mirror of
https://github.com/nomic-ai/gpt4all
synced 2024-11-08 07:10:32 +00:00
Display filesize info in the model downloader.
This commit is contained in:
parent
9c85a2ceb2
commit
33beec0cdd
16
download.cpp
16
download.cpp
@ -84,14 +84,17 @@ void Download::handleJsonDownloadFinished()
|
|||||||
" {"
|
" {"
|
||||||
" \"md5sum\": \"61d48a82cb188cceb14ebb8082bfec37\","
|
" \"md5sum\": \"61d48a82cb188cceb14ebb8082bfec37\","
|
||||||
" \"filename\": \"ggml-gpt4all-j-v1.1-breezy.bin\""
|
" \"filename\": \"ggml-gpt4all-j-v1.1-breezy.bin\""
|
||||||
|
" \"filesize\": \"3785248281\""
|
||||||
" },"
|
" },"
|
||||||
" {"
|
" {"
|
||||||
" \"md5sum\": \"879344aaa9d62fdccbda0be7a09e7976\","
|
" \"md5sum\": \"879344aaa9d62fdccbda0be7a09e7976\","
|
||||||
" \"filename\": \"ggml-gpt4all-j-v1.2-jazzy.bin\","
|
" \"filename\": \"ggml-gpt4all-j-v1.2-jazzy.bin\","
|
||||||
|
" \"filesize\": \"3785248281\""
|
||||||
" \"isDefault\": \"true\""
|
" \"isDefault\": \"true\""
|
||||||
" },"
|
" },"
|
||||||
" {"
|
" {"
|
||||||
" \"md5sum\": \"5b5a3f9b858d33b29b52b89692415595\","
|
" \"md5sum\": \"5b5a3f9b858d33b29b52b89692415595\","
|
||||||
|
" \"filesize\": \"3785248281\""
|
||||||
" \"filename\": \"ggml-gpt4all-j.bin\""
|
" \"filename\": \"ggml-gpt4all-j.bin\""
|
||||||
" }"
|
" }"
|
||||||
"]"
|
"]"
|
||||||
@ -125,13 +128,26 @@ void Download::parseJsonFile(const QByteArray &jsonData)
|
|||||||
QJsonObject obj = value.toObject();
|
QJsonObject obj = value.toObject();
|
||||||
|
|
||||||
QString modelFilename = obj["filename"].toString();
|
QString modelFilename = obj["filename"].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");
|
||||||
|
|
||||||
|
quint64 sz = modelFilesize.toULongLong();
|
||||||
|
if (sz < 1024) {
|
||||||
|
modelFilesize = QString("%1 bytes").arg(sz);
|
||||||
|
} else if (sz < 1024 * 1024) {
|
||||||
|
modelFilesize = QString("%1 KB").arg(qreal(sz) / 1024, 0, 'g', 3);
|
||||||
|
} else if (sz < 1024 * 1024 * 1024) {
|
||||||
|
modelFilesize = QString("%1 MB").arg(qreal(sz) / (1024 * 1024), 0, 'g', 3);
|
||||||
|
} else {
|
||||||
|
modelFilesize = QString("%1 GB").arg(qreal(sz) / (1024 * 1024 * 1024), 0, 'g', 3);
|
||||||
|
}
|
||||||
|
|
||||||
QString filePath = QCoreApplication::applicationDirPath() + QDir::separator() + modelFilename;
|
QString filePath = QCoreApplication::applicationDirPath() + QDir::separator() + modelFilename;
|
||||||
QFileInfo info(filePath);
|
QFileInfo info(filePath);
|
||||||
ModelInfo modelInfo;
|
ModelInfo modelInfo;
|
||||||
modelInfo.filename = modelFilename;
|
modelInfo.filename = modelFilename;
|
||||||
|
modelInfo.filesize = modelFilesize;
|
||||||
modelInfo.md5sum = modelMd5sum;
|
modelInfo.md5sum = modelMd5sum;
|
||||||
modelInfo.installed = info.exists();
|
modelInfo.installed = info.exists();
|
||||||
modelInfo.isDefault = isDefault;
|
modelInfo.isDefault = isDefault;
|
||||||
|
@ -11,12 +11,14 @@
|
|||||||
struct ModelInfo {
|
struct ModelInfo {
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(QString filename MEMBER filename)
|
Q_PROPERTY(QString filename MEMBER filename)
|
||||||
|
Q_PROPERTY(QString filesize MEMBER filesize)
|
||||||
Q_PROPERTY(QByteArray md5sum MEMBER md5sum)
|
Q_PROPERTY(QByteArray md5sum MEMBER md5sum)
|
||||||
Q_PROPERTY(bool installed MEMBER installed)
|
Q_PROPERTY(bool installed MEMBER installed)
|
||||||
Q_PROPERTY(bool isDefault MEMBER isDefault)
|
Q_PROPERTY(bool isDefault MEMBER isDefault)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString filename;
|
QString filename;
|
||||||
|
QString filesize;
|
||||||
QByteArray md5sum;
|
QByteArray md5sum;
|
||||||
bool installed = false;
|
bool installed = false;
|
||||||
bool isDefault = false;
|
bool isDefault = false;
|
||||||
|
@ -6,7 +6,7 @@ import llm
|
|||||||
|
|
||||||
Dialog {
|
Dialog {
|
||||||
id: modelDownloaderDialog
|
id: modelDownloaderDialog
|
||||||
width: 900
|
width: 1024
|
||||||
height: 400
|
height: 400
|
||||||
title: "Model Downloader"
|
title: "Model Downloader"
|
||||||
modal: true
|
modal: true
|
||||||
@ -74,24 +74,38 @@ Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
id: isDefault
|
||||||
text: qsTr("(default)")
|
text: qsTr("(default)")
|
||||||
visible: modelData.isDefault
|
visible: modelData.isDefault
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.left: modelName.right
|
anchors.left: modelName.right
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
font.pixelSize: 24
|
font.pixelSize: 18
|
||||||
color: "#d1d5db"
|
color: "#d1d5db"
|
||||||
Accessible.role: Accessible.Paragraph
|
Accessible.role: Accessible.Paragraph
|
||||||
Accessible.name: qsTr("Default file")
|
Accessible.name: qsTr("Default file")
|
||||||
Accessible.description: qsTr("Whether the file is the default model")
|
Accessible.description: qsTr("Whether the file is the default model")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: modelData.filesize
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: isDefault.visible ? isDefault.right : modelName.right
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
font.pixelSize: 18
|
||||||
|
color: "#d1d5db"
|
||||||
|
Accessible.role: Accessible.Paragraph
|
||||||
|
Accessible.name: qsTr("File size")
|
||||||
|
Accessible.description: qsTr("The size of the file")
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: speedLabel
|
id: speedLabel
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: itemProgressBar.left
|
anchors.right: itemProgressBar.left
|
||||||
anchors.rightMargin: 10
|
anchors.rightMargin: 10
|
||||||
objectName: "speedLabel"
|
objectName: "speedLabel"
|
||||||
|
font.pixelSize: 18
|
||||||
color: "#d1d5db"
|
color: "#d1d5db"
|
||||||
text: ""
|
text: ""
|
||||||
visible: downloading
|
visible: downloading
|
||||||
|
Loading…
Reference in New Issue
Block a user