mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Restore feature I accidentally erased in modellist update.
This commit is contained in:
parent
b19a3e5b2c
commit
d0a3e82ffc
@ -343,6 +343,15 @@ void Download::parseModelsJsonFile(const QByteArray &jsonData)
|
||||
ModelList::globalInstance()->updateData(modelFilename, ModelList::QuantRole, "NA");
|
||||
ModelList::globalInstance()->updateData(modelFilename, ModelList::TypeRole, "GPT");
|
||||
}
|
||||
|
||||
if (ModelList::globalInstance()->installedModels()->count()) {
|
||||
const QString firstModel =
|
||||
ModelList::globalInstance()->installedModels()->firstFilename();
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
settings.setValue("defaultModel", firstModel);
|
||||
settings.sync();
|
||||
}
|
||||
}
|
||||
|
||||
void Download::handleReleaseJsonDownloadFinished()
|
||||
|
@ -24,6 +24,16 @@ int InstalledModels::count() const
|
||||
return rowCount();
|
||||
}
|
||||
|
||||
QString InstalledModels::firstFilename() const
|
||||
{
|
||||
if (rowCount() > 0) {
|
||||
QModelIndex firstIndex = index(0, 0);
|
||||
return sourceModel()->data(firstIndex, ModelList::FilenameRole).toString();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
DownloadableModels::DownloadableModels(QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_expanded(false)
|
||||
@ -141,15 +151,28 @@ ModelInfo ModelList::defaultModelInfo() const
|
||||
// The user default model can be set by the user in the settings dialog. The "default" user
|
||||
// default model is "Application default" which signals we should use the default model that was
|
||||
// specified by the models.json file.
|
||||
const QString defaultModelName = settings.value("userDefaultModel").toString();
|
||||
const bool hasDefaultName = !defaultModelName.isEmpty() && defaultModelName != "Application default";
|
||||
const QString userDefaultModelName = settings.value("userDefaultModel").toString();
|
||||
const bool hasUserDefaultName = !userDefaultModelName.isEmpty() && userDefaultModelName != "Application default";
|
||||
const QString defaultModelName = settings.value("defaultModel").toString();
|
||||
const bool hasDefaultName = hasUserDefaultName ? false : !defaultModelName.isEmpty();
|
||||
|
||||
ModelInfo *defaultModel = nullptr;
|
||||
for (ModelInfo *info : m_models) {
|
||||
if (!info->installed)
|
||||
continue;
|
||||
defaultModel = info;
|
||||
if (!hasDefaultName) break;
|
||||
if (hasDefaultName && (defaultModel->name == defaultModelName || defaultModel->filename == defaultModelName)) break;
|
||||
|
||||
// If we don't have either setting, then just use the first model that is installed
|
||||
if (!hasUserDefaultName && !hasDefaultName)
|
||||
break;
|
||||
|
||||
// If we don't have a user specified default, but *do* have a default setting and match, then use it
|
||||
if (!hasUserDefaultName && hasDefaultName && (defaultModel->name == defaultModelName || defaultModel->filename == defaultModelName))
|
||||
break;
|
||||
|
||||
// If we have a user specified default and match, then use it
|
||||
if (hasUserDefaultName && (defaultModel->name == userDefaultModelName || defaultModel->filename == userDefaultModelName))
|
||||
break;
|
||||
}
|
||||
if (defaultModel)
|
||||
return *defaultModel;
|
||||
|
@ -73,6 +73,7 @@ class InstalledModels : public QSortFilterProxyModel
|
||||
public:
|
||||
explicit InstalledModels(QObject *parent);
|
||||
int count() const;
|
||||
QString firstFilename() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void countChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user