12#include <agents-cpp/workflow.h>
48 std::shared_ptr<LLMInterface>
llm;
71 std::shared_ptr<LLMInterface>
llm =
nullptr,
72 std::shared_ptr<Workflow>
workflow =
nullptr,
84 std::shared_ptr<AgentContext> context,
85 const String& router_prompt_template =
""
104 const String& description,
105 const String& prompt_template =
"",
106 std::shared_ptr<LLMInterface> handler_llm =
nullptr,
107 std::shared_ptr<Workflow> workflow =
nullptr
160 const String& description,
168 String router_prompt_template_;
173 std::map<String, RouteHandler> route_handlers_;
178 std::optional<RouteHandler> default_handler_;
184 String createRouterSystemPrompt()
const;
void addRouteHandler(const String &name, const String &description, const String &prompt_template="", std::shared_ptr< LLMInterface > handler_llm=nullptr, std::shared_ptr< Workflow > workflow=nullptr)
Add a route handler with basic params.
void addRoute(const String &name, const String &description, std::function< JsonObject(const String &, const JsonObject &)> handler)
Add a route with a direct function handler.
void setDefaultHandler(const RouteHandler &handler)
Set default handler for unknown routes.
JsonObject getRoutesSchema() const
Define available routes as a JSON schema.
RoutingWorkflow(std::shared_ptr< AgentContext > context, const String &router_prompt_template="")
Constructor with context and router prompt template.
void init()
Initialize the workflow.
void setDefaultRoute(std::function< JsonObject(const String &, const JsonObject &)> handler)
Set default route.
void setRouterPrompt(const String &prompt_template)
Set the router prompt.
Definition routing_workflow.h:132
JsonObject run(const String &input) override
Execute the workflow with input.
void addRouteHandler(const RouteHandler &handler)
Add a route handler.
void setRouterPromptTemplate(const String &prompt_template)
Set the router prompt template.
Workflow(std::shared_ptr< AgentContext > context)
Constructor.
Worflows Namespace.
Definition workflow.h:22
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
Handler definition for a route.
Definition routing_workflow.h:32
std::shared_ptr< Workflow > workflow
The workflow of the route handler.
Definition routing_workflow.h:52
std::function< JsonObject(const String &, const JsonObject &)> handler
The handler of the route handler.
Definition routing_workflow.h:56
RouteHandler(const String &name, const String &description, const String &prompt_template="", std::shared_ptr< LLMInterface > llm=nullptr, std::shared_ptr< Workflow > workflow=nullptr, std::function< JsonObject(const String &, const JsonObject &)> handler=nullptr)
Constructor.
Definition routing_workflow.h:67
String name
The name of the route handler.
Definition routing_workflow.h:36
String prompt_template
The prompt template of the route handler.
Definition routing_workflow.h:44
String description
The description of the route handler.
Definition routing_workflow.h:40
std::shared_ptr< LLMInterface > llm
The LLM of the route handler.
Definition routing_workflow.h:48