2023-06-27 11:54:34 -04:00
|
|
|
#ifndef MYSETTINGS_H
|
|
|
|
#define MYSETTINGS_H
|
|
|
|
|
2023-12-16 17:58:15 -05:00
|
|
|
#include <cstdint>
|
|
|
|
|
2023-06-27 11:54:34 -04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QMutex>
|
|
|
|
|
2023-07-05 15:35:52 -04:00
|
|
|
#include "modellist.h"
|
|
|
|
|
2023-06-27 11:54:34 -04:00
|
|
|
class MySettings : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-06-28 13:47:57 -04:00
|
|
|
Q_PROPERTY(int threadCount READ threadCount WRITE setThreadCount NOTIFY threadCountChanged)
|
2023-10-11 10:23:33 -04:00
|
|
|
Q_PROPERTY(bool saveChatsContext READ saveChatsContext WRITE setSaveChatsContext NOTIFY saveChatsContextChanged)
|
2023-06-28 13:47:57 -04:00
|
|
|
Q_PROPERTY(bool serverChat READ serverChat WRITE setServerChat NOTIFY serverChatChanged)
|
|
|
|
Q_PROPERTY(QString modelPath READ modelPath WRITE setModelPath NOTIFY modelPathChanged)
|
|
|
|
Q_PROPERTY(QString userDefaultModel READ userDefaultModel WRITE setUserDefaultModel NOTIFY userDefaultModelChanged)
|
2023-07-26 15:42:07 -04:00
|
|
|
Q_PROPERTY(QString chatTheme READ chatTheme WRITE setChatTheme NOTIFY chatThemeChanged)
|
2023-08-07 13:54:13 -04:00
|
|
|
Q_PROPERTY(QString fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
2023-06-27 11:54:34 -04:00
|
|
|
Q_PROPERTY(bool forceMetal READ forceMetal WRITE setForceMetal NOTIFY forceMetalChanged)
|
2023-06-28 20:42:40 -04:00
|
|
|
Q_PROPERTY(QString lastVersionStarted READ lastVersionStarted WRITE setLastVersionStarted NOTIFY lastVersionStartedChanged)
|
|
|
|
Q_PROPERTY(int localDocsChunkSize READ localDocsChunkSize WRITE setLocalDocsChunkSize NOTIFY localDocsChunkSizeChanged)
|
|
|
|
Q_PROPERTY(int localDocsRetrievalSize READ localDocsRetrievalSize WRITE setLocalDocsRetrievalSize NOTIFY localDocsRetrievalSizeChanged)
|
2023-07-05 19:41:07 -04:00
|
|
|
Q_PROPERTY(bool localDocsShowReferences READ localDocsShowReferences WRITE setLocalDocsShowReferences NOTIFY localDocsShowReferencesChanged)
|
2023-06-28 20:42:40 -04:00
|
|
|
Q_PROPERTY(QString networkAttribution READ networkAttribution WRITE setNetworkAttribution NOTIFY networkAttributionChanged)
|
|
|
|
Q_PROPERTY(bool networkIsActive READ networkIsActive WRITE setNetworkIsActive NOTIFY networkIsActiveChanged)
|
|
|
|
Q_PROPERTY(bool networkUsageStatsActive READ networkUsageStatsActive WRITE setNetworkUsageStatsActive NOTIFY networkUsageStatsActiveChanged)
|
2023-09-13 10:32:08 -04:00
|
|
|
Q_PROPERTY(QString device READ device WRITE setDevice NOTIFY deviceChanged)
|
|
|
|
Q_PROPERTY(QVector<QString> deviceList READ deviceList NOTIFY deviceListChanged)
|
2023-06-27 11:54:34 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
static MySettings *globalInstance();
|
|
|
|
|
2023-06-28 13:47:57 -04:00
|
|
|
// Restore methods
|
2023-07-01 11:34:21 -04:00
|
|
|
Q_INVOKABLE void restoreModelDefaults(const ModelInfo &model);
|
2023-06-28 13:47:57 -04:00
|
|
|
Q_INVOKABLE void restoreApplicationDefaults();
|
2023-06-28 20:42:40 -04:00
|
|
|
Q_INVOKABLE void restoreLocalDocsDefaults();
|
2023-06-28 13:47:57 -04:00
|
|
|
|
2023-07-01 11:34:21 -04:00
|
|
|
// Model/Character settings
|
|
|
|
void eraseModel(const ModelInfo &m);
|
|
|
|
QString modelName(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelName(const ModelInfo &m, const QString &name, bool force = false);
|
|
|
|
QString modelFilename(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelFilename(const ModelInfo &m, const QString &filename, bool force = false);
|
|
|
|
double modelTemperature(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelTemperature(const ModelInfo &m, double t, bool force = false);
|
|
|
|
double modelTopP(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelTopP(const ModelInfo &m, double p, bool force = false);
|
|
|
|
int modelTopK(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelTopK(const ModelInfo &m, int k, bool force = false);
|
|
|
|
int modelMaxLength(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelMaxLength(const ModelInfo &m, int l, bool force = false);
|
|
|
|
int modelPromptBatchSize(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelPromptBatchSize(const ModelInfo &m, int s, bool force = false);
|
|
|
|
double modelRepeatPenalty(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelRepeatPenalty(const ModelInfo &m, double p, bool force = false);
|
|
|
|
int modelRepeatPenaltyTokens(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelRepeatPenaltyTokens(const ModelInfo &m, int t, bool force = false);
|
|
|
|
QString modelPromptTemplate(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelPromptTemplate(const ModelInfo &m, const QString &t, bool force = false);
|
|
|
|
QString modelSystemPrompt(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelSystemPrompt(const ModelInfo &m, const QString &p, bool force = false);
|
2023-12-16 17:58:15 -05:00
|
|
|
int modelContextLength(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelContextLength(const ModelInfo &m, int s, bool force = false);
|
2024-01-31 14:17:44 -05:00
|
|
|
int modelGpuLayers(const ModelInfo &m) const;
|
|
|
|
Q_INVOKABLE void setModelGpuLayers(const ModelInfo &m, int s, bool force = false);
|
2023-06-28 13:47:57 -04:00
|
|
|
|
|
|
|
// Application settings
|
|
|
|
int threadCount() const;
|
|
|
|
void setThreadCount(int c);
|
2023-10-11 10:23:33 -04:00
|
|
|
bool saveChatsContext() const;
|
|
|
|
void setSaveChatsContext(bool b);
|
2023-06-28 13:47:57 -04:00
|
|
|
bool serverChat() const;
|
|
|
|
void setServerChat(bool b);
|
|
|
|
QString modelPath() const;
|
|
|
|
void setModelPath(const QString &p);
|
|
|
|
QString userDefaultModel() const;
|
|
|
|
void setUserDefaultModel(const QString &u);
|
2023-07-26 15:42:07 -04:00
|
|
|
QString chatTheme() const;
|
|
|
|
void setChatTheme(const QString &u);
|
2023-08-07 13:54:13 -04:00
|
|
|
QString fontSize() const;
|
|
|
|
void setFontSize(const QString &u);
|
2023-06-27 11:54:34 -04:00
|
|
|
bool forceMetal() const;
|
2023-06-28 13:47:57 -04:00
|
|
|
void setForceMetal(bool b);
|
2023-09-13 10:32:08 -04:00
|
|
|
QString device() const;
|
|
|
|
void setDevice(const QString &u);
|
2023-12-16 17:58:15 -05:00
|
|
|
int32_t contextLength() const;
|
|
|
|
void setContextLength(int32_t value);
|
2024-01-31 14:17:44 -05:00
|
|
|
int32_t gpuLayers() const;
|
|
|
|
void setGpuLayers(int32_t value);
|
2023-06-27 11:54:34 -04:00
|
|
|
|
2023-06-28 20:42:40 -04:00
|
|
|
// Release/Download settings
|
|
|
|
QString lastVersionStarted() const;
|
|
|
|
void setLastVersionStarted(const QString &v);
|
|
|
|
|
|
|
|
// Localdocs settings
|
|
|
|
int localDocsChunkSize() const;
|
|
|
|
void setLocalDocsChunkSize(int s);
|
|
|
|
int localDocsRetrievalSize() const;
|
|
|
|
void setLocalDocsRetrievalSize(int s);
|
2023-07-05 19:41:07 -04:00
|
|
|
bool localDocsShowReferences() const;
|
|
|
|
void setLocalDocsShowReferences(bool b);
|
2023-06-28 20:42:40 -04:00
|
|
|
|
|
|
|
// Network settings
|
|
|
|
QString networkAttribution() const;
|
|
|
|
void setNetworkAttribution(const QString &a);
|
|
|
|
bool networkIsActive() const;
|
|
|
|
void setNetworkIsActive(bool b);
|
|
|
|
bool networkUsageStatsActive() const;
|
|
|
|
void setNetworkUsageStatsActive(bool b);
|
|
|
|
|
2023-07-11 12:09:33 -04:00
|
|
|
QString attemptModelLoad() const;
|
|
|
|
void setAttemptModelLoad(const QString &modelFile);
|
|
|
|
|
2023-09-13 10:32:08 -04:00
|
|
|
QVector<QString> deviceList() const;
|
|
|
|
void setDeviceList(const QVector<QString> &deviceList);
|
|
|
|
|
2023-06-27 11:54:34 -04:00
|
|
|
Q_SIGNALS:
|
2023-07-01 11:34:21 -04:00
|
|
|
void nameChanged(const ModelInfo &model);
|
|
|
|
void filenameChanged(const ModelInfo &model);
|
|
|
|
void temperatureChanged(const ModelInfo &model);
|
|
|
|
void topPChanged(const ModelInfo &model);
|
|
|
|
void topKChanged(const ModelInfo &model);
|
|
|
|
void maxLengthChanged(const ModelInfo &model);
|
|
|
|
void promptBatchSizeChanged(const ModelInfo &model);
|
2023-12-16 17:58:15 -05:00
|
|
|
void contextLengthChanged(const ModelInfo &model);
|
2024-01-31 14:17:44 -05:00
|
|
|
void gpuLayersChanged(const ModelInfo &model);
|
2023-07-01 11:34:21 -04:00
|
|
|
void repeatPenaltyChanged(const ModelInfo &model);
|
|
|
|
void repeatPenaltyTokensChanged(const ModelInfo &model);
|
|
|
|
void promptTemplateChanged(const ModelInfo &model);
|
|
|
|
void systemPromptChanged(const ModelInfo &model);
|
2023-06-28 13:47:57 -04:00
|
|
|
void threadCountChanged();
|
2023-10-11 10:23:33 -04:00
|
|
|
void saveChatsContextChanged();
|
2023-06-28 13:47:57 -04:00
|
|
|
void serverChatChanged();
|
|
|
|
void modelPathChanged();
|
|
|
|
void userDefaultModelChanged();
|
2023-07-26 15:42:07 -04:00
|
|
|
void chatThemeChanged();
|
2023-08-07 13:54:13 -04:00
|
|
|
void fontSizeChanged();
|
2023-06-27 11:54:34 -04:00
|
|
|
void forceMetalChanged(bool);
|
2023-06-28 20:42:40 -04:00
|
|
|
void lastVersionStartedChanged();
|
|
|
|
void localDocsChunkSizeChanged();
|
|
|
|
void localDocsRetrievalSizeChanged();
|
2023-07-05 19:41:07 -04:00
|
|
|
void localDocsShowReferencesChanged();
|
2023-06-28 20:42:40 -04:00
|
|
|
void networkAttributionChanged();
|
|
|
|
void networkIsActiveChanged();
|
|
|
|
void networkUsageStatsActiveChanged();
|
2023-07-11 12:09:33 -04:00
|
|
|
void attemptModelLoadChanged();
|
2023-09-13 10:32:08 -04:00
|
|
|
void deviceChanged();
|
|
|
|
void deviceListChanged();
|
2023-06-27 11:54:34 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_forceMetal;
|
2023-09-13 10:32:08 -04:00
|
|
|
QVector<QString> m_deviceList;
|
2023-06-27 11:54:34 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
explicit MySettings();
|
|
|
|
~MySettings() {}
|
|
|
|
friend class MyPrivateSettings;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MYSETTINGS_H
|