From 069c243f1acd126db468d7de7639becfef9f4665 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Tue, 9 May 2023 12:09:49 -0400 Subject: [PATCH] Add MPT info to the download list and fix it so that isDefault will work even if the required version isn't there. --- download.cpp | 37 +++++++++++++++++++++++++------------ download.h | 1 + 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/download.cpp b/download.cpp index ec4735c5..72398058 100644 --- a/download.cpp +++ b/download.cpp @@ -69,34 +69,39 @@ QList Download::modelList() const { // We make sure the default model is listed first QList values = m_modelMap.values(); - const QString currentVersion = QCoreApplication::applicationVersion(); - ModelInfo defaultInfo; ModelInfo bestGPTJInfo; ModelInfo bestLlamaInfo; + ModelInfo bestMPTInfo; QList filtered; for (ModelInfo v : values) { - if (!v.requires.isEmpty() - && v.requires != currentVersion - && compareVersions(v.requires, currentVersion)) { - continue; - } if (v.isDefault) defaultInfo = v; if (v.bestGPTJ) bestGPTJInfo = v; if (v.bestLlama) bestLlamaInfo = v; + if (v.bestMPT) + bestMPTInfo = v; filtered.append(v); } - Q_ASSERT(defaultInfo == bestGPTJInfo || defaultInfo == bestLlamaInfo); + Q_ASSERT(defaultInfo == bestGPTJInfo || defaultInfo == bestLlamaInfo || defaultInfo == bestMPTInfo); + + if (bestLlamaInfo.bestLlama) { + filtered.removeAll(bestLlamaInfo); + filtered.prepend(bestLlamaInfo); + } - filtered.removeAll(bestLlamaInfo); - filtered.prepend(bestLlamaInfo); + if (bestGPTJInfo.bestGPTJ) { + filtered.removeAll(bestGPTJInfo); + filtered.prepend(bestGPTJInfo); + } - filtered.removeAll(bestGPTJInfo); - filtered.prepend(bestGPTJInfo); + if (bestMPTInfo.bestMPT) { + filtered.removeAll(bestMPTInfo); + filtered.prepend(bestMPTInfo); + } return filtered; } @@ -316,6 +321,7 @@ void Download::parseModelsJsonFile(const QByteArray &jsonData) QString defaultModel; QJsonArray jsonArray = document.array(); + const QString currentVersion = QCoreApplication::applicationVersion(); m_modelMap.clear(); for (const QJsonValue &value : jsonArray) { @@ -328,8 +334,15 @@ void Download::parseModelsJsonFile(const QByteArray &jsonData) bool isDefault = obj.contains("isDefault") && obj["isDefault"] == QString("true"); bool bestGPTJ = obj.contains("bestGPTJ") && obj["bestGPTJ"] == QString("true"); bool bestLlama = obj.contains("bestLlama") && obj["bestLlama"] == QString("true"); + bool bestMPT = obj.contains("bestMPT") && obj["bestMPT"] == QString("true"); QString description = obj["description"].toString(); + if (!requires.isEmpty() + && requires != currentVersion + && compareVersions(requires, currentVersion)) { + continue; + } + if (isDefault) defaultModel = modelFilename; quint64 sz = modelFilesize.toULongLong(); diff --git a/download.h b/download.h index 7aa5b9fc..5bcef9d9 100644 --- a/download.h +++ b/download.h @@ -31,6 +31,7 @@ public: bool isDefault = false; bool bestGPTJ = false; bool bestLlama = false; + bool bestMPT = false; QString description; QString requires; };