mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-17 08:52:06 +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 (m_maxContextLength != -1) return m_maxContextLength;
|
||||
auto path = (dirpath + filename()).toStdString();
|
||||
auto path = this->path().toStdString();
|
||||
int n_ctx = LLModel::Implementation::maxContextLength(path);
|
||||
if (n_ctx < 0) {
|
||||
n_ctx = 4096; // fallback value
|
||||
@ -282,7 +282,7 @@ int ModelInfo::maxGpuLayers() const
|
||||
{
|
||||
if (!installed || isOnline) return -1;
|
||||
if (m_maxGpuLayers != -1) return m_maxGpuLayers;
|
||||
auto path = (dirpath + filename()).toStdString();
|
||||
auto path = this->path().toStdString();
|
||||
int layers = LLModel::Implementation::layerCount(path);
|
||||
if (layers < 0) {
|
||||
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
|
||||
QString modelPath = info->dirpath + info->filename();
|
||||
QString modelPath = info->path();
|
||||
const QFileInfo fileInfo(modelPath);
|
||||
info->installed = fileInfo.exists();
|
||||
const QFileInfo incompleteInfo(incompleteDownloadPath(info->filename()));
|
||||
|
@ -31,6 +31,7 @@ struct ModelInfo {
|
||||
Q_PROPERTY(QString id READ id WRITE setId)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString filename READ filename WRITE setFilename)
|
||||
Q_PROPERTY(QString path READ path)
|
||||
Q_PROPERTY(QString dirpath MEMBER dirpath)
|
||||
Q_PROPERTY(QString filesize MEMBER filesize)
|
||||
Q_PROPERTY(QByteArray hash MEMBER hash)
|
||||
@ -94,6 +95,9 @@ public:
|
||||
QString filename() const;
|
||||
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;
|
||||
void setDescription(const QString &d);
|
||||
|
||||
@ -121,6 +125,7 @@ public:
|
||||
QDateTime recency() const;
|
||||
void setRecency(const QDateTime &r);
|
||||
|
||||
// FIXME(jared): a class with getters should not also have public mutable fields
|
||||
QString dirpath;
|
||||
QString filesize;
|
||||
QByteArray hash;
|
||||
|
Loading…
Reference in New Issue
Block a user