70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
#ifndef OPENMANUS_TOOL_CALL_H
|
|
#define OPENMANUS_TOOL_CALL_H
|
|
|
|
#include <string>
|
|
#include "mcp/include/mcp_message.h"
|
|
|
|
namespace openmanus {
|
|
|
|
/**
|
|
* @class ToolCall
|
|
* @brief 工具调用类,表示一次工具调用
|
|
*/
|
|
class ToolCall {
|
|
public:
|
|
ToolCall(const std::string& id, const std::string& name, const mcp::json& params);
|
|
~ToolCall() = default;
|
|
|
|
/**
|
|
* @brief 获取工具调用ID
|
|
* @return 工具调用ID
|
|
*/
|
|
std::string getId() const { return id_; }
|
|
|
|
/**
|
|
* @brief 获取工具名称
|
|
* @return 工具名称
|
|
*/
|
|
std::string getName() const { return name_; }
|
|
|
|
/**
|
|
* @brief 获取工具参数
|
|
* @return 工具参数
|
|
*/
|
|
mcp::json getParams() const { return params_; }
|
|
|
|
/**
|
|
* @brief 设置执行结果
|
|
* @param result 执行结果
|
|
*/
|
|
void setResult(const std::string& result) { result_ = result; }
|
|
|
|
/**
|
|
* @brief 获取执行结果
|
|
* @return 执行结果
|
|
*/
|
|
std::string getResult() const { return result_; }
|
|
|
|
/**
|
|
* @brief 从JSON对象创建工具调用
|
|
* @param json JSON对象
|
|
* @return 工具调用对象
|
|
*/
|
|
static ToolCall fromJson(const mcp::json& json);
|
|
|
|
/**
|
|
* @brief 转换为JSON对象
|
|
* @return JSON对象
|
|
*/
|
|
mcp::json toJson() const;
|
|
|
|
private:
|
|
std::string id_; // 工具调用ID
|
|
std::string name_; // 工具名称
|
|
mcp::json params_; // 工具参数
|
|
std::string result_; // 执行结果
|
|
};
|
|
|
|
} // namespace openmanus
|
|
|
|
#endif // OPENMANUS_TOOL_CALL_H
|