mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-06-23 14:07:58 +00:00
Turn off saving chats to disk by default as it eats so much disk space.
This commit is contained in:
parent
6d4d86d07c
commit
8d2c8c8cb0
@ -3,6 +3,19 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
|
bool ChatListModel::shouldSaveChats() const
|
||||||
|
{
|
||||||
|
return m_shouldSaveChats;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatListModel::setShouldSaveChats(bool b)
|
||||||
|
{
|
||||||
|
if (m_shouldSaveChats == b)
|
||||||
|
return;
|
||||||
|
m_shouldSaveChats = b;
|
||||||
|
emit shouldSaveChatsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatListModel::removeChatFile(Chat *chat) const
|
void ChatListModel::removeChatFile(Chat *chat) const
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
@ -18,6 +31,9 @@ void ChatListModel::removeChatFile(Chat *chat) const
|
|||||||
|
|
||||||
void ChatListModel::saveChats() const
|
void ChatListModel::saveChats() const
|
||||||
{
|
{
|
||||||
|
if (!m_shouldSaveChats)
|
||||||
|
return;
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QFileInfo settingsInfo(settings.fileName());
|
QFileInfo settingsInfo(settings.fileName());
|
||||||
QString settingsPath = settingsInfo.absolutePath();
|
QString settingsPath = settingsInfo.absolutePath();
|
||||||
|
@ -9,12 +9,14 @@ class ChatListModel : public QAbstractListModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
Q_PROPERTY(int count READ count NOTIFY countChanged)
|
||||||
Q_PROPERTY(Chat *currentChat READ currentChat WRITE setCurrentChat NOTIFY currentChatChanged)
|
Q_PROPERTY(Chat *currentChat READ currentChat WRITE setCurrentChat NOTIFY currentChatChanged)
|
||||||
|
Q_PROPERTY(bool shouldSaveChats READ shouldSaveChats WRITE setShouldSaveChats NOTIFY shouldSaveChatsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ChatListModel(QObject *parent = nullptr)
|
explicit ChatListModel(QObject *parent = nullptr)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
, m_currentChat(nullptr)
|
, m_currentChat(nullptr)
|
||||||
, m_newChat(nullptr)
|
, m_newChat(nullptr)
|
||||||
|
, m_shouldSaveChats(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +55,9 @@ public:
|
|||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldSaveChats() const;
|
||||||
|
void setShouldSaveChats(bool b);
|
||||||
|
|
||||||
Q_INVOKABLE void addChat()
|
Q_INVOKABLE void addChat()
|
||||||
{
|
{
|
||||||
// Don't add a new chat if we already have one
|
// Don't add a new chat if we already have one
|
||||||
@ -165,6 +170,7 @@ Q_SIGNALS:
|
|||||||
void connectChat(Chat*);
|
void connectChat(Chat*);
|
||||||
void disconnectChat(Chat*);
|
void disconnectChat(Chat*);
|
||||||
void currentChatChanged();
|
void currentChatChanged();
|
||||||
|
void shouldSaveChatsChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void newChatCountChanged()
|
void newChatCountChanged()
|
||||||
@ -198,6 +204,7 @@ private Q_SLOTS:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_shouldSaveChats;
|
||||||
Chat* m_newChat;
|
Chat* m_newChat;
|
||||||
Chat* m_currentChat;
|
Chat* m_currentChat;
|
||||||
QList<Chat*> m_chats;
|
QList<Chat*> m_chats;
|
||||||
|
10
network.cpp
10
network.cpp
@ -306,6 +306,16 @@ void Network::sendNetworkToggled(bool isActive)
|
|||||||
sendMixpanelEvent("network_toggled", QVector<KeyValue>{kv});
|
sendMixpanelEvent("network_toggled", QVector<KeyValue>{kv});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::sendSaveChatsToggled(bool isActive)
|
||||||
|
{
|
||||||
|
if (!m_usageStatsActive)
|
||||||
|
return;
|
||||||
|
KeyValue kv;
|
||||||
|
kv.key = QString("isActive");
|
||||||
|
kv.value = QJsonValue(isActive);
|
||||||
|
sendMixpanelEvent("savechats_toggled", QVector<KeyValue>{kv});
|
||||||
|
}
|
||||||
|
|
||||||
void Network::sendNewChat(int count)
|
void Network::sendNewChat(int count)
|
||||||
{
|
{
|
||||||
if (!m_usageStatsActive)
|
if (!m_usageStatsActive)
|
||||||
|
@ -47,6 +47,7 @@ public Q_SLOTS:
|
|||||||
void sendDownloadFinished(const QString &model, bool success);
|
void sendDownloadFinished(const QString &model, bool success);
|
||||||
Q_INVOKABLE void sendSettingsDialog();
|
Q_INVOKABLE void sendSettingsDialog();
|
||||||
Q_INVOKABLE void sendNetworkToggled(bool active);
|
Q_INVOKABLE void sendNetworkToggled(bool active);
|
||||||
|
Q_INVOKABLE void sendSaveChatsToggled(bool active);
|
||||||
Q_INVOKABLE void sendNewChat(int count);
|
Q_INVOKABLE void sendNewChat(int count);
|
||||||
Q_INVOKABLE void sendRemoveChat();
|
Q_INVOKABLE void sendRemoveChat();
|
||||||
Q_INVOKABLE void sendRenameChat();
|
Q_INVOKABLE void sendRenameChat();
|
||||||
|
@ -37,6 +37,7 @@ Dialog {
|
|||||||
property real defaultRepeatPenalty: 1.10
|
property real defaultRepeatPenalty: 1.10
|
||||||
property int defaultRepeatPenaltyTokens: 64
|
property int defaultRepeatPenaltyTokens: 64
|
||||||
property int defaultThreadCount: 0
|
property int defaultThreadCount: 0
|
||||||
|
property bool defaultSaveChats: false
|
||||||
property string defaultPromptTemplate: "### Human:
|
property string defaultPromptTemplate: "### Human:
|
||||||
%1
|
%1
|
||||||
### Assistant:\n"
|
### Assistant:\n"
|
||||||
@ -51,6 +52,7 @@ Dialog {
|
|||||||
property alias repeatPenalty: settings.repeatPenalty
|
property alias repeatPenalty: settings.repeatPenalty
|
||||||
property alias repeatPenaltyTokens: settings.repeatPenaltyTokens
|
property alias repeatPenaltyTokens: settings.repeatPenaltyTokens
|
||||||
property alias threadCount: settings.threadCount
|
property alias threadCount: settings.threadCount
|
||||||
|
property alias saveChats: settings.saveChats
|
||||||
property alias modelPath: settings.modelPath
|
property alias modelPath: settings.modelPath
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
@ -61,6 +63,7 @@ Dialog {
|
|||||||
property int maxLength: settingsDialog.defaultMaxLength
|
property int maxLength: settingsDialog.defaultMaxLength
|
||||||
property int promptBatchSize: settingsDialog.defaultPromptBatchSize
|
property int promptBatchSize: settingsDialog.defaultPromptBatchSize
|
||||||
property int threadCount: settingsDialog.defaultThreadCount
|
property int threadCount: settingsDialog.defaultThreadCount
|
||||||
|
property bool saveChats: settingsDialog.defaultSaveChats
|
||||||
property real repeatPenalty: settingsDialog.defaultRepeatPenalty
|
property real repeatPenalty: settingsDialog.defaultRepeatPenalty
|
||||||
property int repeatPenaltyTokens: settingsDialog.defaultRepeatPenaltyTokens
|
property int repeatPenaltyTokens: settingsDialog.defaultRepeatPenaltyTokens
|
||||||
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
property string promptTemplate: settingsDialog.defaultPromptTemplate
|
||||||
@ -80,13 +83,16 @@ Dialog {
|
|||||||
function restoreApplicationDefaults() {
|
function restoreApplicationDefaults() {
|
||||||
settings.modelPath = settingsDialog.defaultModelPath
|
settings.modelPath = settingsDialog.defaultModelPath
|
||||||
settings.threadCount = defaultThreadCount
|
settings.threadCount = defaultThreadCount
|
||||||
|
settings.saveChats = defaultSaveChats
|
||||||
Download.downloadLocalModelsPath = settings.modelPath
|
Download.downloadLocalModelsPath = settings.modelPath
|
||||||
LLM.threadCount = settings.threadCount
|
LLM.threadCount = settings.threadCount
|
||||||
|
LLM.chatListModel.shouldSaveChats = settings.saveChats
|
||||||
settings.sync()
|
settings.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
LLM.threadCount = settings.threadCount
|
LLM.threadCount = settings.threadCount
|
||||||
|
LLM.chatListModel.shouldSaveChats = settings.saveChats
|
||||||
Download.downloadLocalModelsPath = settings.modelPath
|
Download.downloadLocalModelsPath = settings.modelPath
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,8 +636,61 @@ Dialog {
|
|||||||
Accessible.name: nThreadsLabel.text
|
Accessible.name: nThreadsLabel.text
|
||||||
Accessible.description: ToolTip.text
|
Accessible.description: ToolTip.text
|
||||||
}
|
}
|
||||||
Button {
|
Label {
|
||||||
|
id: saveChatsLabel
|
||||||
|
text: qsTr("Save chats to disk:")
|
||||||
|
color: theme.textColor
|
||||||
Layout.row: 3
|
Layout.row: 3
|
||||||
|
Layout.column: 0
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
id: saveChatsBox
|
||||||
|
Layout.row: 3
|
||||||
|
Layout.column: 1
|
||||||
|
checked: settingsDialog.saveChats
|
||||||
|
onClicked: {
|
||||||
|
Network.sendSaveChatsToggled(saveChatsBox.checked);
|
||||||
|
settingsDialog.saveChats = saveChatsBox.checked
|
||||||
|
LLM.chatListModel.shouldSaveChats = saveChatsBox.checked
|
||||||
|
settings.sync()
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.text: qsTr("WARNING: Saving chats to disk can be ~2GB per chat")
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: "transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
indicator: Rectangle {
|
||||||
|
implicitWidth: 26
|
||||||
|
implicitHeight: 26
|
||||||
|
x: saveChatsBox.leftPadding
|
||||||
|
y: parent.height / 2 - height / 2
|
||||||
|
border.color: theme.dialogBorder
|
||||||
|
color: "transparent"
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 14
|
||||||
|
height: 14
|
||||||
|
x: 6
|
||||||
|
y: 6
|
||||||
|
color: theme.textColor
|
||||||
|
visible: saveChatsBox.checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Text {
|
||||||
|
text: saveChatsBox.text
|
||||||
|
font: saveChatsBox.font
|
||||||
|
opacity: enabled ? 1.0 : 0.3
|
||||||
|
color: theme.textColor
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
leftPadding: saveChatsBox.indicator.width + saveChatsBox.spacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
Layout.row: 4
|
||||||
Layout.column: 1
|
Layout.column: 1
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
padding: 15
|
padding: 15
|
||||||
|
Loading…
Reference in New Issue
Block a user