mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-06 02:50:36 +00:00
Modellist temp
This commit is contained in:
@@ -9,41 +9,6 @@
|
||||
#include <QTemporaryFile>
|
||||
#include <QThread>
|
||||
|
||||
struct ModelInfo {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString filename MEMBER filename)
|
||||
Q_PROPERTY(QString filesize MEMBER filesize)
|
||||
Q_PROPERTY(QByteArray md5sum MEMBER md5sum)
|
||||
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(bool bestMPT MEMBER bestMPT)
|
||||
Q_PROPERTY(bool isChatGPT MEMBER isChatGPT)
|
||||
Q_PROPERTY(QString description MEMBER description)
|
||||
Q_PROPERTY(QString requiresVersion MEMBER requiresVersion)
|
||||
Q_PROPERTY(QString deprecatedVersion MEMBER deprecatedVersion)
|
||||
Q_PROPERTY(QString url MEMBER url)
|
||||
|
||||
public:
|
||||
QString filename;
|
||||
QString filesize;
|
||||
QByteArray md5sum;
|
||||
bool calcHash = false;
|
||||
bool installed = false;
|
||||
bool isDefault = false;
|
||||
bool bestGPTJ = false;
|
||||
bool bestLlama = false;
|
||||
bool bestMPT = false;
|
||||
bool isChatGPT = false;
|
||||
QString description;
|
||||
QString requiresVersion;
|
||||
QString deprecatedVersion;
|
||||
QString url;
|
||||
};
|
||||
Q_DECLARE_METATYPE(ModelInfo)
|
||||
|
||||
struct ReleaseInfo {
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString version MEMBER version)
|
||||
@@ -67,7 +32,7 @@ public Q_SLOTS:
|
||||
QFile *tempFile, QNetworkReply *modelReply);
|
||||
|
||||
Q_SIGNALS:
|
||||
void hashAndSaveFinished(bool success,
|
||||
void hashAndSaveFinished(bool success, const QString &error,
|
||||
QFile *tempFile, QNetworkReply *modelReply);
|
||||
|
||||
private:
|
||||
@@ -77,30 +42,24 @@ private:
|
||||
class Download : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QList<ModelInfo> modelList READ modelList NOTIFY modelListChanged)
|
||||
Q_PROPERTY(bool hasNewerRelease READ hasNewerRelease NOTIFY hasNewerReleaseChanged)
|
||||
Q_PROPERTY(ReleaseInfo releaseInfo READ releaseInfo NOTIFY releaseInfoChanged)
|
||||
Q_PROPERTY(QString downloadLocalModelsPath READ downloadLocalModelsPath
|
||||
WRITE setDownloadLocalModelsPath
|
||||
NOTIFY downloadLocalModelsPathChanged)
|
||||
|
||||
public:
|
||||
static Download *globalInstance();
|
||||
|
||||
QList<ModelInfo> modelList() const;
|
||||
ReleaseInfo releaseInfo() const;
|
||||
bool hasNewerRelease() const;
|
||||
Q_INVOKABLE void updateModelList();
|
||||
Q_INVOKABLE void updateReleaseNotes();
|
||||
Q_INVOKABLE void downloadModel(const QString &modelFile);
|
||||
Q_INVOKABLE void cancelDownload(const QString &modelFile);
|
||||
Q_INVOKABLE void installModel(const QString &modelFile, const QString &apiKey);
|
||||
Q_INVOKABLE void removeModel(const QString &modelFile);
|
||||
Q_INVOKABLE QString defaultLocalModelsPath() const;
|
||||
Q_INVOKABLE QString downloadLocalModelsPath() const;
|
||||
Q_INVOKABLE void setDownloadLocalModelsPath(const QString &modelPath);
|
||||
Q_INVOKABLE bool isFirstStart() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateModelList();
|
||||
void updateReleaseNotes();
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
void handleModelsJsonDownloadFinished();
|
||||
@@ -108,17 +67,13 @@ private Q_SLOTS:
|
||||
void handleErrorOccurred(QNetworkReply::NetworkError code);
|
||||
void handleDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
void handleModelDownloadFinished();
|
||||
void handleHashAndSaveFinished(bool success,
|
||||
void handleHashAndSaveFinished(bool success, const QString &error,
|
||||
QFile *tempFile, QNetworkReply *modelReply);
|
||||
void handleReadyRead();
|
||||
|
||||
Q_SIGNALS:
|
||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal, const QString &modelFile);
|
||||
void downloadFinished(const QString &modelFile);
|
||||
void modelListChanged();
|
||||
void releaseInfoChanged();
|
||||
void hasNewerReleaseChanged();
|
||||
void downloadLocalModelsPathChanged();
|
||||
void requestHashAndSave(const QString &hash, const QString &saveFilePath,
|
||||
QFile *tempFile, QNetworkReply *modelReply);
|
||||
|
||||
@@ -128,11 +83,9 @@ private:
|
||||
QString incompleteDownloadPath(const QString &modelFile);
|
||||
|
||||
HashAndSaveFile *m_hashAndSave;
|
||||
QMap<QString, ModelInfo> m_modelMap;
|
||||
QMap<QString, ReleaseInfo> m_releaseMap;
|
||||
QNetworkAccessManager m_networkManager;
|
||||
QMap<QNetworkReply*, QFile*> m_activeDownloads;
|
||||
QString m_downloadLocalModelsPath;
|
||||
QDateTime m_startTime;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user