mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Update the datalake support.
This commit is contained in:
parent
fe97a6e04f
commit
fc34d1d3b2
7
main.qml
7
main.qml
@ -17,6 +17,8 @@ Window {
|
||||
id: theme
|
||||
}
|
||||
|
||||
property string chatId: Network.generateUniqueId()
|
||||
|
||||
color: theme.textColor
|
||||
|
||||
Item {
|
||||
@ -396,6 +398,7 @@ Window {
|
||||
onClicked: {
|
||||
LLM.stopGenerating()
|
||||
LLM.resetContext()
|
||||
chatId = Network.generateUniqueId()
|
||||
chatModel.clear()
|
||||
}
|
||||
}
|
||||
@ -675,7 +678,7 @@ Window {
|
||||
newResponse = response
|
||||
thumbsDownState = true
|
||||
thumbsUpState = false
|
||||
Network.sendConversation(getConversationJson());
|
||||
Network.sendConversation(chatId, getConversationJson());
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,7 +710,7 @@ Window {
|
||||
newResponse = ""
|
||||
thumbsUpState = true
|
||||
thumbsDownState = false
|
||||
Network.sendConversation(getConversationJson());
|
||||
Network.sendConversation(chatId, getConversationJson());
|
||||
}
|
||||
}
|
||||
|
||||
|
20
network.cpp
20
network.cpp
@ -46,7 +46,7 @@ QString Network::generateUniqueId() const
|
||||
return QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||
}
|
||||
|
||||
bool Network::packageAndSendJson(const QString &json)
|
||||
bool Network::packageAndSendJson(const QString &ingestId, const QString &json)
|
||||
{
|
||||
if (!m_isActive)
|
||||
return false;
|
||||
@ -63,6 +63,7 @@ bool Network::packageAndSendJson(const QString &json)
|
||||
object.insert("source", "gpt4all-chat");
|
||||
object.insert("agent_id", LLM::globalInstance()->modelName());
|
||||
object.insert("submitter_id", m_uniqueId);
|
||||
object.insert("ingest_id", ingestId);
|
||||
|
||||
QSettings settings;
|
||||
settings.sync();
|
||||
@ -77,8 +78,7 @@ bool Network::packageAndSendJson(const QString &json)
|
||||
printf("%s", qPrintable(newDoc.toJson(QJsonDocument::Indented)));
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
QUrl jsonUrl("http://localhost/v1/ingest/chat");
|
||||
QUrl jsonUrl("https://api.gpt4all.io/v1/ingest/chat");
|
||||
QNetworkRequest request(jsonUrl);
|
||||
QByteArray body(newDoc.toJson());
|
||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
@ -101,9 +101,9 @@ void Network::handleJsonUploadFinished()
|
||||
bool ok;
|
||||
int code = response.toInt(&ok);
|
||||
if (!ok)
|
||||
qWarning() << "ERROR: Invalid response.";
|
||||
qWarning() << "ERROR: ingest invalid response.";
|
||||
if (code != 200) {
|
||||
qWarning() << "ERROR: response != 200 code:" << code;
|
||||
qWarning() << "ERROR: ingest response != 200 code:" << code;
|
||||
sendHealth();
|
||||
}
|
||||
|
||||
@ -123,14 +123,14 @@ void Network::handleJsonUploadFinished()
|
||||
jsonReply->deleteLater();
|
||||
}
|
||||
|
||||
bool Network::sendConversation(const QString &conversation)
|
||||
bool Network::sendConversation(const QString &ingestId, const QString &conversation)
|
||||
{
|
||||
return packageAndSendJson(conversation);
|
||||
return packageAndSendJson(ingestId, conversation);
|
||||
}
|
||||
|
||||
void Network::sendHealth()
|
||||
{
|
||||
QUrl healthUrl("http://localhost/v1/health");
|
||||
QUrl healthUrl("https://api.gpt4all.io/v1/health");
|
||||
QNetworkRequest request(healthUrl);
|
||||
QNetworkReply *healthReply = m_networkManager.get(request);
|
||||
connect(healthReply, &QNetworkReply::finished, this, &Network::handleHealthFinished);
|
||||
@ -147,9 +147,9 @@ void Network::handleHealthFinished()
|
||||
bool ok;
|
||||
int code = response.toInt(&ok);
|
||||
if (!ok)
|
||||
qWarning() << "ERROR: Invalid response.";
|
||||
qWarning() << "ERROR: health invalid response.";
|
||||
if (code != 200) {
|
||||
qWarning() << "ERROR: response != 200 code:" << code;
|
||||
qWarning() << "ERROR: health response != 200 code:" << code;
|
||||
emit healthCheckFailed(code);
|
||||
setActive(false);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
void setActive(bool b);
|
||||
|
||||
Q_INVOKABLE QString generateUniqueId() const;
|
||||
Q_INVOKABLE bool sendConversation(const QString &conversation);
|
||||
Q_INVOKABLE bool sendConversation(const QString &ingestId, const QString &conversation);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activeChanged();
|
||||
@ -28,7 +28,7 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
void sendHealth();
|
||||
bool packageAndSendJson(const QString &json);
|
||||
bool packageAndSendJson(const QString &ingestId, const QString &json);
|
||||
|
||||
private:
|
||||
bool m_isActive;
|
||||
|
Loading…
Reference in New Issue
Block a user