🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ChatTools.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "ChatTool.hpp"
25#include <vector>
26#include <memory>
27
28AST_NAMESPACE_BEGIN
29
39{
40public:
41 ChatTools() = default;
42 ChatTools(bool initAsDefault);
43 ~ChatTools() = default;
44 ChatTools(ChatTools&&) = default;
45 ChatTools& operator=(ChatTools&&) = default;
46public:
50 std::string handleToolCall(const JsonValue& toolCall);
51
54 void addTool(std::unique_ptr<ChatTool>&& tool){tools_.push_back(std::move(tool));}
55
56 template<typename Func>
57 ChatTool* addTool(Func func)
58 {
59 ChatTool* tool = new ChatToolGeneric<Func>(func);
60 addTool(std::unique_ptr<ChatTool>(tool));
61 return tool;
62 }
63
65 void clearTools(){tools_.clear();}
66
69 JsonValue toJson() const;
70
72 bool empty() const {return tools_.empty();}
73private:
74 A_DISABLE_COPY(ChatTools);
75 std::vector<std::unique_ptr<ChatTool>> tools_;
76};
77
78
81AST_NAMESPACE_END
通用模板封装
定义 ChatTool.hpp:86
AI工具基类
定义 ChatTool.hpp:40
AI工具集合
定义 ChatTools.hpp:39
bool empty() const
检查工具集合是否为空
定义 ChatTools.hpp:72
void clearTools()
清除所有工具
定义 ChatTools.hpp:65
void addTool(std::unique_ptr< ChatTool > &&tool)
添加工具
定义 ChatTools.hpp:54
JSON 值类
定义 JsonValue.hpp:47