mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-17 17:02:09 +00:00
modellist: provide a path property for convenience
This should always be used instead of joining the current model path setting with the filename, as models may be in subdirectories. But fixing this correctly is not in scope for this PR. Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
291b4bf5f6
commit
f8143361d3
@ -258,7 +258,7 @@ int ModelInfo::maxContextLength() const
|
|||||||
{
|
{
|
||||||
if (!installed || isOnline) return -1;
|
if (!installed || isOnline) return -1;
|
||||||
if (m_maxContextLength != -1) return m_maxContextLength;
|
if (m_maxContextLength != -1) return m_maxContextLength;
|
||||||
auto path = (dirpath + filename()).toStdString();
|
auto path = this->path().toStdString();
|
||||||
int n_ctx = LLModel::Implementation::maxContextLength(path);
|
int n_ctx = LLModel::Implementation::maxContextLength(path);
|
||||||
if (n_ctx < 0) {
|
if (n_ctx < 0) {
|
||||||
n_ctx = 4096; // fallback value
|
n_ctx = 4096; // fallback value
|
||||||
@ -282,7 +282,7 @@ int ModelInfo::maxGpuLayers() const
|
|||||||
{
|
{
|
||||||
if (!installed || isOnline) return -1;
|
if (!installed || isOnline) return -1;
|
||||||
if (m_maxGpuLayers != -1) return m_maxGpuLayers;
|
if (m_maxGpuLayers != -1) return m_maxGpuLayers;
|
||||||
auto path = (dirpath + filename()).toStdString();
|
auto path = this->path().toStdString();
|
||||||
int layers = LLModel::Implementation::layerCount(path);
|
int layers = LLModel::Implementation::layerCount(path);
|
||||||
if (layers < 0) {
|
if (layers < 0) {
|
||||||
layers = 100; // fallback value
|
layers = 100; // fallback value
|
||||||
@ -993,7 +993,7 @@ void ModelList::updateDataInternal(const QString &id, const QVector<QPair<int, Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extra guarantee that these always remains in sync with filesystem
|
// Extra guarantee that these always remains in sync with filesystem
|
||||||
QString modelPath = info->dirpath + info->filename();
|
QString modelPath = info->path();
|
||||||
const QFileInfo fileInfo(modelPath);
|
const QFileInfo fileInfo(modelPath);
|
||||||
info->installed = fileInfo.exists();
|
info->installed = fileInfo.exists();
|
||||||
const QFileInfo incompleteInfo(incompleteDownloadPath(info->filename()));
|
const QFileInfo incompleteInfo(incompleteDownloadPath(info->filename()));
|
||||||
|
@ -31,6 +31,7 @@ struct ModelInfo {
|
|||||||
Q_PROPERTY(QString id READ id WRITE setId)
|
Q_PROPERTY(QString id READ id WRITE setId)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(QString filename READ filename WRITE setFilename)
|
Q_PROPERTY(QString filename READ filename WRITE setFilename)
|
||||||
|
Q_PROPERTY(QString path READ path)
|
||||||
Q_PROPERTY(QString dirpath MEMBER dirpath)
|
Q_PROPERTY(QString dirpath MEMBER dirpath)
|
||||||
Q_PROPERTY(QString filesize MEMBER filesize)
|
Q_PROPERTY(QString filesize MEMBER filesize)
|
||||||
Q_PROPERTY(QByteArray hash MEMBER hash)
|
Q_PROPERTY(QByteArray hash MEMBER hash)
|
||||||
@ -94,6 +95,9 @@ public:
|
|||||||
QString filename() const;
|
QString filename() const;
|
||||||
void setFilename(const QString &name);
|
void setFilename(const QString &name);
|
||||||
|
|
||||||
|
// FIXME(jared): This is the one true path of the model. Never use anything else.
|
||||||
|
QString path() const { return dirpath + filename(); }
|
||||||
|
|
||||||
QString description() const;
|
QString description() const;
|
||||||
void setDescription(const QString &d);
|
void setDescription(const QString &d);
|
||||||
|
|
||||||
@ -121,6 +125,7 @@ public:
|
|||||||
QDateTime recency() const;
|
QDateTime recency() const;
|
||||||
void setRecency(const QDateTime &r);
|
void setRecency(const QDateTime &r);
|
||||||
|
|
||||||
|
// FIXME(jared): a class with getters should not also have public mutable fields
|
||||||
QString dirpath;
|
QString dirpath;
|
||||||
QString filesize;
|
QString filesize;
|
||||||
QByteArray hash;
|
QByteArray hash;
|
||||||
|
Loading…
Reference in New Issue
Block a user