mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-11-22 02:22:44 -05: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:
@ -21,9 +21,11 @@
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <QNetworkRequest>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "ContextData.hpp"
|
||||
#include "HttpClient.hpp"
|
||||
#include "PromptTemplate.hpp"
|
||||
#include "RequestType.hpp"
|
||||
|
||||
@ -32,9 +34,12 @@ class QJsonObject;
|
||||
|
||||
namespace QodeAssist::LLMCore {
|
||||
|
||||
class Provider
|
||||
class Provider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Provider(QObject *parent = nullptr);
|
||||
|
||||
virtual ~Provider() = default;
|
||||
|
||||
virtual QString name() const = 0;
|
||||
@ -48,12 +53,28 @@ public:
|
||||
LLMCore::ContextData context,
|
||||
LLMCore::RequestType type)
|
||||
= 0;
|
||||
virtual bool handleResponse(QNetworkReply *reply, QString &accumulatedResponse) = 0;
|
||||
virtual QList<QString> getInstalledModels(const QString &url) = 0;
|
||||
virtual QList<QString> validateRequest(const QJsonObject &request, TemplateType type) = 0;
|
||||
virtual QString apiKey() const = 0;
|
||||
virtual void prepareNetworkRequest(QNetworkRequest &networkRequest) const = 0;
|
||||
virtual ProviderID providerID() const = 0;
|
||||
|
||||
virtual void sendRequest(const QString &requestId, const QUrl &url, const QJsonObject &payload)
|
||||
= 0;
|
||||
|
||||
HttpClient *httpClient() const;
|
||||
|
||||
public slots:
|
||||
virtual void onDataReceived(const QString &requestId, const QByteArray &data) = 0;
|
||||
virtual void onRequestFinished(const QString &requestId, bool success, const QString &error) = 0;
|
||||
|
||||
signals:
|
||||
void partialResponseReceived(const QString &requestId, const QString &partialText);
|
||||
void fullResponseReceived(const QString &requestId, const QString &fullText);
|
||||
void requestFailed(const QString &requestId, const QString &error);
|
||||
|
||||
private:
|
||||
std::unique_ptr<HttpClient> m_httpClient;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::LLMCore
|
||||
|
||||
Reference in New Issue
Block a user