mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-07-06 12:06:54 +00:00
fix removal of models in subdirectories
removeModel is starting to make sense now. Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
f8143361d3
commit
8a64b039dc
@ -441,9 +441,7 @@ Rectangle {
|
|||||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||||
visible: !isDownloading && (installed || isIncomplete)
|
visible: !isDownloading && (installed || isIncomplete)
|
||||||
Accessible.description: qsTr("Remove model from filesystem")
|
Accessible.description: qsTr("Remove model from filesystem")
|
||||||
onClicked: {
|
onClicked: Download.removeModel(id)
|
||||||
Download.removeModel(filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MySettingsButton {
|
MySettingsButton {
|
||||||
|
@ -221,9 +221,7 @@ Rectangle {
|
|||||||
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
|
||||||
visible: !isDownloading && (installed || isIncomplete)
|
visible: !isDownloading && (installed || isIncomplete)
|
||||||
Accessible.description: qsTr("Remove model from filesystem")
|
Accessible.description: qsTr("Remove model from filesystem")
|
||||||
onClicked: {
|
onClicked: Download.removeModel(id)
|
||||||
Download.removeModel(filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MySettingsButton {
|
MySettingsButton {
|
||||||
|
@ -328,27 +328,28 @@ void Download::installCompatibleModel(const QString &modelName, const QString &a
|
|||||||
ModelList::globalInstance()->updateDataByFilename(modelFile, {{ ModelList::InstalledRole, true }});
|
ModelList::globalInstance()->updateDataByFilename(modelFile, {{ ModelList::InstalledRole, true }});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Download::removeModel(const QString &modelFile)
|
// FIXME(jared): With the current implementation, it is not possible to remove a duplicate
|
||||||
|
// model file (same filename, different subdirectory) from within GPT4All
|
||||||
|
// without restarting it.
|
||||||
|
void Download::removeModel(const QString &id)
|
||||||
{
|
{
|
||||||
auto *modelList = ModelList::globalInstance();
|
auto *modelList = ModelList::globalInstance();
|
||||||
auto *mySettings = MySettings::globalInstance();
|
|
||||||
|
|
||||||
QFile incompleteFile(modelList->incompleteDownloadPath(modelFile));
|
auto info = modelList->modelInfo(id);
|
||||||
if (incompleteFile.exists())
|
if (info.id().isEmpty())
|
||||||
incompleteFile.remove();
|
return;
|
||||||
|
|
||||||
bool shouldRemoveInstalled = false;
|
Network::globalInstance()->trackEvent("remove_model", { {"model", info.filename()} });
|
||||||
|
|
||||||
QFile file(mySettings->modelPath() + modelFile);
|
// remove incomplete download
|
||||||
const ModelInfo info = modelList->modelInfoByFilename(modelFile);
|
QFile(modelList->incompleteDownloadPath(info.filename())).remove();
|
||||||
|
|
||||||
Network::globalInstance()->trackEvent("remove_model", { {"model", modelFile}, {"exists", file.exists()} });
|
// remove file, if this is a real model
|
||||||
|
|
||||||
if (file.exists()) {
|
|
||||||
modelList->uninstall(info);
|
|
||||||
if (!info.isClone())
|
if (!info.isClone())
|
||||||
file.remove();
|
QFile(info.path()).remove();
|
||||||
}
|
|
||||||
|
// remove model list entry
|
||||||
|
modelList->uninstall(info);
|
||||||
|
|
||||||
emit toastMessage(tr("Model \"%1\" is removed.").arg(info.name()));
|
emit toastMessage(tr("Model \"%1\" is removed.").arg(info.name()));
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
Q_INVOKABLE void cancelDownload(const QString &modelFile);
|
Q_INVOKABLE void cancelDownload(const QString &modelFile);
|
||||||
Q_INVOKABLE void installModel(const QString &modelFile, const QString &apiKey);
|
Q_INVOKABLE void installModel(const QString &modelFile, const QString &apiKey);
|
||||||
Q_INVOKABLE void installCompatibleModel(const QString &modelName, const QString &apiKey, const QString &baseUrl);
|
Q_INVOKABLE void installCompatibleModel(const QString &modelName, const QString &apiKey, const QString &baseUrl);
|
||||||
Q_INVOKABLE void removeModel(const QString &modelFile);
|
Q_INVOKABLE void removeModel(const QString &id);
|
||||||
Q_INVOKABLE bool isFirstStart(bool writeVersion = false) const;
|
Q_INVOKABLE bool isFirstStart(bool writeVersion = false) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
Loading…
Reference in New Issue
Block a user