mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
fix: Add checking model support for tool calling (#350)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user