mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
chat: implement display of model loading warnings (#2034)
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
a0bd96f75d
commit
44717682a7
@ -46,6 +46,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::modelLoadingError, this, &Chat::handleModelLoadingError, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::modelLoadingWarning, this, &Chat::modelLoadingWarning, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::recalcChanged, this, &Chat::handleRecalculating, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::generatedNameChanged, this, &Chat::generatedNameChanged, Qt::QueuedConnection);
|
||||
connect(m_llmodel, &ChatLLM::reportSpeed, this, &Chat::handleTokenSpeedChanged, Qt::QueuedConnection);
|
||||
@ -333,7 +334,8 @@ void Chat::handleRecalculating()
|
||||
|
||||
void Chat::handleModelLoadingError(const QString &error)
|
||||
{
|
||||
qWarning() << "ERROR:" << qPrintable(error) << "id" << id();
|
||||
auto stream = qWarning().noquote() << "ERROR:" << error << "id";
|
||||
stream.quote() << id();
|
||||
m_modelLoadingError = error;
|
||||
emit modelLoadingErrorChanged();
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ Q_SIGNALS:
|
||||
void chatModelChanged();
|
||||
void isModelLoadedChanged();
|
||||
void modelLoadingPercentageChanged();
|
||||
void modelLoadingWarning(const QString &warning);
|
||||
void responseChanged();
|
||||
void responseInProgressChanged();
|
||||
void responseStateChanged();
|
||||
|
@ -142,7 +142,7 @@ void ChatGPT::prompt(const std::string &prompt,
|
||||
QJsonDocument doc(root);
|
||||
|
||||
#if defined(DEBUG)
|
||||
qDebug() << "ChatGPT::prompt begin network request" << qPrintable(doc.toJson());
|
||||
qDebug().noquote() << "ChatGPT::prompt begin network request" << doc.toJson();
|
||||
#endif
|
||||
|
||||
m_responseCallback = responseCallback;
|
||||
@ -231,7 +231,7 @@ void ChatGPTWorker::handleReadyRead()
|
||||
int code = response.toInt(&ok);
|
||||
if (!ok || code != 200) {
|
||||
m_chat->callResponse(-1, QString("\nERROR: 2 ChatGPT responded with error code \"%1-%2\" %3\n")
|
||||
.arg(code).arg(reply->errorString()).arg(qPrintable(reply->readAll())).toStdString());
|
||||
.arg(code).arg(reply->errorString()).arg(reply->readAll()).toStdString());
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
@ -246,7 +246,7 @@ void ChatGPTWorker::handleReadyRead()
|
||||
if (jsonData == "[DONE]")
|
||||
continue;
|
||||
#if defined(DEBUG)
|
||||
qDebug() << "line" << qPrintable(jsonData);
|
||||
qDebug().noquote() << "line" << jsonData;
|
||||
#endif
|
||||
QJsonParseError err;
|
||||
const QJsonDocument document = QJsonDocument::fromJson(jsonData.toUtf8(), &err);
|
||||
|
@ -308,7 +308,14 @@ bool ChatLLM::loadModel(const ModelInfo &modelInfo)
|
||||
|
||||
if (m_llModelInfo.model) {
|
||||
if (m_llModelInfo.model->isModelBlacklisted(filePath.toStdString())) {
|
||||
// TODO(cebtenzzre): warn that this model is out-of-date
|
||||
static QSet<QString> warned;
|
||||
auto fname = modelInfo.filename();
|
||||
if (!warned.contains(fname)) {
|
||||
emit modelLoadingWarning(QString(
|
||||
"%1 is known to be broken. Please get a replacement via the download dialog."
|
||||
).arg(fname));
|
||||
warned.insert(fname); // don't warn again until restart
|
||||
}
|
||||
}
|
||||
|
||||
m_llModelInfo.model->setProgressCallback([this](float progress) -> bool {
|
||||
@ -996,7 +1003,7 @@ void ChatLLM::restoreState()
|
||||
m_llModelInfo.model->restoreState(static_cast<const uint8_t*>(reinterpret_cast<void*>(m_state.data())));
|
||||
m_processedSystemPrompt = true;
|
||||
} else {
|
||||
qWarning() << "restoring state from text because" << m_llModelInfo.model->stateSize() << "!=" << m_state.size() << "\n";
|
||||
qWarning() << "restoring state from text because" << m_llModelInfo.model->stateSize() << "!=" << m_state.size();
|
||||
m_restoreStateFromText = true;
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,7 @@ Q_SIGNALS:
|
||||
void recalcChanged();
|
||||
void modelLoadingPercentageChanged(float);
|
||||
void modelLoadingError(const QString &error);
|
||||
void modelLoadingWarning(const QString &warning);
|
||||
void responseChanged(const QString &response);
|
||||
void promptProcessing();
|
||||
void responseStopped();
|
||||
|
@ -93,6 +93,9 @@ Window {
|
||||
if (currentChat.modelLoadingError !== "")
|
||||
modelLoadingErrorPopup.open()
|
||||
}
|
||||
function onModelLoadingWarning(warning) {
|
||||
modelLoadingWarningPopup.open_(warning)
|
||||
}
|
||||
}
|
||||
|
||||
property bool hasShownModelDownload: false
|
||||
@ -213,6 +216,15 @@ Window {
|
||||
+ "<li>Check out our <a href=\"https://discord.gg/4M2QFmTt2k\">discord channel</a> for help")
|
||||
}
|
||||
|
||||
PopupDialog {
|
||||
id: modelLoadingWarningPopup
|
||||
property string message
|
||||
anchors.centerIn: parent
|
||||
shouldTimeOut: false
|
||||
text: qsTr("<h3>Warning</h3><p>%1</p>").arg(message)
|
||||
function open_(msg) { message = msg; open(); }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: accentRibbon
|
||||
anchors.left: parent.left
|
||||
|
@ -1311,7 +1311,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
||||
if (!file.open(QIODeviceBase::WriteOnly)) {
|
||||
qWarning() << "ERROR: Couldn't write models config file: " << modelsConfig;
|
||||
} else {
|
||||
file.write(jsonData.constData());
|
||||
file.write(jsonData);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
@ -1328,7 +1328,7 @@ void ModelList::parseModelsJsonFile(const QByteArray &jsonData, bool save)
|
||||
QString requiresVersion = obj["requires"].toString();
|
||||
QString versionRemoved = obj["removedIn"].toString();
|
||||
QString url = obj["url"].toString();
|
||||
QByteArray modelHash = obj["md5sum"].toString().toLatin1().constData();
|
||||
QByteArray modelHash = obj["md5sum"].toString().toLatin1();
|
||||
bool isDefault = obj.contains("isDefault") && obj["isDefault"] == QString("true");
|
||||
bool disableGUI = obj.contains("disableGUI") && obj["disableGUI"] == QString("true");
|
||||
QString description = obj["description"].toString();
|
||||
|
@ -462,9 +462,9 @@ void Network::handleIpifyFinished()
|
||||
qWarning() << "ERROR: ipify invalid response.";
|
||||
if (code != 200)
|
||||
qWarning() << "ERROR: ipify response != 200 code:" << code;
|
||||
m_ipify = qPrintable(reply->readAll());
|
||||
m_ipify = reply->readAll();
|
||||
#if defined(DEBUG)
|
||||
printf("ipify finished %s\n", m_ipify.toLatin1().constData());
|
||||
printf("ipify finished %s\n", qPrintable(m_ipify));
|
||||
fflush(stdout);
|
||||
#endif
|
||||
reply->deleteLater();
|
||||
|
Loading…
Reference in New Issue
Block a user