|
Agents 1.4.0
Edge AI Agents SDK
|
A workflow where a central orchestrator delegates tasks to workers. More...
#include <orchestrator_workflow.h>
Classes | |
| struct | Worker |
| Worker definition. More... | |
Public Member Functions | |
| OrchestratorWorkflow (std::shared_ptr< Context > context, const std::string &orchestrator_prompt_template="") | |
| Constructor with context and orchestrator prompt. | |
| void | addWorker (const Worker &worker) |
| Add a worker to the workflow. | |
| void | addWorker (const std::string &name, const std::string &description, const std::string &prompt_template, std::shared_ptr< LLMInterface > worker_llm=nullptr) |
| Add a worker with basic params. | |
| void | init () |
| Initialize the workflow. | |
| JsonObject | run (const std::string &input) override |
| Execute the workflow with input. | |
| void | setMaxIterations (int max_iterations) |
| Set the max number of iterations. | |
| void | setSynthesizer (std::function< JsonObject(const std::vector< JsonObject > &)> synthesizer) |
| Set the result synthesizer function. | |
| void | setOrchestratorPrompt (const std::string &orchestrator_prompt_template) |
| Set the orchestrator prompt template. | |
| JsonObject | getWorkersSchema () const |
| Get the schema for available workers. | |
| 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. | |
A workflow where a central orchestrator delegates tasks to workers.
In this workflow, a central LLM (orchestrator) dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results. This is well-suited for complex tasks where subtasks can't be predetermined.
| agents::workflows::OrchestratorWorkflow::OrchestratorWorkflow | ( | std::shared_ptr< Context > | context, |
| const std::string & | orchestrator_prompt_template = "" ) |
Constructor with context and orchestrator prompt.
| context | The context of the workflow |
| orchestrator_prompt_template | The orchestrator prompt template |
| void agents::workflows::OrchestratorWorkflow::addWorker | ( | const std::string & | name, |
| const std::string & | description, | ||
| const std::string & | prompt_template, | ||
| std::shared_ptr< LLMInterface > | worker_llm = nullptr ) |
Add a worker with basic params.
| name | The name of the worker |
| description | The description of the worker |
| prompt_template | The prompt template of the worker |
| worker_llm | The llm of the worker |
| void agents::workflows::OrchestratorWorkflow::addWorker | ( | const Worker & | worker | ) |
|
inherited |
Get the workflow's context.
|
inherited |
Get maximum number of steps.
| JsonObject agents::workflows::OrchestratorWorkflow::getWorkersSchema | ( | ) | const |
Get the schema for available workers.
|
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::OrchestratorWorkflow::setMaxIterations | ( | int | max_iterations | ) |
Set the max number of iterations.
| max_iterations | The max number of iterations |
|
inherited |
Set maximum number of steps.
| max_steps | The maximum number of steps |
| void agents::workflows::OrchestratorWorkflow::setOrchestratorPrompt | ( | const std::string & | orchestrator_prompt_template | ) |
Set the orchestrator prompt template.
| orchestrator_prompt_template | The orchestrator prompt template |
|
inherited |
Set a callback for intermediate steps.
| callback | The callback |
| void agents::workflows::OrchestratorWorkflow::setSynthesizer | ( | std::function< JsonObject(const std::vector< JsonObject > &)> | synthesizer | ) |
Set the result synthesizer function.
| synthesizer | The synthesizer function |