fix: Add checking model support for tool calling (#350)

This commit is contained in:
Petr Mironychev
2026-05-17 21:27:18 +02:00
committed by GitHub
parent 6addcedfd0
commit 74c899c8c3
16 changed files with 334 additions and 18 deletions

View File

@@ -6,6 +6,7 @@
#include "pluginllmcore/PromptTemplate.hpp"
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
namespace QodeAssist::Templates {
@@ -22,6 +23,8 @@ public:
QStringList stopWords() const override { return {}; }
bool supportsToolHistory() const override { return true; }
void prepareRequest(
QJsonObject &request, const PluginLLMCore::ContextData &context) const override
{
@@ -39,6 +42,30 @@ public:
continue;
}
if (!msg.toolCalls.isEmpty()) {
if (!msg.content.isEmpty()) {
input.append(QJsonObject{{"role", "assistant"}, {"content", msg.content}});
}
for (const auto &call : msg.toolCalls) {
input.append(QJsonObject{
{"type", "function_call"},
{"call_id", call.id},
{"name", call.name},
{"arguments",
QString::fromUtf8(
QJsonDocument(call.arguments).toJson(QJsonDocument::Compact))}});
}
continue;
}
if (msg.role == "tool") {
input.append(QJsonObject{
{"type", "function_call_output"},
{"call_id", msg.toolCallId},
{"output", msg.content}});
continue;
}
QJsonObject message;
message["role"] = msg.role;