Better error handling when the model fails to load.

This commit is contained in:
Adam Treat
2023-06-04 14:55:05 -04:00
parent bbe195ee02
commit 9f590db98d
6 changed files with 69 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
#include "localdocs.h"
#include "network.h"
#include "download.h"
#include "server.h"
Chat::Chat(QObject *parent)
: QObject(parent)
@@ -53,7 +54,7 @@ void Chat::connectLLM()
connect(m_llmodel, &ChatLLM::promptProcessing, this, &Chat::promptProcessing, 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::modelLoadingError, this, &Chat::handleModelLoadingError, Qt::QueuedConnection);
connect(m_llmodel, &ChatLLM::recalcChanged, this, &Chat::handleRecalculating, Qt::QueuedConnection);
connect(m_llmodel, &ChatLLM::generatedNameChanged, this, &Chat::generatedNameChanged, Qt::QueuedConnection);
@@ -243,6 +244,8 @@ void Chat::setModelName(const QString &modelName)
{
// doesn't block but will unload old model and load new one which the gui can see through changes
// to the isModelLoaded property
m_modelLoadingError = QString();
emit modelLoadingErrorChanged();
emit modelNameChangeRequested(modelName);
}
@@ -270,11 +273,15 @@ bool Chat::isRecalc() const
void Chat::loadDefaultModel()
{
m_modelLoadingError = QString();
emit modelLoadingErrorChanged();
emit loadDefaultModelRequested();
}
void Chat::loadModel(const QString &modelName)
{
m_modelLoadingError = QString();
emit modelLoadingErrorChanged();
emit loadModelRequested(modelName);
}
@@ -322,6 +329,13 @@ void Chat::handleModelNameChanged()
emit modelNameChanged();
}
void Chat::handleModelLoadingError(const QString &error)
{
qWarning() << "ERROR:" << qPrintable(error) << "id" << id();
m_modelLoadingError = error;
emit modelLoadingErrorChanged();
}
bool Chat::serialize(QDataStream &stream, int version) const
{
stream << m_creationDate;