Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
evaluator_workflow.h
1
10#pragma once
11
12#include <agents-cpp/workflow.h>
13#include <functional>
14#include <vector>
15
16namespace agents {
17namespace workflows {
18
28public:
36 std::shared_ptr<AgentContext> context,
37 const String& optimizer_prompt_template = "",
38 const String& evaluator_prompt_template = ""
39 );
40
44 void init();
45
51 JsonObject run(const String& input) override;
52
57 void setEvaluationCriteria(const std::vector<String>& criteria);
58
63 void setMaxIterations(int max_iterations);
64
69 void setImprovementThreshold(double threshold);
70
75 void setMinimumAcceptableScore(double threshold) { setImprovementThreshold(threshold); }
76
81 void setOptimizerPromptTemplate(const String& prompt_template);
82
87 void setOptimizerPrompt(const String& prompt_template) { setOptimizerPromptTemplate(prompt_template); }
88
93 void setEvaluatorPromptTemplate(const String& prompt_template);
94
99 void setEvaluatorPrompt(const String& prompt_template) { setEvaluatorPromptTemplate(prompt_template); }
100
105 void setOptimizer(std::function<String(const String&, const JsonObject&)> optimizer);
106
111 void setEvaluator(std::function<JsonObject(const String&, const String&)> evaluator);
112
113private:
117 std::shared_ptr<LLMInterface> evaluator_llm_;
118
122 String optimizer_prompt_template_;
123 String evaluator_prompt_template_;
124
128 std::vector<String> evaluation_criteria_;
129
133 int max_iterations_ = 3;
134
138 double improvement_threshold_ = 0.8; // 0.0 to 1.0
139
143 std::function<String(const String&, const JsonObject&)> optimizer_;
144
149 std::function<JsonObject(const String&, const String&)> evaluator_;
150
154 String defaultOptimizer(const String& input, const JsonObject& feedback);
155
159 JsonObject defaultEvaluator(const String& input, const String& output);
160
165 String createEvaluatorSystemPrompt() const;
166};
167
168} // namespace workflows
169} // namespace agents
void setEvaluator(std::function< JsonObject(const String &, const String &)> evaluator)
Set the evaluator function.
void setOptimizerPrompt(const String &prompt_template)
Set the optimizer prompt.
Definition evaluator_workflow.h:87
void setOptimizer(std::function< String(const String &, const JsonObject &)> optimizer)
Set the optimizer function.
JsonObject run(const String &input) override
Execute the workflow with input.
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 setMinimumAcceptableScore(double threshold)
Set the minimum acceptable score.
Definition evaluator_workflow.h:75
void setEvaluatorPrompt(const String &prompt_template)
Set the evaluator prompt.
Definition evaluator_workflow.h:99
void setEvaluationCriteria(const std::vector< String > &criteria)
Set the evaluation criteria for the evaluator.
void init()
Initialize the workflow.
void setEvaluatorPromptTemplate(const String &prompt_template)
Set the evaluator prompt template.
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 setOptimizerPromptTemplate(const String &prompt_template)
Set the optimizer prompt template.
Workflow(std::shared_ptr< AgentContext > context)
Constructor.
Worflows Namespace.
Definition workflow.h:22
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27