Agents 0.0.2
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< AgentContext > context, const String &optimizer_prompt_template="", const String &evaluator_prompt_template="") | |
Constructor with LLM interfaces for optimizer and evaluator. | |
void | init () |
Initialize the workflow. | |
JsonObject | run (const String &input) override |
Execute the workflow with input. | |
void | setEvaluationCriteria (const std::vector< 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 String &prompt_template) |
Set the optimizer prompt template. | |
void | setOptimizerPrompt (const String &prompt_template) |
Set the optimizer prompt. | |
void | setEvaluatorPromptTemplate (const String &prompt_template) |
Set the evaluator prompt template. | |
void | setEvaluatorPrompt (const String &prompt_template) |
Set the evaluator prompt. | |
void | setOptimizer (std::function< String(const String &, const JsonObject &)> optimizer) |
Set the optimizer function. | |
void | setEvaluator (std::function< JsonObject(const String &, const String &)> evaluator) |
Set the evaluator function. | |
virtual void | runAsync (const String &input, std::function< void(const JsonObject &)> callback) |
Run the workflow with a user input asynchronously. | |
std::shared_ptr< AgentContext > | getContext () const |
Get the workflow's context. | |
void | setStepCallback (std::function< void(const 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< AgentContext > | context, |
const String & | optimizer_prompt_template = "", | ||
const 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< String > & | criteria | ) |
Set the evaluation criteria for the evaluator.
criteria | The evaluation criteria to set |
void agents::workflows::EvaluatorWorkflow::setEvaluator | ( | std::function< JsonObject(const String &, const 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 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< String(const 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 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 |