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