mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-10-25 10:12:18 +00:00
Add save/restore to chatgpt chats and allow serialize/deseralize from disk.
This commit is contained in:
@@ -38,6 +38,19 @@ void ChatListModel::setShouldSaveChats(bool b)
|
||||
emit shouldSaveChatsChanged();
|
||||
}
|
||||
|
||||
bool ChatListModel::shouldSaveChatGPTChats() const
|
||||
{
|
||||
return m_shouldSaveChatGPTChats;
|
||||
}
|
||||
|
||||
void ChatListModel::setShouldSaveChatGPTChats(bool b)
|
||||
{
|
||||
if (m_shouldSaveChatGPTChats == b)
|
||||
return;
|
||||
m_shouldSaveChatGPTChats = b;
|
||||
emit shouldSaveChatGPTChatsChanged();
|
||||
}
|
||||
|
||||
void ChatListModel::removeChatFile(Chat *chat) const
|
||||
{
|
||||
Q_ASSERT(chat != m_serverChat);
|
||||
@@ -52,15 +65,17 @@ void ChatListModel::removeChatFile(Chat *chat) const
|
||||
|
||||
void ChatListModel::saveChats() const
|
||||
{
|
||||
if (!m_shouldSaveChats)
|
||||
return;
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
const QString savePath = Download::globalInstance()->downloadLocalModelsPath();
|
||||
for (Chat *chat : m_chats) {
|
||||
if (chat == m_serverChat)
|
||||
continue;
|
||||
const bool isChatGPT = chat->modelName().startsWith("chatgpt-");
|
||||
if (!isChatGPT && !m_shouldSaveChats)
|
||||
continue;
|
||||
if (isChatGPT && !m_shouldSaveChatGPTChats)
|
||||
continue;
|
||||
QString fileName = "gpt4all-" + chat->id() + ".chat";
|
||||
QFile file(savePath + "/" + fileName);
|
||||
bool success = file.open(QIODevice::WriteOnly);
|
||||
|
||||
Reference in New Issue
Block a user