2023-06-27 11:54:34 -04:00
|
|
|
#ifndef MYSETTINGS_H
|
|
|
|
#define MYSETTINGS_H
|
|
|
|
|
2024-06-06 11:59:28 -04:00
|
|
|
#include "modellist.h" // IWYU pragma: keep
|
2023-12-16 17:58:15 -05:00
|
|
|
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <QDateTime>
|
2023-06-27 11:54:34 -04:00
|
|
|
#include <QObject>
|
2024-06-24 18:49:23 -04:00
|
|
|
#include <QSettings>
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <QString>
|
2024-06-24 18:49:23 -04:00
|
|
|
#include <QStringList>
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <QVector>
|
2023-06-27 11:54:34 -04:00
|
|
|
|
2024-06-04 14:47:11 -04:00
|
|
|
#include <cstdint>
|
2024-06-24 18:49:23 -04:00
|
|
|
#include <optional>
|
2024-06-04 14:47:11 -04:00
|
|
|
|
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)
|
2024-06-24 18:49:23 -04:00
|
|
|
Q_PROPERTY(QStringList localDocsFileExtensions READ localDocsFileExtensions WRITE setLocalDocsFileExtensions NOTIFY localDocsFileExtensionsChanged)
|
|
|
|
Q_PROPERTY(bool localDocsUseRemoteEmbed READ localDocsUseRemoteEmbed WRITE setLocalDocsUseRemoteEmbed NOTIFY localDocsUseRemoteEmbedChanged)
|
|
|
|
Q_PROPERTY(QString localDocsNomicAPIKey READ localDocsNomicAPIKey WRITE setLocalDocsNomicAPIKey NOTIFY localDocsNomicAPIKeyChanged)
|
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-11-11 13:52:51 -05:00
|
|
|
Q_PROPERTY(int networkPort READ networkPort WRITE setNetworkPort NOTIFY networkPortChanged)
|
2023-06-27 11:54:34 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
static MySettings *globalInstance();
|
|
|
|
|
2023-06-28 13:47:57 -04:00
|
|
|
// Restore methods
|
2024-06-24 18:49:23 -04:00
|
|
|
Q_INVOKABLE void restoreModelDefaults(const ModelInfo &info);
|
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
|
2024-06-24 18:49:23 -04:00
|
|
|
void eraseModel(const ModelInfo &info);
|
|
|
|
QString modelName(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelName(const ModelInfo &info, const QString &name, bool force = false);
|
|
|
|
QString modelFilename(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelFilename(const ModelInfo &info, const QString &filename, bool force = false);
|
|
|
|
|
|
|
|
QString modelDescription(const ModelInfo &info) const;
|
|
|
|
void setModelDescription(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
QString modelUrl(const ModelInfo &info) const;
|
|
|
|
void setModelUrl(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
QString modelQuant(const ModelInfo &info) const;
|
|
|
|
void setModelQuant(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
QString modelType(const ModelInfo &info) const;
|
|
|
|
void setModelType(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
bool modelIsClone(const ModelInfo &info) const;
|
|
|
|
void setModelIsClone(const ModelInfo &info, bool value, bool force = false);
|
|
|
|
bool modelIsDiscovered(const ModelInfo &info) const;
|
|
|
|
void setModelIsDiscovered(const ModelInfo &info, bool value, bool force = false);
|
|
|
|
int modelLikes(const ModelInfo &info) const;
|
|
|
|
void setModelLikes(const ModelInfo &info, int value, bool force = false);
|
|
|
|
int modelDownloads(const ModelInfo &info) const;
|
|
|
|
void setModelDownloads(const ModelInfo &info, int value, bool force = false);
|
|
|
|
QDateTime modelRecency(const ModelInfo &info) const;
|
|
|
|
void setModelRecency(const ModelInfo &info, const QDateTime &value, bool force = false);
|
|
|
|
|
|
|
|
double modelTemperature(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelTemperature(const ModelInfo &info, double value, bool force = false);
|
|
|
|
double modelTopP(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelTopP(const ModelInfo &info, double value, bool force = false);
|
|
|
|
double modelMinP(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelMinP(const ModelInfo &info, double value, bool force = false);
|
|
|
|
int modelTopK(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelTopK(const ModelInfo &info, int value, bool force = false);
|
|
|
|
int modelMaxLength(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelMaxLength(const ModelInfo &info, int value, bool force = false);
|
|
|
|
int modelPromptBatchSize(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelPromptBatchSize(const ModelInfo &info, int value, bool force = false);
|
|
|
|
double modelRepeatPenalty(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelRepeatPenalty(const ModelInfo &info, double value, bool force = false);
|
|
|
|
int modelRepeatPenaltyTokens(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelRepeatPenaltyTokens(const ModelInfo &info, int value, bool force = false);
|
|
|
|
QString modelPromptTemplate(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelPromptTemplate(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
QString modelSystemPrompt(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelSystemPrompt(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
int modelContextLength(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelContextLength(const ModelInfo &info, int value, bool force = false);
|
|
|
|
int modelGpuLayers(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelGpuLayers(const ModelInfo &info, int value, bool force = false);
|
2023-06-28 13:47:57 -04:00
|
|
|
|
|
|
|
// Application settings
|
|
|
|
int threadCount() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setThreadCount(int value);
|
2023-10-11 10:23:33 -04:00
|
|
|
bool saveChatsContext() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setSaveChatsContext(bool value);
|
2023-06-28 13:47:57 -04:00
|
|
|
bool serverChat() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setServerChat(bool value);
|
|
|
|
QString modelPath();
|
|
|
|
void setModelPath(const QString &value);
|
2023-06-28 13:47:57 -04:00
|
|
|
QString userDefaultModel() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setUserDefaultModel(const QString &value);
|
2023-07-26 15:42:07 -04:00
|
|
|
QString chatTheme() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setChatTheme(const QString &value);
|
2023-08-07 13:54:13 -04:00
|
|
|
QString fontSize() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setFontSize(const QString &value);
|
2023-06-27 11:54:34 -04:00
|
|
|
bool forceMetal() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setForceMetal(bool value);
|
|
|
|
QString device();
|
|
|
|
void setDevice(const QString &value);
|
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;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setLastVersionStarted(const QString &value);
|
2023-06-28 20:42:40 -04:00
|
|
|
|
|
|
|
// Localdocs settings
|
|
|
|
int localDocsChunkSize() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setLocalDocsChunkSize(int value);
|
2023-06-28 20:42:40 -04:00
|
|
|
int localDocsRetrievalSize() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setLocalDocsRetrievalSize(int value);
|
2023-07-05 19:41:07 -04:00
|
|
|
bool localDocsShowReferences() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setLocalDocsShowReferences(bool value);
|
|
|
|
QStringList localDocsFileExtensions() const;
|
|
|
|
void setLocalDocsFileExtensions(const QStringList &value);
|
|
|
|
bool localDocsUseRemoteEmbed() const;
|
|
|
|
void setLocalDocsUseRemoteEmbed(bool value);
|
|
|
|
QString localDocsNomicAPIKey() const;
|
|
|
|
void setLocalDocsNomicAPIKey(const QString &value);
|
2023-06-28 20:42:40 -04:00
|
|
|
|
|
|
|
// Network settings
|
|
|
|
QString networkAttribution() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setNetworkAttribution(const QString &value);
|
2023-06-28 20:42:40 -04:00
|
|
|
bool networkIsActive() const;
|
2024-04-25 13:16:52 -04:00
|
|
|
Q_INVOKABLE bool isNetworkIsActiveSet() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setNetworkIsActive(bool value);
|
2023-06-28 20:42:40 -04:00
|
|
|
bool networkUsageStatsActive() const;
|
2024-04-25 13:16:52 -04:00
|
|
|
Q_INVOKABLE bool isNetworkUsageStatsActiveSet() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setNetworkUsageStatsActive(bool value);
|
2023-11-11 13:52:51 -05:00
|
|
|
int networkPort() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setNetworkPort(int value);
|
2023-06-28 20:42:40 -04:00
|
|
|
|
2023-09-13 10:32:08 -04:00
|
|
|
QVector<QString> deviceList() const;
|
2024-06-24 18:49:23 -04:00
|
|
|
void setDeviceList(const QVector<QString> &value);
|
2023-09-13 10:32:08 -04:00
|
|
|
|
2023-06-27 11:54:34 -04:00
|
|
|
Q_SIGNALS:
|
2024-06-24 18:49:23 -04:00
|
|
|
void nameChanged(const ModelInfo &info);
|
|
|
|
void filenameChanged(const ModelInfo &info);
|
|
|
|
void descriptionChanged(const ModelInfo &info);
|
|
|
|
void temperatureChanged(const ModelInfo &info);
|
|
|
|
void topPChanged(const ModelInfo &info);
|
|
|
|
void minPChanged(const ModelInfo &info);
|
|
|
|
void topKChanged(const ModelInfo &info);
|
|
|
|
void maxLengthChanged(const ModelInfo &info);
|
|
|
|
void promptBatchSizeChanged(const ModelInfo &info);
|
|
|
|
void contextLengthChanged(const ModelInfo &info);
|
|
|
|
void gpuLayersChanged(const ModelInfo &info);
|
|
|
|
void repeatPenaltyChanged(const ModelInfo &info);
|
|
|
|
void repeatPenaltyTokensChanged(const ModelInfo &info);
|
|
|
|
void promptTemplateChanged(const ModelInfo &info);
|
|
|
|
void systemPromptChanged(const ModelInfo &info);
|
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();
|
2024-06-24 18:49:23 -04:00
|
|
|
void localDocsFileExtensionsChanged();
|
|
|
|
void localDocsUseRemoteEmbedChanged();
|
|
|
|
void localDocsNomicAPIKeyChanged();
|
2023-06-28 20:42:40 -04:00
|
|
|
void networkAttributionChanged();
|
|
|
|
void networkIsActiveChanged();
|
2023-11-11 13:52:51 -05:00
|
|
|
void networkPortChanged();
|
2023-06-28 20:42:40 -04:00
|
|
|
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:
|
2024-06-24 18:49:23 -04:00
|
|
|
QSettings m_settings;
|
2023-06-27 11:54:34 -04:00
|
|
|
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;
|
2024-06-24 18:49:23 -04:00
|
|
|
|
|
|
|
QVariant getBasicSetting(const QString &name) const;
|
|
|
|
void setBasicSetting(const QString &name, const QVariant &value, std::optional<QString> signal = std::nullopt);
|
|
|
|
QVariant getModelSetting(const QString &name, const ModelInfo &info) const;
|
|
|
|
void setModelSetting(const QString &name, const ModelInfo &info, const QVariant &value, bool force,
|
|
|
|
bool signal = false);
|
2023-06-27 11:54:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MYSETTINGS_H
|