mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-10 12:21:42 +00:00
Wait just a bit to set the model name so that we can display the proper name instead of filename.
This commit is contained in:
parent
db34a2f670
commit
c24ad02a6a
@ -352,6 +352,8 @@ void Download::parseModelsJsonFile(const QByteArray &jsonData)
|
|||||||
settings.setValue("defaultModel", firstModel);
|
settings.setValue("defaultModel", firstModel);
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelList::globalInstance()->updateModelHasNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Download::handleReleaseJsonDownloadFinished()
|
void Download::handleReleaseJsonDownloadFinished()
|
||||||
|
@ -205,23 +205,40 @@ Window {
|
|||||||
model: ModelList.installedModels
|
model: ModelList.installedModels
|
||||||
valueRole: "filename"
|
valueRole: "filename"
|
||||||
textRole: "name"
|
textRole: "name"
|
||||||
|
property string currentModelName: ""
|
||||||
|
Timer {
|
||||||
|
id: startupTimer
|
||||||
|
interval: 3000 // 3 seconds
|
||||||
|
running: true
|
||||||
|
repeat: false
|
||||||
|
}
|
||||||
|
function updateCurrentModelName() {
|
||||||
|
// During application startup the model names might not be processed yet, so don't
|
||||||
|
// set the combobox text until this is done OR the timer has timed out
|
||||||
|
if (!ModelList.modelHasNames && startupTimer.running)
|
||||||
|
return
|
||||||
|
var info = ModelList.modelInfo(currentChat.modelInfo.filename);
|
||||||
|
comboBox.currentModelName = info.name !== "" ? info.name : info.filename;
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: ModelList
|
||||||
|
function onModelHasNamesChanged() {
|
||||||
|
comboBox.updateCurrentModelName();
|
||||||
|
}
|
||||||
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: currentChat
|
target: currentChat
|
||||||
function onModelInfoChanged() {
|
function onModelInfoChanged() {
|
||||||
comboBox.currentIndex = comboBox.indexOfValue(currentChat.modelInfo.filename)
|
comboBox.updateCurrentModelName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
leftPadding: 10
|
leftPadding: 10
|
||||||
rightPadding: 20
|
rightPadding: 20
|
||||||
text: (ModelList.installedModels.count > 0
|
text: currentChat.modelLoadingError !== ""
|
||||||
? currentChat.modelLoadingError !== "" ? qsTr("Model loading error...")
|
? qsTr("Model loading error...")
|
||||||
: (comboBox.textAt(comboBox.currentIndex) !== ""
|
: comboBox.currentModelName
|
||||||
? comboBox.textAt(comboBox.currentIndex)
|
|
||||||
: (comboBox.valueAt(comboBox.currentIndex) !== "undefined" ? ""
|
|
||||||
: comboBox.valueAt(comboBox.currentIndex)))
|
|
||||||
: "")
|
|
||||||
font: comboBox.font
|
font: comboBox.font
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
@ -245,10 +262,10 @@ Window {
|
|||||||
Accessible.role: Accessible.ComboBox
|
Accessible.role: Accessible.ComboBox
|
||||||
Accessible.name: qsTr("ComboBox for displaying/picking the current model")
|
Accessible.name: qsTr("ComboBox for displaying/picking the current model")
|
||||||
Accessible.description: qsTr("Use this for picking the current model to use; the first item is the current model")
|
Accessible.description: qsTr("Use this for picking the current model to use; the first item is the current model")
|
||||||
onActivated: {
|
onActivated: function (index) {
|
||||||
currentChat.stopGenerating()
|
currentChat.stopGenerating()
|
||||||
currentChat.reset();
|
currentChat.reset();
|
||||||
currentChat.modelInfo = ModelList.modelInfo(comboBox.valueAt(comboBox.currentIndex))
|
currentChat.modelInfo = ModelList.modelInfo(comboBox.valueAt(index))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ ModelList::ModelList()
|
|||||||
: QAbstractListModel(nullptr)
|
: QAbstractListModel(nullptr)
|
||||||
, m_installedModels(new InstalledModels(this))
|
, m_installedModels(new InstalledModels(this))
|
||||||
, m_downloadableModels(new DownloadableModels(this))
|
, m_downloadableModels(new DownloadableModels(this))
|
||||||
|
, m_modelHasNames(false)
|
||||||
{
|
{
|
||||||
m_installedModels->setSourceModel(this);
|
m_installedModels->setSourceModel(this);
|
||||||
m_downloadableModels->setSourceModel(this);
|
m_downloadableModels->setSourceModel(this);
|
||||||
|
@ -116,6 +116,7 @@ class ModelList : public QAbstractListModel
|
|||||||
Q_PROPERTY(InstalledModels* installedModels READ installedModels NOTIFY installedModelsChanged)
|
Q_PROPERTY(InstalledModels* installedModels READ installedModels NOTIFY installedModelsChanged)
|
||||||
Q_PROPERTY(DownloadableModels* downloadableModels READ downloadableModels NOTIFY downloadableModelsChanged)
|
Q_PROPERTY(DownloadableModels* downloadableModels READ downloadableModels NOTIFY downloadableModelsChanged)
|
||||||
Q_PROPERTY(QList<QString> userDefaultModelList READ userDefaultModelList NOTIFY userDefaultModelListChanged)
|
Q_PROPERTY(QList<QString> userDefaultModelList READ userDefaultModelList NOTIFY userDefaultModelListChanged)
|
||||||
|
Q_PROPERTY(bool modelHasNames READ modelHasNames NOTIFY modelHasNamesChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ModelList *globalInstance();
|
static ModelList *globalInstance();
|
||||||
@ -218,12 +219,16 @@ public:
|
|||||||
|
|
||||||
QString incompleteDownloadPath(const QString &modelFile);
|
QString incompleteDownloadPath(const QString &modelFile);
|
||||||
|
|
||||||
|
bool modelHasNames() const { return m_modelHasNames; }
|
||||||
|
void updateModelHasNames() { m_modelHasNames = true; emit modelHasNamesChanged(); }
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void localModelsPathChanged();
|
void localModelsPathChanged();
|
||||||
void installedModelsChanged();
|
void installedModelsChanged();
|
||||||
void downloadableModelsChanged();
|
void downloadableModelsChanged();
|
||||||
void userDefaultModelListChanged();
|
void userDefaultModelListChanged();
|
||||||
|
void modelHasNamesChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateModelsFromDirectory();
|
void updateModelsFromDirectory();
|
||||||
@ -242,6 +247,7 @@ private:
|
|||||||
QHash<QString, ModelInfo*> m_modelMap;
|
QHash<QString, ModelInfo*> m_modelMap;
|
||||||
QString m_localModelsPath;
|
QString m_localModelsPath;
|
||||||
QFileSystemWatcher *m_watcher;
|
QFileSystemWatcher *m_watcher;
|
||||||
|
bool m_modelHasNames;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit ModelList();
|
explicit ModelList();
|
||||||
|
Loading…
Reference in New Issue
Block a user