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
|
|
|
|
2024-07-10 15:45:20 -04:00
|
|
|
namespace MySettingsEnums {
|
|
|
|
Q_NAMESPACE
|
|
|
|
|
2024-07-16 16:12:44 -04:00
|
|
|
/* NOTE: values of these enums are used as indices for the corresponding combo boxes in
|
|
|
|
* ApplicationSettings.qml, as well as the corresponding name lists in mysettings.cpp */
|
|
|
|
|
2024-07-10 15:45:20 -04:00
|
|
|
enum class SuggestionMode {
|
|
|
|
LocalDocsOnly = 0,
|
2024-07-16 16:12:44 -04:00
|
|
|
On = 1,
|
|
|
|
Off = 2,
|
2024-07-10 15:45:20 -04:00
|
|
|
};
|
|
|
|
Q_ENUM_NS(SuggestionMode)
|
2024-07-16 16:12:44 -04:00
|
|
|
|
|
|
|
enum class ChatTheme {
|
|
|
|
Light = 0,
|
|
|
|
Dark = 1,
|
|
|
|
LegacyDark = 2,
|
|
|
|
};
|
|
|
|
Q_ENUM_NS(ChatTheme)
|
|
|
|
|
|
|
|
enum class FontSize {
|
|
|
|
Small = 0,
|
|
|
|
Medium = 1,
|
|
|
|
Large = 2,
|
|
|
|
};
|
|
|
|
Q_ENUM_NS(FontSize)
|
2024-07-10 15:45:20 -04:00
|
|
|
}
|
|
|
|
using namespace MySettingsEnums;
|
|
|
|
|
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)
|
2024-07-16 16:12:44 -04:00
|
|
|
Q_PROPERTY(ChatTheme chatTheme READ chatTheme WRITE setChatTheme NOTIFY chatThemeChanged)
|
|
|
|
Q_PROPERTY(FontSize fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
2024-07-12 16:14:58 -04:00
|
|
|
Q_PROPERTY(QString languageAndLocale READ languageAndLocale WRITE setLanguageAndLocale NOTIFY languageAndLocaleChanged)
|
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)
|
2024-06-28 12:57:57 -04:00
|
|
|
Q_PROPERTY(QString localDocsEmbedDevice READ localDocsEmbedDevice WRITE setLocalDocsEmbedDevice NOTIFY localDocsEmbedDeviceChanged)
|
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)
|
2024-06-28 12:57:57 -04:00
|
|
|
Q_PROPERTY(QStringList deviceList MEMBER m_deviceList CONSTANT)
|
|
|
|
Q_PROPERTY(QStringList embeddingsDeviceList MEMBER m_embeddingsDeviceList CONSTANT)
|
2023-11-11 13:52:51 -05:00
|
|
|
Q_PROPERTY(int networkPort READ networkPort WRITE setNetworkPort NOTIFY networkPortChanged)
|
2024-07-10 15:45:20 -04:00
|
|
|
Q_PROPERTY(SuggestionMode suggestionMode READ suggestionMode WRITE setSuggestionMode NOTIFY suggestionModeChanged)
|
2024-07-12 16:14:58 -04:00
|
|
|
Q_PROPERTY(QStringList uiLanguages MEMBER m_uiLanguages CONSTANT)
|
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);
|
2024-07-10 15:45:20 -04:00
|
|
|
QString modelChatNamePrompt(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelChatNamePrompt(const ModelInfo &info, const QString &value, bool force = false);
|
|
|
|
QString modelSuggestedFollowUpPrompt(const ModelInfo &info) const;
|
|
|
|
Q_INVOKABLE void setModelSuggestedFollowUpPrompt(const ModelInfo &info, const QString &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);
|
2024-07-16 16:12:44 -04:00
|
|
|
ChatTheme chatTheme() const;
|
|
|
|
void setChatTheme(ChatTheme value);
|
|
|
|
FontSize fontSize() const;
|
|
|
|
void setFontSize(FontSize 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);
|
2024-07-10 15:45:20 -04:00
|
|
|
SuggestionMode suggestionMode() const;
|
2024-07-16 16:12:44 -04:00
|
|
|
void setSuggestionMode(SuggestionMode value);
|
2023-06-27 11:54:34 -04:00
|
|
|
|
2024-07-12 16:14:58 -04:00
|
|
|
QString languageAndLocale() const;
|
|
|
|
void setLanguageAndLocale(const QString &bcp47Name = QString()); // called on startup with QString()
|
|
|
|
|
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);
|
2024-06-28 12:57:57 -04:00
|
|
|
QString localDocsEmbedDevice() const;
|
|
|
|
void setLocalDocsEmbedDevice(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-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);
|
2024-07-10 15:45:20 -04:00
|
|
|
void chatNamePromptChanged(const ModelInfo &info);
|
|
|
|
void suggestedFollowUpPromptChanged(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();
|
2024-06-28 12:57:57 -04:00
|
|
|
void localDocsEmbedDeviceChanged();
|
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();
|
2024-07-10 15:45:20 -04:00
|
|
|
void suggestionModeChanged();
|
2024-07-12 16:14:58 -04:00
|
|
|
void languageAndLocaleChanged();
|
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;
|
2024-06-28 12:57:57 -04:00
|
|
|
const QStringList m_deviceList;
|
|
|
|
const QStringList m_embeddingsDeviceList;
|
2024-07-12 16:14:58 -04:00
|
|
|
const QStringList m_uiLanguages;
|
|
|
|
QTranslator *m_translator = nullptr;
|
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);
|
2024-07-16 16:12:44 -04:00
|
|
|
int getEnumSetting(const QString &setting, const QStringList &valueNames) const;
|
2024-06-24 18:49:23 -04:00
|
|
|
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);
|
2024-07-12 16:14:58 -04:00
|
|
|
QString filePathForLocale(const QLocale &locale);
|
2023-06-27 11:54:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MYSETTINGS_H
|