- 工具循环:capture_image / get_robot_status / spawn_subagent - 子代理:技能超集(run_command 带超时截断、read_file / write_file) - V4L2 摄像头抓帧:MJPEG 优先零转码,YUYV+libjpeg 回退,/dev/video* 自动探测 - 时间戳注入:system prompt 会话级当前时间 + 工具结果执行时间 - CLI:--prompt-file / --camera / --camera-device / --model / --max-turns
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
#pragma once
|
||
|
||
#include <boost/json.hpp>
|
||
|
||
#include "tools.hpp"
|
||
|
||
#include <string>
|
||
|
||
namespace json = boost::json;
|
||
|
||
struct AgentConfig {
|
||
std::string model;
|
||
std::string endpoint;
|
||
std::string api_key;
|
||
std::string camera_path; // 非空 = 模拟摄像头(读文件)
|
||
std::string camera_device; // 真实摄像头设备(默认 /dev/video0)
|
||
int max_turns = 8;
|
||
};
|
||
|
||
// 运行工具循环,直到模型给出最终回答并返回其文本。失败抛 std::runtime_error。
|
||
// log_tag 用于区分不同代理的工具日志(输出到 stderr)。
|
||
std::string run_chat_loop(const AgentConfig& cfg,
|
||
const std::string& system_prompt,
|
||
const std::string& user_question,
|
||
const ToolRegistry& registry,
|
||
const std::string& log_tag);
|
||
|
||
// 消息构造(主代理与子代理共用)
|
||
json::object user_text_msg(const std::string& text);
|
||
json::object user_image_msg(const std::string& text, const std::string& data_url);
|
||
json::object tool_result_msg(const std::string& call_id, const std::string& text);
|
||
json::value build_tools_spec(const ToolRegistry& registry);
|