Provide a description and make the downloader cleaner and prettier.

pull/520/head
Adam Treat 1 year ago
parent 62a885de40
commit b00da454e4

@ -33,19 +33,35 @@ Download::Download()
m_downloadLocalModelsPath = defaultLocalModelsPath();
}
bool operator==(const ModelInfo& lhs, const ModelInfo& rhs) {
return lhs.filename == rhs.filename && lhs.md5sum == rhs.md5sum;
}
QList<ModelInfo> Download::modelList() const
{
// We make sure the default model is listed first
QList<ModelInfo> values = m_modelMap.values();
ModelInfo defaultInfo;
ModelInfo bestGPTJInfo;
ModelInfo bestLlamaInfo;
for (ModelInfo v : values) {
if (v.isDefault) {
if (v.isDefault)
defaultInfo = v;
break;
}
if (v.bestGPTJ)
bestGPTJInfo = v;
if (v.bestLlama)
bestLlamaInfo = v;
}
values.removeAll(defaultInfo);
values.prepend(defaultInfo);
Q_ASSERT(defaultInfo == bestGPTJInfo || defaultInfo == bestLlamaInfo);
values.removeAll(bestLlamaInfo);
values.prepend(bestLlamaInfo);
values.removeAll(bestGPTJInfo);
values.prepend(bestGPTJInfo);
return values;
}
@ -210,6 +226,10 @@ void Download::parseJsonFile(const QByteArray &jsonData)
QString modelFilesize = obj["filesize"].toString();
QByteArray modelMd5sum = obj["md5sum"].toString().toLatin1().constData();
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");
QString description = obj["description"].toString();
if (isDefault)
defaultModel = modelFilename;
quint64 sz = modelFilesize.toULongLong();
@ -231,6 +251,9 @@ void Download::parseJsonFile(const QByteArray &jsonData)
modelInfo.md5sum = modelMd5sum;
modelInfo.installed = info.exists();
modelInfo.isDefault = isDefault;
modelInfo.bestGPTJ = bestGPTJ;
modelInfo.bestLlama = bestLlama;
modelInfo.description = description;
m_modelMap.insert(modelInfo.filename, modelInfo);
}
@ -257,10 +280,6 @@ void Download::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
emit downloadProgress(bytesReceived, bytesTotal, modelFilename);
}
bool operator==(const ModelInfo& lhs, const ModelInfo& rhs) {
return lhs.filename == rhs.filename && lhs.md5sum == rhs.md5sum;
}
HashAndSaveFile::HashAndSaveFile()
: QObject(nullptr)
{

@ -17,6 +17,9 @@ struct ModelInfo {
Q_PROPERTY(bool calcHash MEMBER calcHash)
Q_PROPERTY(bool installed MEMBER installed)
Q_PROPERTY(bool isDefault MEMBER isDefault)
Q_PROPERTY(bool bestGPTJ MEMBER bestGPTJ)
Q_PROPERTY(bool bestLlama MEMBER bestLlama)
Q_PROPERTY(QString description MEMBER description)
public:
QString filename;
@ -25,6 +28,9 @@ public:
bool calcHash = false;
bool installed = false;
bool isDefault = false;
bool bestGPTJ = false;
bool bestLlama = false;
QString description;
};
Q_DECLARE_METATYPE(ModelInfo)

@ -8,7 +8,7 @@ import llm
Dialog {
id: modelDownloaderDialog
width: 1024
height: 435
height: 600
modal: true
opacity: 0.9
closePolicy: LLM.modelList.length === 0 ? Popup.NoAutoClose : (Popup.CloseOnEscape | Popup.CloseOnPressOutside)
@ -54,7 +54,8 @@ Dialog {
delegate: Item {
id: delegateItem
width: modelList.width
height: 70
height: modelName.height + modelName.padding
+ description.height + description.padding
objectName: "delegateItem"
property bool downloading: false
Rectangle {
@ -67,22 +68,37 @@ Dialog {
objectName: "modelName"
property string filename: modelData.filename
text: filename.slice(5, filename.length - 4)
anchors.verticalCenter: parent.verticalCenter
padding: 20
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 10
color: theme.textColor
font.bold: modelData.isDefault || modelData.bestGPTJ || modelData.bestLlama
color: theme.assistantColor
Accessible.role: Accessible.Paragraph
Accessible.name: qsTr("Model file")
Accessible.description: qsTr("Model file to be downloaded")
}
Text {
id: description
text: " - " + modelData.description
leftPadding: 20
anchors.top: modelName.bottom
anchors.left: modelName.left
anchors.right: parent.right
wrapMode: Text.WordWrap
color: theme.textColor
Accessible.role: Accessible.Paragraph
Accessible.name: qsTr("Description")
Accessible.description: qsTr("The description of the file")
}
Text {
id: isDefault
text: qsTr("(default)")
visible: modelData.isDefault
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.left: modelName.right
anchors.leftMargin: 10
padding: 20
color: theme.textColor
Accessible.role: Accessible.Paragraph
Accessible.name: qsTr("Default file")
@ -91,9 +107,9 @@ Dialog {
Text {
text: modelData.filesize
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.left: isDefault.visible ? isDefault.right : modelName.right
anchors.leftMargin: 10
padding: 20
color: theme.textColor
Accessible.role: Accessible.Paragraph
Accessible.name: qsTr("File size")
@ -102,9 +118,9 @@ Dialog {
Label {
id: speedLabel
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.right: itemProgressBar.left
anchors.rightMargin: 10
padding: 20
objectName: "speedLabel"
color: theme.textColor
text: ""
@ -117,9 +133,9 @@ Dialog {
ProgressBar {
id: itemProgressBar
objectName: "itemProgressBar"
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.right: downloadButton.left
anchors.rightMargin: 10
padding: 20
width: 100
visible: downloading
background: Rectangle {
@ -147,15 +163,13 @@ Dialog {
Item {
visible: modelData.calcHash
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.right: parent.right
anchors.rightMargin: 10
Label {
id: calcHashLabel
anchors.right: busyCalcHash.left
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
padding: 20
objectName: "calcHashLabel"
color: theme.textColor
text: qsTr("Calculating MD5...")
@ -167,7 +181,7 @@ Dialog {
BusyIndicator {
id: busyCalcHash
anchors.right: parent.right
anchors.verticalCenter: calcHashLabel.verticalCenter
padding: 20
running: modelData.calcHash
Accessible.role: Accessible.Animation
Accessible.name: qsTr("Busy indicator")
@ -177,9 +191,9 @@ Dialog {
Label {
id: installedLabel
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.right: parent.right
anchors.rightMargin: 15
padding: 20
objectName: "installedLabel"
color: theme.textColor
text: qsTr("Already installed")
@ -195,11 +209,10 @@ Dialog {
color: theme.textColor
text: downloading ? "Cancel" : "Download"
}
anchors.verticalCenter: parent.verticalCenter
anchors.top: modelName.top
anchors.right: parent.right
anchors.rightMargin: 10
padding: 20
visible: !modelData.installed && !modelData.calcHash
padding: 10
onClicked: {
if (!downloading) {
downloading = true;

Loading…
Cancel
Save