mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-07-18 21:14:34 -04:00
chore: Run clang-format over the codebase (#82)
This commit is a result of the following commands: clang-format-19 --style=file -i $(git ls-files | fgrep .cpp) clang-format-19 --style=file -i $(git ls-files | fgrep .hpp)
This commit is contained in:
committed by
GitHub
parent
102bb114a1
commit
61196cae90
@ -35,8 +35,7 @@ public:
|
||||
template<typename T>
|
||||
void registerTemplate()
|
||||
{
|
||||
static_assert(std::is_base_of<PromptTemplate, T>::value,
|
||||
"T must inherit from PromptTemplate");
|
||||
static_assert(std::is_base_of<PromptTemplate, T>::value, "T must inherit from PromptTemplate");
|
||||
T *template_ptr = new T();
|
||||
QString name = template_ptr->name();
|
||||
m_fimTemplates[name] = template_ptr;
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <QMap>
|
||||
#include "Provider.hpp"
|
||||
#include <QMap>
|
||||
|
||||
namespace QodeAssist::LLMCore {
|
||||
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QUrl>
|
||||
#include "PromptTemplate.hpp"
|
||||
#include "Provider.hpp"
|
||||
#include "RequestType.hpp"
|
||||
#include <QJsonObject>
|
||||
#include <QUrl>
|
||||
|
||||
namespace QodeAssist::LLMCore {
|
||||
|
||||
|
@ -33,15 +33,16 @@ RequestHandler::RequestHandler(QObject *parent)
|
||||
void RequestHandler::sendLLMRequest(const LLMConfig &config, const QJsonObject &request)
|
||||
{
|
||||
LOG_MESSAGE(QString("Sending request to llm: \nurl: %1\nRequest body:\n%2")
|
||||
.arg(config.url.toString(),
|
||||
.arg(
|
||||
config.url.toString(),
|
||||
QString::fromUtf8(
|
||||
QJsonDocument(config.providerRequest).toJson(QJsonDocument::Indented))));
|
||||
|
||||
QNetworkRequest networkRequest(config.url);
|
||||
config.provider->prepareNetworkRequest(networkRequest);
|
||||
|
||||
QNetworkReply *reply = m_manager->post(networkRequest,
|
||||
QJsonDocument(config.providerRequest).toJson());
|
||||
QNetworkReply *reply
|
||||
= m_manager->post(networkRequest, QJsonDocument(config.providerRequest).toJson());
|
||||
if (!reply) {
|
||||
LOG_MESSAGE("Error: Failed to create network reply");
|
||||
return;
|
||||
@ -70,9 +71,8 @@ void RequestHandler::sendLLMRequest(const LLMConfig &config, const QJsonObject &
|
||||
});
|
||||
}
|
||||
|
||||
void RequestHandler::handleLLMResponse(QNetworkReply *reply,
|
||||
const QJsonObject &request,
|
||||
const LLMConfig &config)
|
||||
void RequestHandler::handleLLMResponse(
|
||||
QNetworkReply *reply, const QJsonObject &request, const LLMConfig &config)
|
||||
{
|
||||
QString &accumulatedResponse = m_accumulatedResponses[reply];
|
||||
|
||||
@ -85,8 +85,8 @@ void RequestHandler::handleLLMResponse(QNetworkReply *reply,
|
||||
}
|
||||
|
||||
if (isComplete) {
|
||||
auto cleanedCompletion = removeStopWords(accumulatedResponse,
|
||||
config.promptTemplate->stopWords());
|
||||
auto cleanedCompletion
|
||||
= removeStopWords(accumulatedResponse, config.promptTemplate->stopWords());
|
||||
|
||||
emit completionReceived(cleanedCompletion, request, true);
|
||||
}
|
||||
|
@ -37,9 +37,7 @@ public:
|
||||
explicit RequestHandler(QObject *parent = nullptr);
|
||||
|
||||
void sendLLMRequest(const LLMConfig &config, const QJsonObject &request);
|
||||
void handleLLMResponse(QNetworkReply *reply,
|
||||
const QJsonObject &request,
|
||||
const LLMConfig &config);
|
||||
void handleLLMResponse(QNetworkReply *reply, const QJsonObject &request, const LLMConfig &config);
|
||||
bool cancelRequest(const QString &id);
|
||||
|
||||
signals:
|
||||
@ -52,10 +50,11 @@ private:
|
||||
QMap<QString, QNetworkReply *> m_activeRequests;
|
||||
QMap<QNetworkReply *, QString> m_accumulatedResponses;
|
||||
|
||||
bool processSingleLineCompletion(QNetworkReply *reply,
|
||||
const QJsonObject &request,
|
||||
const QString &accumulatedResponse,
|
||||
const LLMConfig &config);
|
||||
bool processSingleLineCompletion(
|
||||
QNetworkReply *reply,
|
||||
const QJsonObject &request,
|
||||
const QString &accumulatedResponse,
|
||||
const LLMConfig &config);
|
||||
QString removeStopWords(const QStringView &completion, const QStringList &stopWords);
|
||||
void removeCodeBlockWrappers(QString &response);
|
||||
};
|
||||
|
Reference in New Issue
Block a user