mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
This completes the work of consolidating all settings that can be changed by the user on new settings object.
This commit is contained in:
parent
8d19ef3909
commit
7f252b4970
@ -6,13 +6,6 @@
|
||||
#include "mysettings.h"
|
||||
#include "../gpt4all-backend/llmodel.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QResource>
|
||||
#include <QSettings>
|
||||
|
||||
//#define DEBUG
|
||||
//#define DEBUG_MODEL_LOADING
|
||||
|
||||
@ -427,7 +420,7 @@ bool ChatLLM::prompt(const QList<QString> &collectionList, const QString &prompt
|
||||
return false;
|
||||
|
||||
QList<ResultInfo> databaseResults;
|
||||
const int retrievalSize = LocalDocs::globalInstance()->retrievalSize();
|
||||
const int retrievalSize = MySettings::globalInstance()->localDocsRetrievalSize();
|
||||
emit requestRetrieveFromDB(collectionList, prompt, retrievalSize, &databaseResults); // blocks
|
||||
emit databaseResultsChanged(databaseResults);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "llm.h"
|
||||
#include "../gpt4all-backend/sysinfo.h"
|
||||
#include "chatlistmodel.h"
|
||||
#include "../gpt4all-backend/llmodel.h"
|
||||
#include "network.h"
|
||||
|
||||
@ -9,7 +8,6 @@
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QResource>
|
||||
#include <QSettings>
|
||||
#include <fstream>
|
||||
|
||||
class MyLLM: public LLM { };
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "localdocs.h"
|
||||
#include "mysettings.h"
|
||||
|
||||
class MyLocalDocs: public LocalDocs { };
|
||||
Q_GLOBAL_STATIC(MyLocalDocs, localDocsInstance)
|
||||
@ -12,13 +13,10 @@ LocalDocs::LocalDocs()
|
||||
, m_localDocsModel(new LocalDocsModel(this))
|
||||
, m_database(nullptr)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
m_chunkSize = settings.value("localdocs/chunkSize", 256).toInt();
|
||||
m_retrievalSize = settings.value("localdocs/retrievalSize", 3).toInt();
|
||||
connect(MySettings::globalInstance(), &MySettings::localDocsChunkSizeChanged, this, &LocalDocs::handleChunkSizeChanged);
|
||||
|
||||
// Create the DB with the chunk size from settings
|
||||
m_database = new Database(m_chunkSize);
|
||||
m_database = new Database(MySettings::globalInstance()->localDocsChunkSize());
|
||||
|
||||
connect(this, &LocalDocs::requestAddFolder, m_database,
|
||||
&Database::addFolder, Qt::QueuedConnection);
|
||||
@ -47,31 +45,7 @@ void LocalDocs::removeFolder(const QString &collection, const QString &path)
|
||||
emit requestRemoveFolder(collection, path);
|
||||
}
|
||||
|
||||
int LocalDocs::chunkSize() const
|
||||
void LocalDocs::handleChunkSizeChanged()
|
||||
{
|
||||
return m_chunkSize;
|
||||
}
|
||||
|
||||
void LocalDocs::setChunkSize(int chunkSize)
|
||||
{
|
||||
if (m_chunkSize == chunkSize)
|
||||
return;
|
||||
|
||||
m_chunkSize = chunkSize;
|
||||
emit chunkSizeChanged();
|
||||
emit requestChunkSizeChange(chunkSize);
|
||||
}
|
||||
|
||||
int LocalDocs::retrievalSize() const
|
||||
{
|
||||
return m_retrievalSize;
|
||||
}
|
||||
|
||||
void LocalDocs::setRetrievalSize(int retrievalSize)
|
||||
{
|
||||
if (m_retrievalSize == retrievalSize)
|
||||
return;
|
||||
|
||||
m_retrievalSize = retrievalSize;
|
||||
emit retrievalSizeChanged();
|
||||
emit requestChunkSizeChange(MySettings::globalInstance()->localDocsChunkSize());
|
||||
}
|
||||
|
@ -10,8 +10,6 @@ class LocalDocs : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LocalDocsModel *localDocsModel READ localDocsModel NOTIFY localDocsModelChanged)
|
||||
Q_PROPERTY(int chunkSize READ chunkSize WRITE setChunkSize NOTIFY chunkSizeChanged)
|
||||
Q_PROPERTY(int retrievalSize READ retrievalSize WRITE setRetrievalSize NOTIFY retrievalSizeChanged)
|
||||
|
||||
public:
|
||||
static LocalDocs *globalInstance();
|
||||
@ -23,23 +21,16 @@ public:
|
||||
|
||||
Database *database() const { return m_database; }
|
||||
|
||||
int chunkSize() const;
|
||||
void setChunkSize(int chunkSize);
|
||||
|
||||
int retrievalSize() const;
|
||||
void setRetrievalSize(int retrievalSize);
|
||||
public Q_SLOTS:
|
||||
void handleChunkSizeChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void requestAddFolder(const QString &collection, const QString &path);
|
||||
void requestRemoveFolder(const QString &collection, const QString &path);
|
||||
void requestChunkSizeChange(int chunkSize);
|
||||
void localDocsModelChanged();
|
||||
void chunkSizeChanged();
|
||||
void retrievalSizeChanged();
|
||||
|
||||
private:
|
||||
int m_chunkSize;
|
||||
int m_retrievalSize;
|
||||
LocalDocsModel *m_localDocsModel;
|
||||
Database *m_database;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QSettings>
|
||||
|
||||
#include "llm.h"
|
||||
#include "modellist.h"
|
||||
|
@ -78,7 +78,7 @@ Window {
|
||||
Connections {
|
||||
target: currentChat
|
||||
function onResponseInProgressChanged() {
|
||||
if (Network.isActive && !currentChat.responseInProgress)
|
||||
if (MySettings.networkIsActive && !currentChat.responseInProgress)
|
||||
Network.sendConversation(currentChat.id, getConversationJson());
|
||||
}
|
||||
function onModelLoadingErrorChanged() {
|
||||
@ -365,14 +365,14 @@ Window {
|
||||
height: 40
|
||||
z: 200
|
||||
padding: 15
|
||||
toggled: Network.isActive
|
||||
toggled: MySettings.networkIsActive
|
||||
source: "qrc:/gpt4all/icons/network.svg"
|
||||
Accessible.name: qsTr("Network button")
|
||||
Accessible.description: qsTr("Reveals a dialogue where you can opt-in for sharing data over network")
|
||||
|
||||
onClicked: {
|
||||
if (Network.isActive) {
|
||||
Network.isActive = false
|
||||
if (MySettings.networkIsActive) {
|
||||
MySettings.networkIsActive = false
|
||||
Network.sendNetworkToggled(false);
|
||||
} else
|
||||
networkDialog.open()
|
||||
@ -769,7 +769,7 @@ Window {
|
||||
|
||||
Column {
|
||||
visible: name === qsTr("Response: ") &&
|
||||
(!currentResponse || !currentChat.responseInProgress) && Network.isActive
|
||||
(!currentResponse || !currentChat.responseInProgress) && MySettings.networkIsActive
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 20
|
||||
y: parent.topPadding + (parent.positionToRectangle(0).height / 2) - (height / 2)
|
||||
|
@ -92,8 +92,6 @@ ModelList::ModelList()
|
||||
m_installedModels->setSourceModel(this);
|
||||
m_downloadableModels->setSourceModel(this);
|
||||
m_watcher = new QFileSystemWatcher(this);
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
const QString exePath = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||
m_watcher->addPath(exePath);
|
||||
m_watcher->addPath(MySettings::globalInstance()->modelPath());
|
||||
@ -122,10 +120,7 @@ const QList<QString> ModelList::userDefaultModelList() const
|
||||
{
|
||||
QMutexLocker locker(&m_mutex);
|
||||
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
|
||||
const QString userDefaultModelName = settings.value("userDefaultModel").toString();
|
||||
const QString userDefaultModelName = MySettings::globalInstance()->userDefaultModel();
|
||||
QList<QString> models;
|
||||
bool foundUserDefault = false;
|
||||
for (ModelInfo *info : m_models) {
|
||||
@ -155,7 +150,7 @@ ModelInfo ModelList::defaultModelInfo() const
|
||||
// The user default model can be set by the user in the settings dialog. The "default" user
|
||||
// default model is "Application default" which signals we should use the default model that was
|
||||
// specified by the models.json file.
|
||||
const QString userDefaultModelName = settings.value("userDefaultModel").toString();
|
||||
const QString userDefaultModelName = MySettings::globalInstance()->userDefaultModel();
|
||||
const bool hasUserDefaultName = !userDefaultModelName.isEmpty() && userDefaultModelName != "Application default";
|
||||
const QString defaultModelName = settings.value("defaultModel").toString();
|
||||
const bool hasDefaultName = hasUserDefaultName ? false : !defaultModelName.isEmpty();
|
||||
@ -634,7 +629,6 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData)
|
||||
const QString firstModel =
|
||||
installedModels()->firstFilename();
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
settings.setValue("defaultModel", firstModel);
|
||||
settings.sync();
|
||||
}
|
||||
|
@ -21,6 +21,12 @@ static bool default_saveChatGPTChats = true;
|
||||
static bool default_serverChat = false;
|
||||
static QString default_userDefaultModel = "Application default";
|
||||
static bool default_forceMetal = false;
|
||||
static QString default_lastVersionStarted = "";
|
||||
static int default_localDocsChunkSize = 256;
|
||||
static int default_localDocsRetrievalSize = 3;
|
||||
static QString default_networkAttribution = "";
|
||||
static bool default_networkIsActive = false;
|
||||
static bool default_networkUsageStatsActive = false;
|
||||
|
||||
static QString defaultLocalModelsPath()
|
||||
{
|
||||
@ -85,6 +91,12 @@ void MySettings::restoreApplicationDefaults()
|
||||
setForceMetal(default_forceMetal);
|
||||
}
|
||||
|
||||
void MySettings::restoreLocalDocsDefaults()
|
||||
{
|
||||
setLocalDocsChunkSize(default_localDocsChunkSize);
|
||||
setLocalDocsRetrievalSize(default_localDocsRetrievalSize);
|
||||
}
|
||||
|
||||
double MySettings::temperature() const
|
||||
{
|
||||
QSettings setting;
|
||||
@ -351,3 +363,111 @@ void MySettings::setForceMetal(bool b)
|
||||
m_forceMetal = b;
|
||||
emit forceMetalChanged(b);
|
||||
}
|
||||
|
||||
QString MySettings::lastVersionStarted() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("lastVersionStarted", default_lastVersionStarted).toString();
|
||||
}
|
||||
|
||||
void MySettings::setLastVersionStarted(const QString &v)
|
||||
{
|
||||
if (lastVersionStarted() == v)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("lastVersionStarted", v);
|
||||
setting.sync();
|
||||
emit lastVersionStartedChanged();
|
||||
}
|
||||
|
||||
int MySettings::localDocsChunkSize() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("localdocs/chunkSize", default_localDocsChunkSize).toInt();
|
||||
}
|
||||
|
||||
void MySettings::setLocalDocsChunkSize(int s)
|
||||
{
|
||||
if (localDocsChunkSize() == s)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("localdocs/chunkSize", s);
|
||||
setting.sync();
|
||||
emit localDocsChunkSizeChanged();
|
||||
}
|
||||
|
||||
int MySettings::localDocsRetrievalSize() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("localdocs/retrievalSize", default_localDocsRetrievalSize).toInt();
|
||||
}
|
||||
|
||||
void MySettings::setLocalDocsRetrievalSize(int s)
|
||||
{
|
||||
if (localDocsRetrievalSize() == s)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("localdocs/retrievalSize", s);
|
||||
setting.sync();
|
||||
emit localDocsRetrievalSizeChanged();
|
||||
}
|
||||
|
||||
QString MySettings::networkAttribution() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("network/attribution", default_networkAttribution).toString();
|
||||
}
|
||||
|
||||
void MySettings::setNetworkAttribution(const QString &a)
|
||||
{
|
||||
if (networkAttribution() == a)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("network/attribution", a);
|
||||
setting.sync();
|
||||
emit networkAttributionChanged();
|
||||
}
|
||||
|
||||
bool MySettings::networkIsActive() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("network/isActive", default_networkIsActive).toBool();
|
||||
}
|
||||
|
||||
void MySettings::setNetworkIsActive(bool b)
|
||||
{
|
||||
if (networkIsActive() == b)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("network/isActive", b);
|
||||
setting.sync();
|
||||
emit networkIsActiveChanged();
|
||||
}
|
||||
|
||||
bool MySettings::networkUsageStatsActive() const
|
||||
{
|
||||
QSettings setting;
|
||||
setting.sync();
|
||||
return setting.value("network/usageStatsActive", default_networkUsageStatsActive).toBool();
|
||||
}
|
||||
|
||||
void MySettings::setNetworkUsageStatsActive(bool b)
|
||||
{
|
||||
if (networkUsageStatsActive() == b)
|
||||
return;
|
||||
|
||||
QSettings setting;
|
||||
setting.setValue("network/usageStatsActive", b);
|
||||
setting.sync();
|
||||
emit networkUsageStatsActiveChanged();
|
||||
}
|
||||
|
@ -22,6 +22,12 @@ class MySettings : public QObject
|
||||
Q_PROPERTY(QString modelPath READ modelPath WRITE setModelPath NOTIFY modelPathChanged)
|
||||
Q_PROPERTY(QString userDefaultModel READ userDefaultModel WRITE setUserDefaultModel NOTIFY userDefaultModelChanged)
|
||||
Q_PROPERTY(bool forceMetal READ forceMetal WRITE setForceMetal NOTIFY forceMetalChanged)
|
||||
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)
|
||||
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)
|
||||
|
||||
public:
|
||||
static MySettings *globalInstance();
|
||||
@ -29,6 +35,7 @@ public:
|
||||
// Restore methods
|
||||
Q_INVOKABLE void restoreGenerationDefaults();
|
||||
Q_INVOKABLE void restoreApplicationDefaults();
|
||||
Q_INVOKABLE void restoreLocalDocsDefaults();
|
||||
|
||||
// Generation settings
|
||||
double temperature() const;
|
||||
@ -64,6 +71,24 @@ public:
|
||||
bool forceMetal() const;
|
||||
void setForceMetal(bool b);
|
||||
|
||||
// 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);
|
||||
|
||||
// Network settings
|
||||
QString networkAttribution() const;
|
||||
void setNetworkAttribution(const QString &a);
|
||||
bool networkIsActive() const;
|
||||
void setNetworkIsActive(bool b);
|
||||
bool networkUsageStatsActive() const;
|
||||
void setNetworkUsageStatsActive(bool b);
|
||||
|
||||
Q_SIGNALS:
|
||||
void temperatureChanged();
|
||||
void topPChanged();
|
||||
@ -80,6 +105,12 @@ Q_SIGNALS:
|
||||
void modelPathChanged();
|
||||
void userDefaultModelChanged();
|
||||
void forceMetalChanged(bool);
|
||||
void lastVersionStartedChanged();
|
||||
void localDocsChunkSizeChanged();
|
||||
void localDocsRetrievalSizeChanged();
|
||||
void networkAttributionChanged();
|
||||
void networkIsActiveChanged();
|
||||
void networkUsageStatsActiveChanged();
|
||||
|
||||
private:
|
||||
bool m_forceMetal;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "network.h"
|
||||
#include "llm.h"
|
||||
#include "chatlistmodel.h"
|
||||
#include "mysettings.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QGuiApplication>
|
||||
@ -8,7 +9,6 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QSettings>
|
||||
#include <QNetworkRequest>
|
||||
#include <QScreen>
|
||||
|
||||
@ -33,8 +33,6 @@ Network *Network::globalInstance()
|
||||
|
||||
Network::Network()
|
||||
: QObject{nullptr}
|
||||
, m_isActive(false)
|
||||
, m_usageStatsActive(false)
|
||||
, m_shouldSendStartup(false)
|
||||
{
|
||||
QSettings settings;
|
||||
@ -42,35 +40,25 @@ Network::Network()
|
||||
m_uniqueId = settings.value("uniqueId", generateUniqueId()).toString();
|
||||
settings.setValue("uniqueId", m_uniqueId);
|
||||
settings.sync();
|
||||
m_isActive = settings.value("network/isActive", false).toBool();
|
||||
if (m_isActive)
|
||||
connect(MySettings::globalInstance(), &MySettings::networkIsActiveChanged, this, &Network::handleIsActiveChanged);
|
||||
connect(MySettings::globalInstance(), &MySettings::networkUsageStatsActiveChanged, this, &Network::handleUsageStatsActiveChanged);
|
||||
if (MySettings::globalInstance()->networkIsActive())
|
||||
sendHealth();
|
||||
m_usageStatsActive = settings.value("network/usageStatsActive", false).toBool();
|
||||
if (m_usageStatsActive)
|
||||
if (MySettings::globalInstance()->networkUsageStatsActive())
|
||||
sendIpify();
|
||||
connect(&m_networkManager, &QNetworkAccessManager::sslErrors, this,
|
||||
&Network::handleSslErrors);
|
||||
}
|
||||
|
||||
void Network::setActive(bool b)
|
||||
void Network::handleIsActiveChanged()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("network/isActive", b);
|
||||
settings.sync();
|
||||
m_isActive = b;
|
||||
emit activeChanged();
|
||||
if (m_isActive)
|
||||
if (MySettings::globalInstance()->networkUsageStatsActive())
|
||||
sendHealth();
|
||||
}
|
||||
|
||||
void Network::setUsageStatsActive(bool b)
|
||||
void Network::handleUsageStatsActiveChanged()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("network/usageStatsActive", b);
|
||||
settings.sync();
|
||||
m_usageStatsActive = b;
|
||||
emit usageStatsActiveChanged();
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
sendOptOut();
|
||||
else {
|
||||
// model might be loaded already when user opt-in for first time
|
||||
@ -86,7 +74,7 @@ QString Network::generateUniqueId() const
|
||||
|
||||
bool Network::packageAndSendJson(const QString &ingestId, const QString &json)
|
||||
{
|
||||
if (!m_isActive)
|
||||
if (!MySettings::globalInstance()->networkIsActive())
|
||||
return false;
|
||||
|
||||
QJsonParseError err;
|
||||
@ -104,13 +92,11 @@ bool Network::packageAndSendJson(const QString &ingestId, const QString &json)
|
||||
object.insert("submitter_id", m_uniqueId);
|
||||
object.insert("ingest_id", ingestId);
|
||||
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
QString attribution = settings.value("network/attribution", QString()).toString();
|
||||
QString attribution = MySettings::globalInstance()->networkAttribution();
|
||||
if (!attribution.isEmpty())
|
||||
object.insert("network/attribution", attribution);
|
||||
|
||||
QString promptTemplate = settings.value("promptTemplate", QString()).toString();
|
||||
QString promptTemplate = MySettings::globalInstance()->promptTemplate();
|
||||
object.insert("prompt_template", promptTemplate);
|
||||
|
||||
QJsonDocument newDoc;
|
||||
@ -204,14 +190,14 @@ void Network::sendOptOut()
|
||||
|
||||
void Network::sendModelLoaded()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("model_load");
|
||||
}
|
||||
|
||||
void Network::sendResetContext(int conversationLength)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
|
||||
KeyValue kv;
|
||||
@ -222,7 +208,7 @@ void Network::sendResetContext(int conversationLength)
|
||||
|
||||
void Network::sendStartup()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
m_shouldSendStartup = true;
|
||||
if (m_ipify.isEmpty())
|
||||
@ -232,21 +218,21 @@ void Network::sendStartup()
|
||||
|
||||
void Network::sendCheckForUpdates()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("check_for_updates");
|
||||
}
|
||||
|
||||
void Network::sendModelDownloaderDialog()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("download_dialog");
|
||||
}
|
||||
|
||||
void Network::sendInstallModel(const QString &model)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -256,7 +242,7 @@ void Network::sendInstallModel(const QString &model)
|
||||
|
||||
void Network::sendRemoveModel(const QString &model)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -266,7 +252,7 @@ void Network::sendRemoveModel(const QString &model)
|
||||
|
||||
void Network::sendDownloadStarted(const QString &model)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -276,7 +262,7 @@ void Network::sendDownloadStarted(const QString &model)
|
||||
|
||||
void Network::sendDownloadCanceled(const QString &model)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -286,7 +272,7 @@ void Network::sendDownloadCanceled(const QString &model)
|
||||
|
||||
void Network::sendDownloadError(const QString &model, int code, const QString &errorString)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -302,7 +288,7 @@ void Network::sendDownloadError(const QString &model, int code, const QString &e
|
||||
|
||||
void Network::sendDownloadFinished(const QString &model, bool success)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("model");
|
||||
@ -315,14 +301,14 @@ void Network::sendDownloadFinished(const QString &model, bool success)
|
||||
|
||||
void Network::sendSettingsDialog()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("settings_dialog");
|
||||
}
|
||||
|
||||
void Network::sendNetworkToggled(bool isActive)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("isActive");
|
||||
@ -332,7 +318,7 @@ void Network::sendNetworkToggled(bool isActive)
|
||||
|
||||
void Network::sendSaveChatsToggled(bool isActive)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("isActive");
|
||||
@ -342,7 +328,7 @@ void Network::sendSaveChatsToggled(bool isActive)
|
||||
|
||||
void Network::sendNewChat(int count)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
KeyValue kv;
|
||||
kv.key = QString("number_of_chats");
|
||||
@ -352,28 +338,28 @@ void Network::sendNewChat(int count)
|
||||
|
||||
void Network::sendRemoveChat()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("remove_chat");
|
||||
}
|
||||
|
||||
void Network::sendRenameChat()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("rename_chat");
|
||||
}
|
||||
|
||||
void Network::sendChatStarted()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("chat_started");
|
||||
}
|
||||
|
||||
void Network::sendRecalculatingContext(int conversationLength)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
|
||||
KeyValue kv;
|
||||
@ -384,14 +370,14 @@ void Network::sendRecalculatingContext(int conversationLength)
|
||||
|
||||
void Network::sendNonCompatHardware()
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
sendMixpanelEvent("noncompat_hardware");
|
||||
}
|
||||
|
||||
void Network::sendMixpanelEvent(const QString &ev, const QVector<KeyValue> &values)
|
||||
{
|
||||
if (!m_usageStatsActive)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive())
|
||||
return;
|
||||
|
||||
Q_ASSERT(ChatListModel::globalInstance()->currentChat());
|
||||
@ -439,7 +425,7 @@ void Network::sendMixpanelEvent(const QString &ev, const QVector<KeyValue> &valu
|
||||
|
||||
void Network::sendIpify()
|
||||
{
|
||||
if (!m_usageStatsActive || !m_ipify.isEmpty())
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive() || !m_ipify.isEmpty())
|
||||
return;
|
||||
|
||||
QUrl ipifyUrl("https://api.ipify.org");
|
||||
@ -453,7 +439,7 @@ void Network::sendIpify()
|
||||
|
||||
void Network::sendMixpanel(const QByteArray &json, bool isOptOut)
|
||||
{
|
||||
if (!m_usageStatsActive && !isOptOut)
|
||||
if (!MySettings::globalInstance()->networkUsageStatsActive() && !isOptOut)
|
||||
return;
|
||||
|
||||
QUrl trackUrl("https://api.mixpanel.com/track");
|
||||
@ -468,7 +454,7 @@ void Network::sendMixpanel(const QByteArray &json, bool isOptOut)
|
||||
|
||||
void Network::handleIpifyFinished()
|
||||
{
|
||||
Q_ASSERT(m_usageStatsActive);
|
||||
Q_ASSERT(MySettings::globalInstance()->networkUsageStatsActive());
|
||||
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
|
||||
if (!reply)
|
||||
return;
|
||||
@ -544,7 +530,7 @@ void Network::handleHealthFinished()
|
||||
if (code != 200) {
|
||||
qWarning() << "ERROR: health response != 200 code:" << code;
|
||||
emit healthCheckFailed(code);
|
||||
setActive(false);
|
||||
MySettings::globalInstance()->setNetworkIsActive(false);
|
||||
}
|
||||
healthReply->deleteLater();
|
||||
}
|
||||
|
@ -14,24 +14,13 @@ struct KeyValue {
|
||||
class Network : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY activeChanged)
|
||||
Q_PROPERTY(bool usageStatsActive READ usageStatsActive WRITE setUsageStatsActive NOTIFY usageStatsActiveChanged)
|
||||
|
||||
public:
|
||||
static Network *globalInstance();
|
||||
|
||||
bool isActive() const { return m_isActive; }
|
||||
void setActive(bool b);
|
||||
|
||||
bool usageStatsActive() const { return m_usageStatsActive; }
|
||||
void setUsageStatsActive(bool b);
|
||||
|
||||
Q_INVOKABLE QString generateUniqueId() const;
|
||||
Q_INVOKABLE bool sendConversation(const QString &ingestId, const QString &conversation);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activeChanged();
|
||||
void usageStatsActiveChanged();
|
||||
void healthCheckFailed(int code);
|
||||
|
||||
public Q_SLOTS:
|
||||
@ -63,6 +52,8 @@ private Q_SLOTS:
|
||||
void handleJsonUploadFinished();
|
||||
void handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
void handleMixpanelFinished();
|
||||
void handleIsActiveChanged();
|
||||
void handleUsageStatsActiveChanged();
|
||||
|
||||
private:
|
||||
void sendHealth();
|
||||
@ -73,8 +64,6 @@ private:
|
||||
|
||||
private:
|
||||
bool m_shouldSendStartup;
|
||||
bool m_isActive;
|
||||
bool m_usageStatsActive;
|
||||
QString m_ipify;
|
||||
QString m_uniqueId;
|
||||
QNetworkAccessManager m_networkManager;
|
||||
|
@ -5,6 +5,7 @@ import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Dialogs
|
||||
import localdocs
|
||||
import mysettings
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@ -12,27 +13,6 @@ Item {
|
||||
property alias collection: collection.text
|
||||
property alias folder_path: folderEdit.text
|
||||
|
||||
property int defaultChunkSize: 256
|
||||
property int defaultRetrievalSize: 3
|
||||
|
||||
property alias chunkSize: settings.chunkSize
|
||||
property alias retrievalSize: settings.retrievalSize
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
category: "localdocs"
|
||||
property int chunkSize: root.defaultChunkSize
|
||||
property int retrievalSize: root.defaultRetrievalSize
|
||||
}
|
||||
|
||||
function restoreLocalDocsDefaults() {
|
||||
settings.chunkSize = root.defaultChunkSize
|
||||
settings.retrievalSize = root.defaultRetrievalSize
|
||||
LocalDocs.chunkSize = settings.chunkSize
|
||||
LocalDocs.retrievalSize = settings.retrievalSize
|
||||
settings.sync()
|
||||
}
|
||||
|
||||
FolderDialog {
|
||||
id: folderDialog
|
||||
title: "Please choose a directory"
|
||||
@ -240,19 +220,17 @@ Item {
|
||||
Layout.column: 1
|
||||
ToolTip.text: qsTr("Number of characters per document snippet.\nNOTE: larger numbers increase likelihood of factual responses, but also result in slower generation.")
|
||||
ToolTip.visible: hovered
|
||||
text: settings.chunkSize.toString()
|
||||
text: MySettings.localDocsChunkSize
|
||||
validator: IntValidator {
|
||||
bottom: 1
|
||||
}
|
||||
onEditingFinished: {
|
||||
var val = parseInt(text)
|
||||
if (!isNaN(val)) {
|
||||
settings.chunkSize = val
|
||||
settings.sync()
|
||||
MySettings.localDocsChunkSize = val
|
||||
focus = false
|
||||
LocalDocs.chunkSize = settings.chunkSize
|
||||
} else {
|
||||
text = settings.chunkSize.toString()
|
||||
text = MySettings.localDocsChunkSize
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,19 +248,17 @@ Item {
|
||||
Layout.column: 1
|
||||
ToolTip.text: qsTr("Best N matches of retrieved document snippets to add to the context for prompt.\nNOTE: larger numbers increase likelihood of factual responses, but also result in slower generation.")
|
||||
ToolTip.visible: hovered
|
||||
text: settings.retrievalSize.toString()
|
||||
text: MySettings.localDocsRetrievalSize
|
||||
validator: IntValidator {
|
||||
bottom: 1
|
||||
}
|
||||
onEditingFinished: {
|
||||
var val = parseInt(text)
|
||||
if (!isNaN(val)) {
|
||||
settings.retrievalSize = val
|
||||
settings.sync()
|
||||
MySettings.localDocsRetrievalSize = val
|
||||
focus = false
|
||||
LocalDocs.retrievalSize = settings.retrievalSize
|
||||
} else {
|
||||
text = settings.retrievalSize.toString()
|
||||
text = MySettings.localDocsRetrievalSize
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -311,7 +287,7 @@ Item {
|
||||
Accessible.name: text
|
||||
Accessible.description: qsTr("Restores the settings dialog to a default state")
|
||||
onClicked: {
|
||||
root.restoreLocalDocsDefaults();
|
||||
MySettings.restoreLocalDocsDefaults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import QtQuick.Layouts
|
||||
import download
|
||||
import network
|
||||
import llm
|
||||
import mysettings
|
||||
|
||||
Dialog {
|
||||
id: networkDialog
|
||||
@ -18,16 +19,6 @@ Dialog {
|
||||
id: theme
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
category: "network"
|
||||
property string attribution: ""
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
settings.sync()
|
||||
}
|
||||
|
||||
Column {
|
||||
id: column
|
||||
spacing: 20
|
||||
@ -86,7 +77,7 @@ NOTE: By turning on this feature, you will be sending your data to the GPT4All O
|
||||
color: theme.textColor
|
||||
padding: 20
|
||||
width: parent.width
|
||||
text: settings.attribution
|
||||
text: MySettings.networkAttribution
|
||||
font.pixelSize: theme.fontSizeLarge
|
||||
placeholderText: qsTr("Please provide a name for attribution (optional)")
|
||||
placeholderTextColor: theme.backgroundLightest
|
||||
@ -98,8 +89,7 @@ NOTE: By turning on this feature, you will be sending your data to the GPT4All O
|
||||
Accessible.name: qsTr("Attribution (optional)")
|
||||
Accessible.description: qsTr("Textfield for providing attribution")
|
||||
onEditingFinished: {
|
||||
settings.attribution = attribution.text;
|
||||
settings.sync();
|
||||
MySettings.networkAttribution = attribution.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,16 +123,16 @@ NOTE: By turning on this feature, you will be sending your data to the GPT4All O
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
if (Network.isActive)
|
||||
if (MySettings.networkIsActive)
|
||||
return
|
||||
Network.isActive = true;
|
||||
MySettings.networkIsActive = true;
|
||||
Network.sendNetworkToggled(true);
|
||||
}
|
||||
|
||||
onRejected: {
|
||||
if (!Network.isActive)
|
||||
if (!MySettings.networkIsActive)
|
||||
return
|
||||
Network.isActive = false;
|
||||
MySettings.networkIsActive = false;
|
||||
Network.sendNetworkToggled(false);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import QtQuick.Layouts
|
||||
import download
|
||||
import network
|
||||
import llm
|
||||
import mysettings
|
||||
|
||||
Dialog {
|
||||
id: startupDialog
|
||||
@ -135,7 +136,7 @@ model release that uses your data!")
|
||||
ButtonGroup {
|
||||
buttons: optInStatisticsRadio.children
|
||||
onClicked: {
|
||||
Network.usageStatsActive = optInStatisticsRadio.checked
|
||||
MySettings.networkUsageStatsActive = optInStatisticsRadio.checked
|
||||
if (optInNetworkRadio.choiceMade && optInStatisticsRadio.choiceMade)
|
||||
startupDialog.close();
|
||||
}
|
||||
@ -246,7 +247,7 @@ model release that uses your data!")
|
||||
ButtonGroup {
|
||||
buttons: optInNetworkRadio.children
|
||||
onClicked: {
|
||||
Network.isActive = optInNetworkRadio.checked
|
||||
MySettings.networkIsActive = optInNetworkRadio.checked
|
||||
if (optInNetworkRadio.choiceMade && optInStatisticsRadio.choiceMade)
|
||||
startupDialog.close();
|
||||
}
|
||||
|
@ -295,13 +295,11 @@ QHttpServerResponse Server::handleCompletionRequest(const QHttpServerRequest &re
|
||||
// don't remember any context
|
||||
resetContext();
|
||||
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
const QString promptTemplate = settings.value("promptTemplate", "%1").toString();
|
||||
const float top_k = settings.value("topK", m_ctx.top_k).toDouble();
|
||||
const int n_batch = settings.value("promptBatchSize", m_ctx.n_batch).toInt();
|
||||
const float repeat_penalty = settings.value("repeatPenalty", m_ctx.repeat_penalty).toDouble();
|
||||
const int repeat_last_n = settings.value("repeatPenaltyTokens", m_ctx.repeat_last_n).toInt();
|
||||
const QString promptTemplate = MySettings::globalInstance()->promptTemplate();
|
||||
const float top_k = MySettings::globalInstance()->topK();
|
||||
const int n_batch = MySettings::globalInstance()->promptBatchSize();
|
||||
const float repeat_penalty = MySettings::globalInstance()->repeatPenalty();
|
||||
const int repeat_last_n = MySettings::globalInstance()->repeatPenaltyTokens();
|
||||
|
||||
int threadCount = MySettings::globalInstance()->threadCount();
|
||||
if (threadCount <= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user