51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#ifndef HUMANUS_FLOW_BASE_H
|
|
#define HUMANUS_FLOW_BASE_H
|
|
|
|
#include "../agent/base.h"
|
|
|
|
namespace humanus {
|
|
|
|
enum FlowType {
|
|
PLANING = 0
|
|
};
|
|
|
|
const std::map<FlowType, std::string> FLOW_TYPE_MAP = {
|
|
{PLANING, "planning"}
|
|
};
|
|
|
|
// Base class for execution flows supporting multiple agents
|
|
struct BaseFlow {
|
|
std::map<std::string, std::shared_ptr<BaseAgent>> agents;
|
|
std::vector<std::shared_ptr<BaseTool>> tools;
|
|
std::string primary_agent_key;
|
|
|
|
BaseFlow(const std::map<std::string, std::shared_ptr<BaseAgent>>& agents = {}, const std::vector<std::shared_ptr<BaseTool>>& tools = {}, const std::string& primary_agent_key = "") : agents(agents), tools(tools), primary_agent_key(primary_agent_key) {
|
|
// If primary agent not specified, use first agent
|
|
if (primary_agent_key.empty() && !agents.empty()) {
|
|
primary_agent_key = agents.begin()->first;
|
|
}
|
|
}
|
|
|
|
// Get the primary agent for the flow
|
|
std::shared_ptr<BaseAgent> primary_agent() const {
|
|
return agents.at(primary_agent_key);
|
|
}
|
|
|
|
// Get a specific agent by key
|
|
std::shared_ptr<BaseAgent> get_agent(const std::string& key) const {
|
|
return agents.at(key);
|
|
}
|
|
|
|
// Add a new agent to the flow
|
|
void add_agent(const std::string& key, const std::shared_ptr<BaseAgent>& agent) {
|
|
agents[key] = agent;
|
|
}
|
|
|
|
// Execute the flow with the given input
|
|
virtual std::string execute(const std::string& input) = 0;
|
|
};
|
|
|
|
}
|
|
|
|
#endif // HUMANUS_FLOW_BASE_H
|