fix: Found and fix review mistakes

This commit is contained in:
Petr Mironychev
2026-07-02 22:26:07 +02:00
parent c070d65366
commit 35bbaa1af0
139 changed files with 2032 additions and 1573 deletions

View File

@@ -38,8 +38,8 @@ inline void applyToSystem(QJsonObject &request, const QJsonObject &cacheControl)
if (sys.isString()) {
const QString text = sys.toString();
if (!text.isEmpty()) {
request["system"] = QJsonArray{QJsonObject{
{"type", "text"}, {"text", text}, {"cache_control", cacheControl}}};
request["system"] = QJsonArray{
QJsonObject{{"type", "text"}, {"text", text}, {"cache_control", cacheControl}}};
}
} else if (sys.isArray()) {
QJsonArray blocks = sys.toArray();

View File

@@ -73,8 +73,6 @@ QString GenericProvider::modelsEndpoint(const QString &url) const
RequestID GenericProvider::sendRequest(
const QUrl &url, const QJsonObject &payload, const QString &endpoint)
{
// Gemini carries the model in the URL and rejects unknown body fields, so
// the model/stream keys injected by the generic pipeline must be dropped.
if (m_id == ProviderID::GoogleAI) {
QJsonObject cleaned = payload;
cleaned.remove("model");
@@ -98,9 +96,7 @@ GenericProvider::ClientFactory makeFactory()
void registerBuiltinProviders()
{
const auto reg = [](const QString &api,
ProviderID id,
GenericProvider::ClientFactory factory) {
const auto reg = [](const QString &api, ProviderID id, GenericProvider::ClientFactory factory) {
ProviderFactory::registerType(api, [=](QObject *parent) -> Provider * {
return new GenericProvider(api, id, factory, parent);
});
@@ -109,21 +105,23 @@ void registerBuiltinProviders()
reg("Claude", ProviderID::Claude, makeFactory<::LLMQore::ClaudeClient>());
reg("Google AI", ProviderID::GoogleAI, makeFactory<::LLMQore::GoogleAIClient>());
reg("llama.cpp", ProviderID::LlamaCpp, makeFactory<::LLMQore::LlamaCppClient>());
reg("LM Studio (Chat Completions)", ProviderID::LMStudio,
reg("LM Studio (Chat Completions)",
ProviderID::LMStudio,
makeFactory<::LLMQore::OpenAIClient>());
reg("LM Studio (Responses API)", ProviderID::OpenAIResponses,
reg("LM Studio (Responses API)",
ProviderID::OpenAIResponses,
makeFactory<::LLMQore::OpenAIResponsesClient>());
reg("Mistral AI", ProviderID::MistralAI, makeFactory<::LLMQore::MistralClient>());
reg("Codestral", ProviderID::MistralAI, makeFactory<::LLMQore::MistralClient>());
reg("Ollama (Native)", ProviderID::Ollama, makeFactory<::LLMQore::OllamaClient>());
reg("Ollama (OpenAI-compatible)", ProviderID::OpenAICompatible,
reg("Ollama (OpenAI-compatible)",
ProviderID::OpenAICompatible,
makeFactory<::LLMQore::OpenAIClient>());
reg("OpenAI (Chat Completions)", ProviderID::OpenAI,
makeFactory<::LLMQore::OpenAIClient>());
reg("OpenAI (Responses API)", ProviderID::OpenAIResponses,
reg("OpenAI (Chat Completions)", ProviderID::OpenAI, makeFactory<::LLMQore::OpenAIClient>());
reg("OpenAI (Responses API)",
ProviderID::OpenAIResponses,
makeFactory<::LLMQore::OpenAIResponsesClient>());
reg("OpenAI Compatible", ProviderID::OpenAICompatible,
makeFactory<::LLMQore::OpenAIClient>());
reg("OpenAI Compatible", ProviderID::OpenAICompatible, makeFactory<::LLMQore::OpenAIClient>());
reg("OpenRouter", ProviderID::OpenRouter, makeFactory<::LLMQore::OpenAIClient>());
}

View File

@@ -14,10 +14,6 @@ class BaseClient;
namespace QodeAssist::Providers {
// A configuration-driven provider: it owns an LLMQore client and exposes a
// fixed identity. Concrete behaviour (request shape) comes from the agent's
// prompt template via Provider::prepareRequest, so a single class covers
// every client_api by varying the client factory + metadata.
class GenericProvider : public Provider
{
Q_OBJECT
@@ -25,10 +21,7 @@ public:
using ClientFactory = std::function<::LLMQore::BaseClient *(QObject *)>;
GenericProvider(
QString name,
ProviderID id,
const ClientFactory &clientFactory,
QObject *parent = nullptr);
QString name, ProviderID id, const ClientFactory &clientFactory, QObject *parent = nullptr);
QString name() const override;
QFuture<QList<QString>> getInstalledModels(const QString &url) override;
@@ -46,8 +39,6 @@ private:
::LLMQore::BaseClient *m_client;
};
// Registers every built-in client_api into ProviderFactory. Must be called once
// at plugin startup before any agent/session is created.
void registerBuiltinProviders();
} // namespace QodeAssist::Providers

View File

@@ -40,14 +40,13 @@ bool Provider::prepareRequest(
return fail(QString("Provider '%1': null template").arg(name()));
if (!prompt->isSupportProvider(providerID())) {
return fail(QString("Template '%1' doesn't support provider '%2'")
.arg(prompt->name(), name()));
return fail(
QString("Template '%1' doesn't support provider '%2'").arg(prompt->name(), name()));
}
if (!prompt->buildFullRequest(request, context)) {
return fail(
QString("Provider '%1': template '%2' failed to build request (see log)")
.arg(name(), prompt->name()));
return fail(QString("Provider '%1': template '%2' failed to build request (see log)")
.arg(name(), prompt->name()));
}
if (isToolsEnabled) {
@@ -58,18 +57,23 @@ bool Provider::prepareRequest(
}
if (m_promptCachingEnabled)
ClaudeCacheControl::apply(
request, m_promptCachingExtendedTtl, m_promptCacheBreakpoints);
ClaudeCacheControl::apply(request, m_promptCachingExtendedTtl, m_promptCacheBreakpoints);
return true;
}
void Provider::setPromptCaching(bool enabled, bool extendedTtl, const QStringList &breakpoints)
{
auto *claude = qobject_cast<::LLMQore::ClaudeClient *>(client());
if (enabled && !claude) {
LOG_MESSAGE(
QString("%1: cache_prompt is only supported by Claude providers, ignoring").arg(name()));
enabled = false;
}
m_promptCachingEnabled = enabled;
m_promptCachingExtendedTtl = enabled && extendedTtl;
m_promptCacheBreakpoints = breakpoints;
if (auto *claude = qobject_cast<::LLMQore::ClaudeClient *>(client()))
if (claude)
claude->setUseExtendedCacheTTL(m_promptCachingExtendedTtl);
}

View File

@@ -8,14 +8,12 @@
#include <QObject>
#include <QString>
#include <QStringList>
#include <utils/environment.h>
#include "ContextData.hpp"
#include "ProviderID.hpp"
#include "LLMQore/BaseClient.hpp"
namespace LLMQore {
class BaseClient;
class ToolsManager;
}
@@ -63,8 +61,7 @@ public:
void cancelRequest(const RequestID &requestId);
::LLMQore::ToolsManager *toolsManager() const;
void setPromptCaching(
bool enabled, bool extendedTtl, const QStringList &breakpoints = {});
void setPromptCaching(bool enabled, bool extendedTtl, const QStringList &breakpoints = {});
private:
QString m_url;