mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-06-14 10:19:16 -04:00
refactor: Add agents for providers
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "JsonPromptTemplate.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHash>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
|
||||
@@ -42,6 +43,16 @@ nlohmann::json buildContextJson(const ContextData &context)
|
||||
ctx["files_metadata"] = std::move(files);
|
||||
}
|
||||
|
||||
// tool_result blocks only carry the tool_use_id; resolve the originating
|
||||
// tool name so templates (e.g. Google's functionResponse.name) can emit it.
|
||||
QHash<QString, QString> toolNameById;
|
||||
if (context.history) {
|
||||
for (const auto &msg : context.history.value())
|
||||
for (const auto &b : msg.blocks)
|
||||
if (b.kind == ContentBlockEntry::Kind::ToolUse)
|
||||
toolNameById.insert(b.toolUseId, b.toolName);
|
||||
}
|
||||
|
||||
nlohmann::json history = nlohmann::json::array();
|
||||
if (context.history) {
|
||||
for (const auto &msg : context.history.value()) {
|
||||
@@ -93,6 +104,7 @@ nlohmann::json buildContextJson(const ContextData &context)
|
||||
bj["type"] = "tool_result";
|
||||
bj["tool_use_id"] = b.toolUseId.toStdString();
|
||||
bj["content"] = b.result.toStdString();
|
||||
bj["name"] = toolNameById.value(b.toolUseId).toStdString();
|
||||
break;
|
||||
case ContentBlockEntry::Kind::Image:
|
||||
bj["type"] = "image";
|
||||
|
||||
Reference in New Issue
Block a user