mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-09-19 23:35:41 +00:00
Gracefully handle when we have a previous chat where the model that it used has gone away.
This commit is contained in:
parent
8b80345c98
commit
5f372bd881
1
chat.cpp
1
chat.cpp
@ -22,6 +22,7 @@ Chat::Chat(QObject *parent)
|
||||
connect(m_llmodel, &ChatLLM::responseStarted, this, &Chat::responseStarted, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::responseStopped, this, &Chat::responseStopped, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::modelNameChanged, this, &Chat::handleModelNameChanged, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::modelLoadingError, this, &Chat::modelLoadingError, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::recalcChanged, this, &Chat::handleRecalculating, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::generatedNameChanged, this, &Chat::generatedNameChanged, Qt::QueuedConnection);
|
||||
|
||||
|
1
chat.h
1
chat.h
@ -82,6 +82,7 @@ Q_SIGNALS:
|
||||
void reloadModelRequested(const QString &modelName);
|
||||
void generateNameRequested();
|
||||
void modelListChanged();
|
||||
void modelLoadingError(const QString &error);
|
||||
|
||||
private Q_SLOTS:
|
||||
void handleResponseChanged();
|
||||
|
@ -213,6 +213,7 @@ void ChatListModel::restoreChat(Chat *chat)
|
||||
{
|
||||
chat->setParent(this);
|
||||
connect(chat, &Chat::nameChanged, this, &ChatListModel::nameChanged);
|
||||
connect(chat, &Chat::modelLoadingError, this, &ChatListModel::handleModelLoadingError);
|
||||
|
||||
if (m_dummyChat) {
|
||||
beginResetModel();
|
||||
|
@ -105,6 +105,8 @@ public:
|
||||
this, &ChatListModel::newChatCountChanged);
|
||||
connect(m_newChat, &Chat::nameChanged,
|
||||
this, &ChatListModel::nameChanged);
|
||||
connect(m_newChat, &Chat::modelLoadingError,
|
||||
this, &ChatListModel::handleModelLoadingError);
|
||||
setCurrentChat(m_newChat);
|
||||
}
|
||||
|
||||
@ -204,6 +206,13 @@ private Q_SLOTS:
|
||||
emit dataChanged(index, index, {NameRole});
|
||||
}
|
||||
|
||||
void handleModelLoadingError(const QString &error)
|
||||
{
|
||||
Chat *chat = qobject_cast<Chat *>(sender());
|
||||
qWarning() << "ERROR:" << qPrintable(error) << "id" << chat->id();
|
||||
removeChat(chat);
|
||||
}
|
||||
|
||||
void printChats()
|
||||
{
|
||||
for (auto c : m_chats) {
|
||||
|
@ -127,7 +127,8 @@ bool ChatLLM::loadModel(const QString &modelName)
|
||||
else
|
||||
emit sendModelLoaded();
|
||||
} else {
|
||||
qWarning() << "ERROR: Could not find model at" << filePath;
|
||||
const QString error = QString("Could not find model %1").arg(modelName);
|
||||
emit modelLoadingError(error);
|
||||
}
|
||||
|
||||
if (m_llmodel)
|
||||
|
Loading…
Reference in New Issue
Block a user