mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-03-31 09:52:44 -04:00
feat: Rename old llmcore module to pluginllmcore
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
|
||||
#include "OpenAICompatProvider.hpp"
|
||||
|
||||
#include "llmcore/ValidationUtils.hpp"
|
||||
#include "pluginllmcore/ValidationUtils.hpp"
|
||||
#include "logger/Logger.hpp"
|
||||
#include "settings/ChatAssistantSettings.hpp"
|
||||
#include "settings/CodeCompletionSettings.hpp"
|
||||
@ -35,7 +35,7 @@
|
||||
namespace QodeAssist::Providers {
|
||||
|
||||
OpenAICompatProvider::OpenAICompatProvider(QObject *parent)
|
||||
: LLMCore::Provider(parent)
|
||||
: PluginLLMCore::Provider(parent)
|
||||
, m_toolsManager(new Tools::ToolsManager(this))
|
||||
{
|
||||
connect(
|
||||
@ -72,9 +72,9 @@ bool OpenAICompatProvider::supportsModelListing() const
|
||||
|
||||
void OpenAICompatProvider::prepareRequest(
|
||||
QJsonObject &request,
|
||||
LLMCore::PromptTemplate *prompt,
|
||||
LLMCore::ContextData context,
|
||||
LLMCore::RequestType type,
|
||||
PluginLLMCore::PromptTemplate *prompt,
|
||||
PluginLLMCore::ContextData context,
|
||||
PluginLLMCore::RequestType type,
|
||||
bool isToolsEnabled,
|
||||
bool isThinkingEnabled)
|
||||
{
|
||||
@ -98,22 +98,22 @@ void OpenAICompatProvider::prepareRequest(
|
||||
request["presence_penalty"] = settings.presencePenalty();
|
||||
};
|
||||
|
||||
if (type == LLMCore::RequestType::CodeCompletion) {
|
||||
if (type == PluginLLMCore::RequestType::CodeCompletion) {
|
||||
applyModelParams(Settings::codeCompletionSettings());
|
||||
} else if (type == LLMCore::RequestType::QuickRefactoring) {
|
||||
} else if (type == PluginLLMCore::RequestType::QuickRefactoring) {
|
||||
applyModelParams(Settings::quickRefactorSettings());
|
||||
} else {
|
||||
applyModelParams(Settings::chatAssistantSettings());
|
||||
}
|
||||
|
||||
if (isToolsEnabled) {
|
||||
LLMCore::RunToolsFilter filter = LLMCore::RunToolsFilter::ALL;
|
||||
if (type == LLMCore::RequestType::QuickRefactoring) {
|
||||
filter = LLMCore::RunToolsFilter::OnlyRead;
|
||||
PluginLLMCore::RunToolsFilter filter = PluginLLMCore::RunToolsFilter::ALL;
|
||||
if (type == PluginLLMCore::RequestType::QuickRefactoring) {
|
||||
filter = PluginLLMCore::RunToolsFilter::OnlyRead;
|
||||
}
|
||||
|
||||
auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
|
||||
LLMCore::ToolSchemaFormat::OpenAI, filter);
|
||||
PluginLLMCore::ToolSchemaFormat::OpenAI, filter);
|
||||
if (!toolsDefinitions.isEmpty()) {
|
||||
request["tools"] = toolsDefinitions;
|
||||
LOG_MESSAGE(
|
||||
@ -128,7 +128,7 @@ QFuture<QList<QString>> OpenAICompatProvider::getInstalledModels(const QString &
|
||||
}
|
||||
|
||||
QList<QString> OpenAICompatProvider::validateRequest(
|
||||
const QJsonObject &request, LLMCore::TemplateType type)
|
||||
const QJsonObject &request, PluginLLMCore::TemplateType type)
|
||||
{
|
||||
const auto templateReq = QJsonObject{
|
||||
{"model", {}},
|
||||
@ -143,7 +143,7 @@ QList<QString> OpenAICompatProvider::validateRequest(
|
||||
{"stream", {}},
|
||||
{"tools", {}}};
|
||||
|
||||
return LLMCore::ValidationUtils::validateRequestFields(request, templateReq);
|
||||
return PluginLLMCore::ValidationUtils::validateRequestFields(request, templateReq);
|
||||
}
|
||||
|
||||
QString OpenAICompatProvider::apiKey() const
|
||||
@ -160,13 +160,13 @@ void OpenAICompatProvider::prepareNetworkRequest(QNetworkRequest &networkRequest
|
||||
}
|
||||
}
|
||||
|
||||
LLMCore::ProviderID OpenAICompatProvider::providerID() const
|
||||
PluginLLMCore::ProviderID OpenAICompatProvider::providerID() const
|
||||
{
|
||||
return LLMCore::ProviderID::OpenAICompatible;
|
||||
return PluginLLMCore::ProviderID::OpenAICompatible;
|
||||
}
|
||||
|
||||
void OpenAICompatProvider::sendRequest(
|
||||
const LLMCore::RequestID &requestId, const QUrl &url, const QJsonObject &payload)
|
||||
const PluginLLMCore::RequestID &requestId, const QUrl &url, const QJsonObject &payload)
|
||||
{
|
||||
if (!m_messages.contains(requestId)) {
|
||||
m_dataBuffers[requestId].clear();
|
||||
@ -194,17 +194,17 @@ bool OpenAICompatProvider::supportImage() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenAICompatProvider::cancelRequest(const LLMCore::RequestID &requestId)
|
||||
void OpenAICompatProvider::cancelRequest(const PluginLLMCore::RequestID &requestId)
|
||||
{
|
||||
LOG_MESSAGE(QString("OpenAICompatProvider: Cancelling request %1").arg(requestId));
|
||||
LLMCore::Provider::cancelRequest(requestId);
|
||||
PluginLLMCore::Provider::cancelRequest(requestId);
|
||||
cleanupRequest(requestId);
|
||||
}
|
||||
|
||||
void OpenAICompatProvider::onDataReceived(
|
||||
const QodeAssist::LLMCore::RequestID &requestId, const QByteArray &data)
|
||||
const QodeAssist::PluginLLMCore::RequestID &requestId, const QByteArray &data)
|
||||
{
|
||||
LLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
PluginLLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
QStringList lines = buffers.rawStreamBuffer.processData(data);
|
||||
|
||||
for (const QString &line : lines) {
|
||||
@ -221,7 +221,7 @@ void OpenAICompatProvider::onDataReceived(
|
||||
}
|
||||
|
||||
void OpenAICompatProvider::onRequestFinished(
|
||||
const QodeAssist::LLMCore::RequestID &requestId, std::optional<QString> error)
|
||||
const QodeAssist::PluginLLMCore::RequestID &requestId, std::optional<QString> error)
|
||||
{
|
||||
if (error) {
|
||||
LOG_MESSAGE(QString("OpenAICompatProvider request %1 failed: %2").arg(requestId, *error));
|
||||
@ -232,7 +232,7 @@ void OpenAICompatProvider::onRequestFinished(
|
||||
|
||||
if (m_messages.contains(requestId)) {
|
||||
OpenAIMessage *message = m_messages[requestId];
|
||||
if (message->state() == LLMCore::MessageState::RequiresToolExecution) {
|
||||
if (message->state() == PluginLLMCore::MessageState::RequiresToolExecution) {
|
||||
LOG_MESSAGE(QString("Waiting for tools to complete for %1").arg(requestId));
|
||||
m_dataBuffers.remove(requestId);
|
||||
return;
|
||||
@ -240,7 +240,7 @@ void OpenAICompatProvider::onRequestFinished(
|
||||
}
|
||||
|
||||
if (m_dataBuffers.contains(requestId)) {
|
||||
const LLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
const PluginLLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
if (!buffers.responseContent.isEmpty()) {
|
||||
LOG_MESSAGE(QString("Emitting full response for %1").arg(requestId));
|
||||
emit fullResponseReceived(requestId, buffers.responseContent);
|
||||
@ -317,7 +317,7 @@ void OpenAICompatProvider::processStreamChunk(const QString &requestId, const QJ
|
||||
}
|
||||
} else if (
|
||||
m_dataBuffers.contains(requestId)
|
||||
&& message->state() == LLMCore::MessageState::RequiresToolExecution) {
|
||||
&& message->state() == PluginLLMCore::MessageState::RequiresToolExecution) {
|
||||
message->startNewContinuation();
|
||||
emit continuationStarted(requestId);
|
||||
LOG_MESSAGE(QString("Cleared message state for continuation request %1").arg(requestId));
|
||||
@ -327,7 +327,7 @@ void OpenAICompatProvider::processStreamChunk(const QString &requestId, const QJ
|
||||
QString content = delta["content"].toString();
|
||||
message->handleContentDelta(content);
|
||||
|
||||
LLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
PluginLLMCore::DataBuffers &buffers = m_dataBuffers[requestId];
|
||||
buffers.responseContent += content;
|
||||
emit partialResponseReceived(requestId, content);
|
||||
}
|
||||
@ -372,7 +372,7 @@ void OpenAICompatProvider::handleMessageComplete(const QString &requestId)
|
||||
|
||||
OpenAIMessage *message = m_messages[requestId];
|
||||
|
||||
if (message->state() == LLMCore::MessageState::RequiresToolExecution) {
|
||||
if (message->state() == PluginLLMCore::MessageState::RequiresToolExecution) {
|
||||
LOG_MESSAGE(QString("OpenAICompat message requires tool execution for %1").arg(requestId));
|
||||
|
||||
auto toolUseContent = message->getCurrentToolUseContent();
|
||||
@ -394,7 +394,7 @@ void OpenAICompatProvider::handleMessageComplete(const QString &requestId)
|
||||
}
|
||||
}
|
||||
|
||||
void OpenAICompatProvider::cleanupRequest(const LLMCore::RequestID &requestId)
|
||||
void OpenAICompatProvider::cleanupRequest(const PluginLLMCore::RequestID &requestId)
|
||||
{
|
||||
LOG_MESSAGE(QString("Cleaning up OpenAICompat request %1").arg(requestId));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user