From 081d32bd97aa17d425706f30e116deba35c02b68 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Wed, 3 May 2023 12:45:14 -0400 Subject: [PATCH] Restore the model when switching chats. --- chat.cpp | 3 ++- chat.h | 3 ++- chatllm.cpp | 7 +++++-- chatllm.h | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chat.cpp b/chat.cpp index 15430148..87f1dbd6 100644 --- a/chat.cpp +++ b/chat.cpp @@ -127,13 +127,14 @@ bool Chat::isRecalc() const void Chat::unload() { + m_savedModelName = m_llmodel->modelName(); stopGenerating(); emit unloadRequested(); } void Chat::reload() { - emit reloadRequested(); + emit reloadRequested(m_savedModelName); } void Chat::generatedNameChanged() diff --git a/chat.h b/chat.h index c81509b9..18a26d6a 100644 --- a/chat.h +++ b/chat.h @@ -72,7 +72,7 @@ Q_SIGNALS: void setThreadCountRequested(int32_t threadCount); void recalcChanged(); void unloadRequested(); - void reloadRequested(); + void reloadRequested(const QString &modelName); void generateNameRequested(); private Q_SLOTS: @@ -86,6 +86,7 @@ private: QString m_id; QString m_name; QString m_userName; + QString m_savedModelName; ChatModel *m_chatModel; bool m_responseInProgress; int32_t m_desiredThreadCount; diff --git a/chatllm.cpp b/chatllm.cpp index 4872dee3..68230127 100644 --- a/chatllm.cpp +++ b/chatllm.cpp @@ -295,9 +295,12 @@ void ChatLLM::unload() emit isModelLoadedChanged(); } -void ChatLLM::reload() +void ChatLLM::reload(const QString &modelName) { - loadModel(); + if (modelName.isEmpty()) + loadModel(); + else + loadModelPrivate(modelName); } void ChatLLM::generateName() diff --git a/chatllm.h b/chatllm.h index e5c0acef..ab2dcc8c 100644 --- a/chatllm.h +++ b/chatllm.h @@ -43,7 +43,7 @@ public Q_SLOTS: bool loadModel(); void modelNameChangeRequested(const QString &modelName); void unload(); - void reload(); + void reload(const QString &modelName); void generateName(); Q_SIGNALS: