From 67bbce43abf55c25c937a2339fa2de72acc23058 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Wed, 21 Feb 2024 16:05:49 -0500 Subject: [PATCH] Fix state issues with reloading model. Signed-off-by: Adam Treat --- gpt4all-chat/chatllm.cpp | 6 +++++- gpt4all-chat/main.qml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gpt4all-chat/chatllm.cpp b/gpt4all-chat/chatllm.cpp index aa19b696..d0c9d33b 100644 --- a/gpt4all-chat/chatllm.cpp +++ b/gpt4all-chat/chatllm.cpp @@ -672,7 +672,11 @@ void ChatLLM::unloadModel() if (!isModelLoaded() || m_isServer) return; - emit modelLoadingPercentageChanged(0.0f); + if (!m_forceUnloadModel || !m_shouldBeLoaded) + emit modelLoadingPercentageChanged(0.0f); + else + emit modelLoadingPercentageChanged(std::numeric_limits::min()); // small non-zero positive value + saveState(); #if defined(DEBUG_MODEL_LOADING) qDebug() << "unloadModel" << m_llmThread.objectName() << m_llModelInfo.model; diff --git a/gpt4all-chat/main.qml b/gpt4all-chat/main.qml index 7bacb6cb..70fe6dae 100644 --- a/gpt4all-chat/main.qml +++ b/gpt4all-chat/main.qml @@ -463,7 +463,7 @@ Window { MyMiniButton { id: ejectButton - visible: currentChat.isModelLoaded + visible: currentChat.isModelLoaded && !window.isCurrentlyLoading z: 500 anchors.right: parent.right anchors.rightMargin: 50