mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-03-31 01:42:56 -04:00
refactor: Adapt provider to clients API
This commit is contained in:
@ -1,36 +1,9 @@
|
||||
#include "Provider.hpp"
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace QodeAssist::PluginLLMCore {
|
||||
|
||||
Provider::Provider(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_httpClient(new HttpClient(this))
|
||||
{
|
||||
connect(m_httpClient, &HttpClient::dataReceived, this, &Provider::onDataReceived);
|
||||
connect(m_httpClient, &HttpClient::requestFinished, this, &Provider::onRequestFinished);
|
||||
}
|
||||
|
||||
void Provider::cancelRequest(const RequestID &requestId)
|
||||
{
|
||||
m_httpClient->cancelRequest(requestId);
|
||||
}
|
||||
|
||||
HttpClient *Provider::httpClient() const
|
||||
{
|
||||
return m_httpClient;
|
||||
}
|
||||
|
||||
QJsonObject Provider::parseEventLine(const QString &line)
|
||||
{
|
||||
if (!line.startsWith("data: "))
|
||||
return QJsonObject();
|
||||
|
||||
QString jsonStr = line.mid(6);
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(jsonStr.toUtf8());
|
||||
return doc.object();
|
||||
}
|
||||
{}
|
||||
|
||||
} // namespace QodeAssist::PluginLLMCore
|
||||
|
||||
Reference in New Issue
Block a user