|
Agents 1.4.0
Edge AI Agents SDK
|
An evaluator-optimizer workflow where one LLM optimizes output based on another's feedback. More...
#include <evaluator_workflow.h>
Public Member Functions | |
| EvaluatorWorkflow (std::shared_ptr< Context > context, const std::string &optimizer_prompt_template="", const std::string &evaluator_prompt_template="") | |
| Constructor with LLM interfaces for optimizer and evaluator. | |
| void | init () |
| Initialize the workflow. | |
| JsonObject | run (const std::string &input) override |
| Execute the workflow with input. | |
| void | setEvaluationCriteria (const std::vector< std::string > &criteria) |
| Set the evaluation criteria for the evaluator. | |
| void | setMaxIterations (int max_iterations) |
| Set the max number of feedback iterations. | |
| void | setImprovementThreshold (double threshold) |
| Set the improvement threshold (minimum score to accept a response). | |
| void | setMinimumAcceptableScore (double threshold) |
| Set the minimum acceptable score. | |
| void | setOptimizerPromptTemplate (const std::string &prompt_template) |
| Set the optimizer prompt template. | |
| void | setOptimizerPrompt (const std::string &prompt_template) |
| Set the optimizer prompt. | |
| void | setEvaluatorPromptTemplate (const std::string &prompt_template) |
| Set the evaluator prompt template. | |
| void | setEvaluatorPrompt (const std::string &prompt_template) |
| Set the evaluator prompt. | |
| void | setOptimizer (std::function< std::string(const std::string &, const JsonObject &)> optimizer) |
| Set the optimizer function. | |
| void | setEvaluator (std::function< JsonObject(const std::string &, const std::string &)> evaluator) |
| Set the evaluator function. | |
| 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. | |
An evaluator-optimizer workflow where one LLM optimizes output based on another's feedback.
In this workflow, one LLM call generates a response while another provides evaluation and feedback in a loop. This pattern is effective when we have clear evaluation criteria and iterative refinement provides value.
| agents::workflows::EvaluatorWorkflow::EvaluatorWorkflow | ( | std::shared_ptr< Context > | context, |
| const std::string & | optimizer_prompt_template = "", | ||
| const std::string & | evaluator_prompt_template = "" ) |
Constructor with LLM interfaces for optimizer and evaluator.
| context | The context to use |
| optimizer_prompt_template | The optimizer prompt template |
| evaluator_prompt_template | The evaluator prompt template |
|
inherited |
Get the workflow's context.
|
inherited |
Get maximum number of steps.
|
overridevirtual |
Execute the workflow with input.
| input | The input to execute the workflow with |
Implements agents::workflows::Workflow.
|
virtualinherited |
Run the workflow with a user input asynchronously.
| input | The user input |
| callback | The callback |
| void agents::workflows::EvaluatorWorkflow::setEvaluationCriteria | ( | const std::vector< std::string > & | criteria | ) |
Set the evaluation criteria for the evaluator.
| criteria | The evaluation criteria to set |
| void agents::workflows::EvaluatorWorkflow::setEvaluator | ( | std::function< JsonObject(const std::string &, const std::string &)> | evaluator | ) |
Set the evaluator function.
| evaluator | The evaluator function to set |
|
inline |
Set the evaluator prompt.
| prompt_template | The evaluator prompt to set |
| void agents::workflows::EvaluatorWorkflow::setEvaluatorPromptTemplate | ( | const std::string & | prompt_template | ) |
Set the evaluator prompt template.
| prompt_template | The evaluator prompt template to set |
| void agents::workflows::EvaluatorWorkflow::setImprovementThreshold | ( | double | threshold | ) |
Set the improvement threshold (minimum score to accept a response).
| threshold | The improvement threshold to set |
| void agents::workflows::EvaluatorWorkflow::setMaxIterations | ( | int | max_iterations | ) |
Set the max number of feedback iterations.
| max_iterations | The max number of feedback iterations to set |
|
inherited |
Set maximum number of steps.
| max_steps | The maximum number of steps |
|
inline |
Set the minimum acceptable score.
| threshold | The minimum acceptable score to set |
| void agents::workflows::EvaluatorWorkflow::setOptimizer | ( | std::function< std::string(const std::string &, const JsonObject &)> | optimizer | ) |
Set the optimizer function.
| optimizer | The optimizer function to set |
|
inline |
Set the optimizer prompt.
| prompt_template | The optimizer prompt to set |
| void agents::workflows::EvaluatorWorkflow::setOptimizerPromptTemplate | ( | const std::string & | prompt_template | ) |
Set the optimizer prompt template.
| prompt_template | The optimizer prompt template to set |
|
inherited |
Set a callback for intermediate steps.
| callback | The callback |