|
Agents 1.4.0
Edge AI Agents SDK
|
Routing workflow using the actor model. More...
#include <routing_workflow.h>
Classes | |
| struct | RouteHandler |
| Handler definition for a route. More... | |
Public Member Functions | |
| RoutingWorkflow (std::shared_ptr< Context > context, const std::string &router_prompt_template="") | |
| Constructor with context and router prompt template. | |
| void | addRouteHandler (const RouteHandler &handler) |
| Add a route handler. | |
| void | addRouteHandler (const std::string &name, const std::string &description, const std::string &prompt_template="", std::shared_ptr< LLMInterface > handler_llm=nullptr, std::shared_ptr< Workflow > workflow=nullptr) |
| Add a route handler with basic params. | |
| void | init () |
| Initialize the workflow. | |
| JsonObject | run (const std::string &input) override |
| Execute the workflow with input. | |
| void | setRouterPromptTemplate (const std::string &prompt_template) |
| Set the router prompt template. | |
| void | setRouterPrompt (const std::string &prompt_template) |
| Set the router prompt. | |
| void | setDefaultHandler (const RouteHandler &handler) |
| Set default handler for unknown routes. | |
| void | setDefaultRoute (std::function< JsonObject(const std::string &, const JsonObject &)> handler) |
| Set default route. | |
| JsonObject | getRoutesSchema () const |
| Define available routes as a JSON schema. | |
| void | addRoute (const std::string &name, const std::string &description, std::function< JsonObject(const std::string &, const JsonObject &)> handler) |
| Add a route with a direct function handler. | |
| virtual void | runAsync (const std::string &input, std::function< void(const JsonObject &)> callback) |
| Run the workflow with a user input asynchronously. | |
| std::shared_ptr< Context > | getContext () const |
| Get the workflow's context. | |
| void | setStepCallback (std::function< void(const std::string &, const JsonObject &)> callback) |
| Set a callback for intermediate steps. | |
| void | setMaxSteps (int max_steps) |
| Set maximum number of steps. | |
| int | getMaxSteps () const |
| Get maximum number of steps. | |
Routing workflow using the actor model.
This workflow classifies an input and directs it to a specialized follow-up task or handler. It allows for separation of concerns and building more specialized prompts for different types of inputs.
| agents::workflows::RoutingWorkflow::RoutingWorkflow | ( | std::shared_ptr< Context > | context, |
| const std::string & | router_prompt_template = "" ) |
Constructor with context and router prompt template.
| context | The context of the workflow |
| router_prompt_template | The router prompt template |
| void agents::workflows::RoutingWorkflow::addRoute | ( | const std::string & | name, |
| const std::string & | description, | ||
| std::function< JsonObject(const std::string &, const JsonObject &)> | handler ) |
Add a route with a direct function handler.
| name | The name of the route |
| description | The description of the route |
| handler | The handler of the route |
| void agents::workflows::RoutingWorkflow::addRouteHandler | ( | const RouteHandler & | handler | ) |
Add a route handler.
| handler | The handler to add |
| void agents::workflows::RoutingWorkflow::addRouteHandler | ( | const std::string & | name, |
| const std::string & | description, | ||
| const std::string & | prompt_template = "", | ||
| std::shared_ptr< LLMInterface > | handler_llm = nullptr, | ||
| std::shared_ptr< Workflow > | workflow = nullptr ) |
Add a route handler with basic params.
| name | The name of the route |
| description | The description of the route |
| prompt_template | The prompt template of the route |
| handler_llm | The LLM of the route |
| workflow | The workflow of the route |
|
inherited |
Get the workflow's context.
|
inherited |
Get maximum number of steps.
| JsonObject agents::workflows::RoutingWorkflow::getRoutesSchema | ( | ) | const |
Define available routes as a JSON schema.
|
overridevirtual |
Execute the workflow with input.
| input | The input to the workflow |
Implements agents::workflows::Workflow.
|
virtualinherited |
Run the workflow with a user input asynchronously.
| input | The user input |
| callback | The callback |
| void agents::workflows::RoutingWorkflow::setDefaultHandler | ( | const RouteHandler & | handler | ) |
Set default handler for unknown routes.
| handler | The handler to set |
| void agents::workflows::RoutingWorkflow::setDefaultRoute | ( | std::function< JsonObject(const std::string &, const JsonObject &)> | handler | ) |
|
inherited |
Set maximum number of steps.
| max_steps | The maximum number of steps |
|
inline |
Set the router prompt.
| prompt_template | The prompt template to set |
| void agents::workflows::RoutingWorkflow::setRouterPromptTemplate | ( | const std::string & | prompt_template | ) |
Set the router prompt template.
| prompt_template | The prompt template to set |
|
inherited |
Set a callback for intermediate steps.
| callback | The callback |