58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#ifndef OPENMANUS_AGENT_BASE_H
|
|
#define OPENMANUS_AGENT_BASE_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "tool_collection.h"
|
|
#include "mcp/include/mcp_message.h"
|
|
|
|
namespace openmanus {
|
|
|
|
/**
|
|
* @class AgentBase
|
|
* @brief 代理的基类,定义了所有代理的基本接口
|
|
*/
|
|
class AgentBase : public std::enable_shared_from_this<AgentBase> {
|
|
public:
|
|
AgentBase(const std::string& name, const std::string& description);
|
|
virtual ~AgentBase() = default;
|
|
|
|
/**
|
|
* @brief 运行代理,处理用户输入的提示
|
|
* @param prompt 用户输入的提示
|
|
* @return 处理结果
|
|
*/
|
|
virtual std::string run(const std::string& prompt) = 0;
|
|
|
|
/**
|
|
* @brief 执行工具调用
|
|
* @param tool_name 工具名称
|
|
* @param params 工具参数
|
|
* @return 执行结果
|
|
*/
|
|
virtual mcp::json executeToolCall(const std::string& tool_name, const mcp::json& params);
|
|
|
|
/**
|
|
* @brief 获取代理名称
|
|
* @return 代理名称
|
|
*/
|
|
std::string getName() const { return name_; }
|
|
|
|
/**
|
|
* @brief 获取代理描述
|
|
* @return 代理描述
|
|
*/
|
|
std::string getDescription() const { return description_; }
|
|
|
|
protected:
|
|
std::string name_;
|
|
std::string description_;
|
|
std::string system_prompt_;
|
|
std::string next_step_prompt_;
|
|
std::unique_ptr<ToolCollection> available_tools_;
|
|
};
|
|
|
|
} // namespace openmanus
|
|
|
|
#endif // OPENMANUS_AGENT_BASE_H
|