mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Provide a description and make the downloader cleaner and prettier.
This commit is contained in:
parent
62a885de40
commit
b00da454e4
37
download.cpp
37
download.cpp
@ -33,19 +33,35 @@ Download::Download()
|
|||||||
m_downloadLocalModelsPath = defaultLocalModelsPath();
|
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
|
QList<ModelInfo> Download::modelList() const
|
||||||
{
|
{
|
||||||
// We make sure the default model is listed first
|
// We make sure the default model is listed first
|
||||||
QList<ModelInfo> values = m_modelMap.values();
|
QList<ModelInfo> values = m_modelMap.values();
|
||||||
|
|
||||||
ModelInfo defaultInfo;
|
ModelInfo defaultInfo;
|
||||||
|
ModelInfo bestGPTJInfo;
|
||||||
|
ModelInfo bestLlamaInfo;
|
||||||
for (ModelInfo v : values) {
|
for (ModelInfo v : values) {
|
||||||
if (v.isDefault) {
|
if (v.isDefault)
|
||||||
defaultInfo = v;
|
defaultInfo = v;
|
||||||
break;
|
if (v.bestGPTJ)
|
||||||
|
bestGPTJInfo = v;
|
||||||
|
if (v.bestLlama)
|
||||||
|
bestLlamaInfo = v;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
values.removeAll(defaultInfo);
|
Q_ASSERT(defaultInfo == bestGPTJInfo || defaultInfo == bestLlamaInfo);
|
||||||
values.prepend(defaultInfo);
|
|
||||||
|
values.removeAll(bestLlamaInfo);
|
||||||
|
values.prepend(bestLlamaInfo);
|
||||||
|
|
||||||
|
values.removeAll(bestGPTJInfo);
|
||||||
|
values.prepend(bestGPTJInfo);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +226,10 @@ void Download::parseJsonFile(const QByteArray &jsonData)
|
|||||||
QString modelFilesize = obj["filesize"].toString();
|
QString modelFilesize = obj["filesize"].toString();
|
||||||
QByteArray modelMd5sum = obj["md5sum"].toString().toLatin1().constData();
|
QByteArray modelMd5sum = obj["md5sum"].toString().toLatin1().constData();
|
||||||
bool isDefault = obj.contains("isDefault") && obj["isDefault"] == QString("true");
|
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)
|
if (isDefault)
|
||||||
defaultModel = modelFilename;
|
defaultModel = modelFilename;
|
||||||
quint64 sz = modelFilesize.toULongLong();
|
quint64 sz = modelFilesize.toULongLong();
|
||||||
@ -231,6 +251,9 @@ void Download::parseJsonFile(const QByteArray &jsonData)
|
|||||||
modelInfo.md5sum = modelMd5sum;
|
modelInfo.md5sum = modelMd5sum;
|
||||||
modelInfo.installed = info.exists();
|
modelInfo.installed = info.exists();
|
||||||
modelInfo.isDefault = isDefault;
|
modelInfo.isDefault = isDefault;
|
||||||
|
modelInfo.bestGPTJ = bestGPTJ;
|
||||||
|
modelInfo.bestLlama = bestLlama;
|
||||||
|
modelInfo.description = description;
|
||||||
m_modelMap.insert(modelInfo.filename, modelInfo);
|
m_modelMap.insert(modelInfo.filename, modelInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,10 +280,6 @@ void Download::handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
|||||||
emit downloadProgress(bytesReceived, bytesTotal, modelFilename);
|
emit downloadProgress(bytesReceived, bytesTotal, modelFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const ModelInfo& lhs, const ModelInfo& rhs) {
|
|
||||||
return lhs.filename == rhs.filename && lhs.md5sum == rhs.md5sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashAndSaveFile::HashAndSaveFile()
|
HashAndSaveFile::HashAndSaveFile()
|
||||||
: QObject(nullptr)
|
: QObject(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,9 @@ struct ModelInfo {
|
|||||||
Q_PROPERTY(bool calcHash MEMBER calcHash)
|
Q_PROPERTY(bool calcHash MEMBER calcHash)
|
||||||
Q_PROPERTY(bool installed MEMBER installed)
|
Q_PROPERTY(bool installed MEMBER installed)
|
||||||
Q_PROPERTY(bool isDefault MEMBER isDefault)
|
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:
|
public:
|
||||||
QString filename;
|
QString filename;
|
||||||
@ -25,6 +28,9 @@ public:
|
|||||||
bool calcHash = false;
|
bool calcHash = false;
|
||||||
bool installed = false;
|
bool installed = false;
|
||||||
bool isDefault = false;
|
bool isDefault = false;
|
||||||
|
bool bestGPTJ = false;
|
||||||
|
bool bestLlama = false;
|
||||||
|
QString description;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(ModelInfo)
|
Q_DECLARE_METATYPE(ModelInfo)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import llm
|
|||||||
Dialog {
|
Dialog {
|
||||||
id: modelDownloaderDialog
|
id: modelDownloaderDialog
|
||||||
width: 1024
|
width: 1024
|
||||||
height: 435
|
height: 600
|
||||||
modal: true
|
modal: true
|
||||||
opacity: 0.9
|
opacity: 0.9
|
||||||
closePolicy: LLM.modelList.length === 0 ? Popup.NoAutoClose : (Popup.CloseOnEscape | Popup.CloseOnPressOutside)
|
closePolicy: LLM.modelList.length === 0 ? Popup.NoAutoClose : (Popup.CloseOnEscape | Popup.CloseOnPressOutside)
|
||||||
@ -54,7 +54,8 @@ Dialog {
|
|||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: delegateItem
|
id: delegateItem
|
||||||
width: modelList.width
|
width: modelList.width
|
||||||
height: 70
|
height: modelName.height + modelName.padding
|
||||||
|
+ description.height + description.padding
|
||||||
objectName: "delegateItem"
|
objectName: "delegateItem"
|
||||||
property bool downloading: false
|
property bool downloading: false
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@ -67,22 +68,37 @@ Dialog {
|
|||||||
objectName: "modelName"
|
objectName: "modelName"
|
||||||
property string filename: modelData.filename
|
property string filename: modelData.filename
|
||||||
text: filename.slice(5, filename.length - 4)
|
text: filename.slice(5, filename.length - 4)
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
padding: 20
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 10
|
font.bold: modelData.isDefault || modelData.bestGPTJ || modelData.bestLlama
|
||||||
color: theme.textColor
|
color: theme.assistantColor
|
||||||
Accessible.role: Accessible.Paragraph
|
Accessible.role: Accessible.Paragraph
|
||||||
Accessible.name: qsTr("Model file")
|
Accessible.name: qsTr("Model file")
|
||||||
Accessible.description: qsTr("Model file to be downloaded")
|
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 {
|
Text {
|
||||||
id: isDefault
|
id: isDefault
|
||||||
text: qsTr("(default)")
|
text: qsTr("(default)")
|
||||||
visible: modelData.isDefault
|
visible: modelData.isDefault
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.left: modelName.right
|
anchors.left: modelName.right
|
||||||
anchors.leftMargin: 10
|
padding: 20
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
Accessible.role: Accessible.Paragraph
|
Accessible.role: Accessible.Paragraph
|
||||||
Accessible.name: qsTr("Default file")
|
Accessible.name: qsTr("Default file")
|
||||||
@ -91,9 +107,9 @@ Dialog {
|
|||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: modelData.filesize
|
text: modelData.filesize
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.left: isDefault.visible ? isDefault.right : modelName.right
|
anchors.left: isDefault.visible ? isDefault.right : modelName.right
|
||||||
anchors.leftMargin: 10
|
padding: 20
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
Accessible.role: Accessible.Paragraph
|
Accessible.role: Accessible.Paragraph
|
||||||
Accessible.name: qsTr("File size")
|
Accessible.name: qsTr("File size")
|
||||||
@ -102,9 +118,9 @@ Dialog {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: speedLabel
|
id: speedLabel
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.right: itemProgressBar.left
|
anchors.right: itemProgressBar.left
|
||||||
anchors.rightMargin: 10
|
padding: 20
|
||||||
objectName: "speedLabel"
|
objectName: "speedLabel"
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
text: ""
|
text: ""
|
||||||
@ -117,9 +133,9 @@ Dialog {
|
|||||||
ProgressBar {
|
ProgressBar {
|
||||||
id: itemProgressBar
|
id: itemProgressBar
|
||||||
objectName: "itemProgressBar"
|
objectName: "itemProgressBar"
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.right: downloadButton.left
|
anchors.right: downloadButton.left
|
||||||
anchors.rightMargin: 10
|
padding: 20
|
||||||
width: 100
|
width: 100
|
||||||
visible: downloading
|
visible: downloading
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
@ -147,15 +163,13 @@ Dialog {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
visible: modelData.calcHash
|
visible: modelData.calcHash
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 10
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: calcHashLabel
|
id: calcHashLabel
|
||||||
anchors.right: busyCalcHash.left
|
anchors.right: busyCalcHash.left
|
||||||
anchors.rightMargin: 10
|
padding: 20
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
objectName: "calcHashLabel"
|
objectName: "calcHashLabel"
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
text: qsTr("Calculating MD5...")
|
text: qsTr("Calculating MD5...")
|
||||||
@ -167,7 +181,7 @@ Dialog {
|
|||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
id: busyCalcHash
|
id: busyCalcHash
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: calcHashLabel.verticalCenter
|
padding: 20
|
||||||
running: modelData.calcHash
|
running: modelData.calcHash
|
||||||
Accessible.role: Accessible.Animation
|
Accessible.role: Accessible.Animation
|
||||||
Accessible.name: qsTr("Busy indicator")
|
Accessible.name: qsTr("Busy indicator")
|
||||||
@ -177,9 +191,9 @@ Dialog {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: installedLabel
|
id: installedLabel
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 15
|
padding: 20
|
||||||
objectName: "installedLabel"
|
objectName: "installedLabel"
|
||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
text: qsTr("Already installed")
|
text: qsTr("Already installed")
|
||||||
@ -195,11 +209,10 @@ Dialog {
|
|||||||
color: theme.textColor
|
color: theme.textColor
|
||||||
text: downloading ? "Cancel" : "Download"
|
text: downloading ? "Cancel" : "Download"
|
||||||
}
|
}
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.top: modelName.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 10
|
padding: 20
|
||||||
visible: !modelData.installed && !modelData.calcHash
|
visible: !modelData.installed && !modelData.calcHash
|
||||||
padding: 10
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!downloading) {
|
if (!downloading) {
|
||||||
downloading = true;
|
downloading = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user