mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-09-28 08:06:02 -04:00
Refactor llm providers to use internal http client (#227)
* refactor: Move http client into provider * refactor: Rework ollama provider for work with internal http client * refactor: Rework LM Studio provider to work with internal http client * refactor: Rework Mistral AI to work with internal http client * fix: Replace url and header to QNetworkRequest * refactor: Rework Google provider to use internal http client * refactor: OpenAI compatible providers switch to use internal http client * fix: Remove m_requestHandler from tests * refactor: Remove old handleData method * fix: Remove LLMClientInterfaceTest
This commit is contained in:
@ -46,24 +46,11 @@ HttpClient::~HttpClient()
|
||||
|
||||
void HttpClient::onSendRequest(const HttpRequest &request)
|
||||
{
|
||||
QNetworkRequest networkRequest(request.url);
|
||||
networkRequest.setTransferTimeout(300000);
|
||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
networkRequest.setRawHeader("Accept", "text/event-stream");
|
||||
networkRequest.setRawHeader("Cache-Control", "no-cache");
|
||||
networkRequest.setRawHeader("Connection", "keep-alive");
|
||||
|
||||
if (request.headers.has_value()) {
|
||||
for (const auto &[headername, value] : request.headers->asKeyValueRange()) {
|
||||
networkRequest.setRawHeader(headername.toUtf8(), value.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
QJsonDocument doc(request.payload);
|
||||
LOG_MESSAGE(QString("HttpClient: Sending POST to %1").arg(request.url.toString()));
|
||||
LOG_MESSAGE(QString("HttpClient: data: %1").arg(doc.toJson(QJsonDocument::Indented)));
|
||||
|
||||
QNetworkReply *reply = m_manager->post(networkRequest, doc.toJson(QJsonDocument::Compact));
|
||||
QNetworkReply *reply
|
||||
= m_manager->post(request.networkRequest, doc.toJson(QJsonDocument::Compact));
|
||||
addActiveRequest(reply, request.requestId);
|
||||
|
||||
connect(reply, &QNetworkReply::readyRead, this, &HttpClient::onReadyRead);
|
||||
|
Reference in New Issue
Block a user