mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
Update LLMQore to v0.0.4 (#339)
This commit is contained in:
@@ -19,8 +19,14 @@
|
||||
|
||||
#include "Provider.hpp"
|
||||
|
||||
#include <LLMCore/BaseClient.hpp>
|
||||
#include <LLMCore/ToolsManager.hpp>
|
||||
#include <LLMQore/BaseClient.hpp>
|
||||
#include <LLMQore/LlamaCppClient.hpp>
|
||||
#include <LLMQore/MistralClient.hpp>
|
||||
#include <LLMQore/OpenAIClient.hpp>
|
||||
#include <LLMQore/OpenAIResponsesClient.hpp>
|
||||
#include <LLMQore/ToolsManager.hpp>
|
||||
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include <Logger.hpp>
|
||||
|
||||
@@ -30,19 +36,21 @@ Provider::Provider(QObject *parent)
|
||||
: QObject(parent)
|
||||
{}
|
||||
|
||||
RequestID Provider::sendRequest(const QUrl &url, const QJsonObject &payload)
|
||||
RequestID Provider::sendRequest(
|
||||
const QUrl &url, const QJsonObject &payload, const QString &endpoint)
|
||||
{
|
||||
auto *c = client();
|
||||
|
||||
QUrl baseUrl(url);
|
||||
baseUrl.setPath("");
|
||||
c->setUrl(baseUrl.toString());
|
||||
c->setUrl(url.toString());
|
||||
c->setApiKey(apiKey());
|
||||
|
||||
auto requestId = c->sendMessage(payload);
|
||||
auto requestId = c->sendMessage(payload, endpoint);
|
||||
|
||||
LOG_MESSAGE(
|
||||
QString("%1: Sending request %2 to %3").arg(name(), requestId, url.toString()));
|
||||
QString("%1: Sending request %2 to %3%4").arg(name(), requestId, url.toString(), endpoint));
|
||||
LOG_MESSAGE(
|
||||
QString("%1: Payload:\n%2")
|
||||
.arg(name(), QString::fromUtf8(QJsonDocument(payload).toJson(QJsonDocument::Indented))));
|
||||
|
||||
return requestId;
|
||||
}
|
||||
@@ -53,9 +61,35 @@ void Provider::cancelRequest(const RequestID &requestId)
|
||||
client()->cancelRequest(requestId);
|
||||
}
|
||||
|
||||
::LLMCore::ToolsManager *Provider::toolsManager() const
|
||||
::LLMQore::ToolsManager *Provider::toolsManager() const
|
||||
{
|
||||
return client()->tools();
|
||||
}
|
||||
|
||||
QString Provider::enrichErrorMessage(const QString &error) const
|
||||
{
|
||||
auto *c = client();
|
||||
|
||||
if (qobject_cast<::LLMQore::MistralClient *>(c))
|
||||
return error;
|
||||
|
||||
const bool isOpenAICompatible = qobject_cast<::LLMQore::OpenAIClient *>(c)
|
||||
|| qobject_cast<::LLMQore::OpenAIResponsesClient *>(c)
|
||||
|| qobject_cast<::LLMQore::LlamaCppClient *>(c);
|
||||
if (!isOpenAICompatible)
|
||||
return error;
|
||||
|
||||
const QString baseUrl = c->url();
|
||||
const QString path = QUrl(baseUrl).path();
|
||||
const bool hasV1Segment = path.contains("/v1/") || path.endsWith("/v1");
|
||||
if (hasV1Segment)
|
||||
return error;
|
||||
|
||||
return error
|
||||
+ tr("\n\nHint: Your base URL (%1) does not contain a '/v1' path segment. "
|
||||
"Most OpenAI-compatible servers require it (e.g., %1/v1). "
|
||||
"Try updating the URL in settings.")
|
||||
.arg(baseUrl);
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::PluginLLMCore
|
||||
|
||||
Reference in New Issue
Block a user