77 lines
1.6 KiB
C++
77 lines
1.6 KiB
C++
#ifndef OPENMANUS_FLOW_BASE_FLOW_H
|
|
#define OPENMANUS_FLOW_BASE_FLOW_H
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include "../agent_base.h"
|
|
|
|
namespace openmanus {
|
|
|
|
/**
|
|
* @enum FlowType
|
|
* @brief 流程类型枚举
|
|
*/
|
|
enum class FlowType {
|
|
PLANNING
|
|
};
|
|
|
|
/**
|
|
* @class BaseFlow
|
|
* @brief 执行流程的基类,支持多个代理
|
|
*/
|
|
class BaseFlow {
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param agent 主要代理
|
|
*/
|
|
BaseFlow(std::shared_ptr<AgentBase> agent);
|
|
|
|
/**
|
|
* @brief 构造函数
|
|
* @param agents 多个代理
|
|
*/
|
|
BaseFlow(const std::vector<std::shared_ptr<AgentBase>>& agents);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~BaseFlow() = default;
|
|
|
|
/**
|
|
* @brief 执行流程
|
|
* @param input_text 输入文本
|
|
* @return 执行结果
|
|
*/
|
|
virtual std::string execute(const std::string& input_text) = 0;
|
|
|
|
/**
|
|
* @brief 获取主要代理
|
|
* @return 主要代理
|
|
*/
|
|
std::shared_ptr<AgentBase> getPrimaryAgent() const;
|
|
|
|
/**
|
|
* @brief 获取指定代理
|
|
* @param key 代理键
|
|
* @return 代理
|
|
*/
|
|
std::shared_ptr<AgentBase> getAgent(const std::string& key) const;
|
|
|
|
/**
|
|
* @brief 添加代理
|
|
* @param key 代理键
|
|
* @param agent 代理
|
|
*/
|
|
void addAgent(const std::string& key, std::shared_ptr<AgentBase> agent);
|
|
|
|
protected:
|
|
std::unordered_map<std::string, std::shared_ptr<AgentBase>> agents_;
|
|
std::string primary_agent_key_;
|
|
};
|
|
|
|
} // namespace openmanus
|
|
|
|
#endif // OPENMANUS_FLOW_BASE_FLOW_H
|