mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-09-06 02:50:36 +00:00
chat: major UI redesign for v3.0.0 (#2396)
Signed-off-by: Adam Treat <treat.adam@gmail.com> Signed-off-by: Jared Van Bortel <jared@nomic.ai> Co-authored-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QThread>
|
||||
@@ -19,6 +20,8 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
ChatAPI::ChatAPI()
|
||||
@@ -194,7 +197,7 @@ void ChatAPIWorker::request(const QString &apiKey,
|
||||
m_ctx = promptCtx;
|
||||
|
||||
QUrl apiUrl(m_chat->url());
|
||||
const QString authorization = QString("Bearer %1").arg(apiKey).trimmed();
|
||||
const QString authorization = u"Bearer %1"_s.arg(apiKey).trimmed();
|
||||
QNetworkRequest request(apiUrl);
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
request.setRawHeader("Authorization", authorization.toUtf8());
|
||||
@@ -241,8 +244,8 @@ void ChatAPIWorker::handleReadyRead()
|
||||
if (!ok || code != 200) {
|
||||
m_chat->callResponse(
|
||||
-1,
|
||||
QString("ERROR: ChatAPIWorker::handleReadyRead got HTTP Error %1 %2: %3")
|
||||
.arg(code).arg(reply->errorString()).arg(reply->readAll()).toStdString()
|
||||
u"ERROR: ChatAPIWorker::handleReadyRead got HTTP Error %1 %2: %3"_s
|
||||
.arg(code).arg(reply->errorString(), reply->readAll()).toStdString()
|
||||
);
|
||||
emit finished();
|
||||
return;
|
||||
@@ -263,7 +266,7 @@ void ChatAPIWorker::handleReadyRead()
|
||||
QJsonParseError err;
|
||||
const QJsonDocument document = QJsonDocument::fromJson(jsonData.toUtf8(), &err);
|
||||
if (err.error != QJsonParseError::NoError) {
|
||||
m_chat->callResponse(-1, QString("ERROR: ChatAPI responded with invalid json \"%1\"")
|
||||
m_chat->callResponse(-1, u"ERROR: ChatAPI responded with invalid json \"%1\""_s
|
||||
.arg(err.errorString()).toStdString());
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user