mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-08-03 09:09:07 +00:00
modellist: rename "deprecated" to "removedIn", disable if equal (#2063)
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
402f515a5d
commit
5a874be7c1
@ -6,6 +6,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <compare>
|
||||||
|
|
||||||
//#define USE_LOCAL_MODELSJSON
|
//#define USE_LOCAL_MODELSJSON
|
||||||
|
|
||||||
@ -691,8 +692,8 @@ QVariant ModelList::dataInternal(const ModelInfo *info, int role) const
|
|||||||
return info->description();
|
return info->description();
|
||||||
case RequiresVersionRole:
|
case RequiresVersionRole:
|
||||||
return info->requiresVersion;
|
return info->requiresVersion;
|
||||||
case DeprecatedVersionRole:
|
case VersionRemovedRole:
|
||||||
return info->deprecatedVersion;
|
return info->versionRemoved;
|
||||||
case UrlRole:
|
case UrlRole:
|
||||||
return info->url();
|
return info->url();
|
||||||
case BytesReceivedRole:
|
case BytesReceivedRole:
|
||||||
@ -840,8 +841,8 @@ void ModelList::updateData(const QString &id, const QVector<QPair<int, QVariant>
|
|||||||
info->setDescription(value.toString()); break;
|
info->setDescription(value.toString()); break;
|
||||||
case RequiresVersionRole:
|
case RequiresVersionRole:
|
||||||
info->requiresVersion = value.toString(); break;
|
info->requiresVersion = value.toString(); break;
|
||||||
case DeprecatedVersionRole:
|
case VersionRemovedRole:
|
||||||
info->deprecatedVersion = value.toString(); break;
|
info->versionRemoved = value.toString(); break;
|
||||||
case UrlRole:
|
case UrlRole:
|
||||||
info->setUrl(value.toString()); break;
|
info->setUrl(value.toString()); break;
|
||||||
case BytesReceivedRole:
|
case BytesReceivedRole:
|
||||||
@ -1277,22 +1278,19 @@ void ModelList::updateDataForSettings()
|
|||||||
emit dataChanged(index(0, 0), index(m_models.size() - 1, 0));
|
emit dataChanged(index(0, 0), index(m_models.size() - 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compareVersions(const QString &a, const QString &b) {
|
static std::strong_ordering compareVersions(const QString &a, const QString &b) {
|
||||||
QStringList aParts = a.split('.');
|
QStringList aParts = a.split('.');
|
||||||
QStringList bParts = b.split('.');
|
QStringList bParts = b.split('.');
|
||||||
|
|
||||||
for (int i = 0; i < std::min(aParts.size(), bParts.size()); ++i) {
|
for (int i = 0; i < std::min(aParts.size(), bParts.size()); ++i) {
|
||||||
int aInt = aParts[i].toInt();
|
int aInt = aParts[i].toInt();
|
||||||
int bInt = bParts[i].toInt();
|
int bInt = bParts[i].toInt();
|
||||||
|
if (auto diff = aInt <=> bInt; diff != 0) {
|
||||||
if (aInt > bInt) {
|
return diff;
|
||||||
return true;
|
|
||||||
} else if (aInt < bInt) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return aParts.size() > bParts.size();
|
return aParts.size() <=> bParts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
||||||
@ -1328,7 +1326,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
|||||||
QString modelFilename = obj["filename"].toString();
|
QString modelFilename = obj["filename"].toString();
|
||||||
QString modelFilesize = obj["filesize"].toString();
|
QString modelFilesize = obj["filesize"].toString();
|
||||||
QString requiresVersion = obj["requires"].toString();
|
QString requiresVersion = obj["requires"].toString();
|
||||||
QString deprecatedVersion = obj["deprecated"].toString();
|
QString versionRemoved = obj["removedIn"].toString();
|
||||||
QString url = obj["url"].toString();
|
QString url = obj["url"].toString();
|
||||||
QByteArray modelHash = obj["md5sum"].toString().toLatin1().constData();
|
QByteArray modelHash = obj["md5sum"].toString().toLatin1().constData();
|
||||||
bool isDefault = obj.contains("isDefault") && obj["isDefault"] == QString("true");
|
bool isDefault = obj.contains("isDefault") && obj["isDefault"] == QString("true");
|
||||||
@ -1340,16 +1338,13 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
|||||||
QString quant = obj["quant"].toString();
|
QString quant = obj["quant"].toString();
|
||||||
QString type = obj["type"].toString();
|
QString type = obj["type"].toString();
|
||||||
|
|
||||||
// If the currentVersion version is strictly less than required version, then continue
|
// If the current version is strictly less than required version, then skip
|
||||||
if (!requiresVersion.isEmpty()
|
if (!requiresVersion.isEmpty() && compareVersions(currentVersion, requiresVersion) < 0) {
|
||||||
&& requiresVersion != currentVersion
|
|
||||||
&& compareVersions(requiresVersion, currentVersion)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current version is strictly greater than the deprecated version, then continue
|
// If the version removed is less than or equal to the current version, then skip
|
||||||
if (!deprecatedVersion.isEmpty()
|
if (!versionRemoved.isEmpty() && compareVersions(versionRemoved, currentVersion) <= 0) {
|
||||||
&& compareVersions(currentVersion, deprecatedVersion)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,7 +1367,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
|||||||
updateData(id, ModelList::DefaultRole, isDefault);
|
updateData(id, ModelList::DefaultRole, isDefault);
|
||||||
updateData(id, ModelList::DescriptionRole, description);
|
updateData(id, ModelList::DescriptionRole, description);
|
||||||
updateData(id, ModelList::RequiresVersionRole, requiresVersion);
|
updateData(id, ModelList::RequiresVersionRole, requiresVersion);
|
||||||
updateData(id, ModelList::DeprecatedVersionRole, deprecatedVersion);
|
updateData(id, ModelList::VersionRemovedRole, versionRemoved);
|
||||||
updateData(id, ModelList::UrlRole, url);
|
updateData(id, ModelList::UrlRole, url);
|
||||||
updateData(id, ModelList::DisableGUIRole, disableGUI);
|
updateData(id, ModelList::DisableGUIRole, disableGUI);
|
||||||
updateData(id, ModelList::OrderRole, order);
|
updateData(id, ModelList::OrderRole, order);
|
||||||
|
@ -20,7 +20,7 @@ struct ModelInfo {
|
|||||||
Q_PROPERTY(bool isOnline MEMBER isOnline)
|
Q_PROPERTY(bool isOnline MEMBER isOnline)
|
||||||
Q_PROPERTY(QString description READ description WRITE setDescription)
|
Q_PROPERTY(QString description READ description WRITE setDescription)
|
||||||
Q_PROPERTY(QString requiresVersion MEMBER requiresVersion)
|
Q_PROPERTY(QString requiresVersion MEMBER requiresVersion)
|
||||||
Q_PROPERTY(QString deprecatedVersion MEMBER deprecatedVersion)
|
Q_PROPERTY(QString versionRemoved MEMBER versionRemoved)
|
||||||
Q_PROPERTY(QString url READ url WRITE setUrl)
|
Q_PROPERTY(QString url READ url WRITE setUrl)
|
||||||
Q_PROPERTY(qint64 bytesReceived MEMBER bytesReceived)
|
Q_PROPERTY(qint64 bytesReceived MEMBER bytesReceived)
|
||||||
Q_PROPERTY(qint64 bytesTotal MEMBER bytesTotal)
|
Q_PROPERTY(qint64 bytesTotal MEMBER bytesTotal)
|
||||||
@ -106,7 +106,7 @@ public:
|
|||||||
bool isOnline = false;
|
bool isOnline = false;
|
||||||
bool disableGUI = false;
|
bool disableGUI = false;
|
||||||
QString requiresVersion;
|
QString requiresVersion;
|
||||||
QString deprecatedVersion;
|
QString versionRemoved;
|
||||||
qint64 bytesReceived = 0;
|
qint64 bytesReceived = 0;
|
||||||
qint64 bytesTotal = 0;
|
qint64 bytesTotal = 0;
|
||||||
qint64 timestamp = 0;
|
qint64 timestamp = 0;
|
||||||
@ -285,7 +285,7 @@ public:
|
|||||||
DisableGUIRole,
|
DisableGUIRole,
|
||||||
DescriptionRole,
|
DescriptionRole,
|
||||||
RequiresVersionRole,
|
RequiresVersionRole,
|
||||||
DeprecatedVersionRole,
|
VersionRemovedRole,
|
||||||
UrlRole,
|
UrlRole,
|
||||||
BytesReceivedRole,
|
BytesReceivedRole,
|
||||||
BytesTotalRole,
|
BytesTotalRole,
|
||||||
@ -335,7 +335,7 @@ public:
|
|||||||
roles[DisableGUIRole] = "disableGUI";
|
roles[DisableGUIRole] = "disableGUI";
|
||||||
roles[DescriptionRole] = "description";
|
roles[DescriptionRole] = "description";
|
||||||
roles[RequiresVersionRole] = "requiresVersion";
|
roles[RequiresVersionRole] = "requiresVersion";
|
||||||
roles[DeprecatedVersionRole] = "deprecatedVersion";
|
roles[VersionRemovedRole] = "versionRemoved";
|
||||||
roles[UrlRole] = "url";
|
roles[UrlRole] = "url";
|
||||||
roles[BytesReceivedRole] = "bytesReceived";
|
roles[BytesReceivedRole] = "bytesReceived";
|
||||||
roles[BytesTotalRole] = "bytesTotal";
|
roles[BytesTotalRole] = "bytesTotal";
|
||||||
|
Loading…
Reference in New Issue
Block a user