|
Agents 1.4.0
Edge AI Agents SDK
|
A workflow that runs multiple tasks in parallel. More...
#include <parallelization_workflow.h>
Classes | |
| struct | Task |
| Task definition for parallel execution. More... | |
Public Types | |
| enum class | Strategy { SECTIONING , VOTING } |
| Enum for parallelization strategy. More... | |
Public Member Functions | |
| ParallelizationWorkflow (std::shared_ptr< Context > context, Strategy strategy=Strategy::SECTIONING) | |
| Constructor with context. | |
| virtual | ~ParallelizationWorkflow ()=default |
| Destructor. | |
| void | addTask (const Task &task) |
| Add a task to the workflow. | |
| void | addTask (const std::string &name, const std::string &prompt_template, const JsonObject &context=JsonObject()) |
| Add a task to the workflow with basic params. | |
| void | addTask (const std::string &name, const std::string &prompt_template, std::function< std::string(const std::string &)> prompt_fn, std::function< JsonObject(const std::string &)> result_parser, const JsonObject &context=JsonObject()) |
| Add a task to the workflow with generators and parser. | |
| void | setAggregator (std::function< JsonObject(const std::vector< JsonObject > &)> aggregator) |
| Set the aggregation function for task results. | |
| void | setStrategy (Strategy strategy) |
| Set the strategy. | |
| void | init () |
| Initialize the workflow. | |
| void | setVotingThreshold (double threshold) |
| Set the voting threshold (for VOTING mode). | |
| JsonObject | run (const std::string &input) override |
| Execute the workflow with input. | |
| JsonObject | run () |
| Execute using the latest USER message from context memory. | |
| 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 that runs multiple tasks in parallel.
This workflow allows LLMs to work simultaneously on a task and have their outputs aggregated. It supports two key variations:
|
strong |
Enum for parallelization strategy.
| Enumerator | |
|---|---|
| SECTIONING | Break task into independent subtasks. |
| VOTING | Run same task multiple times for consensus. |
| agents::workflows::ParallelizationWorkflow::ParallelizationWorkflow | ( | std::shared_ptr< Context > | context, |
| Strategy | strategy = Strategy::SECTIONING ) |
Constructor with context.
| context | The context of the workflow |
| strategy | The strategy of the workflow |
| void agents::workflows::ParallelizationWorkflow::addTask | ( | const std::string & | name, |
| const std::string & | prompt_template, | ||
| const JsonObject & | context = JsonObject() ) |
Add a task to the workflow with basic params.
| name | The name of the task |
| prompt_template | The prompt template of the task |
| context | The context of the task |
| void agents::workflows::ParallelizationWorkflow::addTask | ( | const std::string & | name, |
| const std::string & | prompt_template, | ||
| std::function< std::string(const std::string &)> | prompt_fn, | ||
| std::function< JsonObject(const std::string &)> | result_parser, | ||
| const JsonObject & | context = JsonObject() ) |
Add a task to the workflow with generators and parser.
| name | The name of the task |
| prompt_template | The prompt template of the task |
| prompt_fn | The prompt function of the task |
| result_parser | The result parser of the task |
| context | The context of the task |
| void agents::workflows::ParallelizationWorkflow::addTask | ( | const Task & | task | ) |
|
inherited |
Get the workflow's context.
|
inherited |
Get maximum number of steps.
| JsonObject agents::workflows::ParallelizationWorkflow::run | ( | ) |
Execute using the latest USER message from context memory.
|
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::ParallelizationWorkflow::setAggregator | ( | std::function< JsonObject(const std::vector< JsonObject > &)> | aggregator | ) |
Set the aggregation function for task results.
| aggregator | The aggregation function |
|
inherited |
Set maximum number of steps.
| max_steps | The maximum number of steps |
|
inherited |
Set a callback for intermediate steps.
| callback | The callback |
| void agents::workflows::ParallelizationWorkflow::setStrategy | ( | Strategy | strategy | ) |
Set the strategy.
| strategy | The strategy |
| void agents::workflows::ParallelizationWorkflow::setVotingThreshold | ( | double | threshold | ) |
Set the voting threshold (for VOTING mode).
| threshold | The threshold |