Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
prompt_chaining_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
27public:
31 struct Step {
36
41
45 std::function<bool(const JsonObject&)> validator;
46
50 std::function<JsonObject(const JsonObject&)> transformer;
51
55 bool use_tools = false;
56
65 const String& name,
67 std::function<bool(const JsonObject&)> validator = nullptr,
68 std::function<JsonObject(const JsonObject&)> transformer = nullptr
71 };
72
77 PromptChainingWorkflow(std::shared_ptr<AgentContext> context);
78
83 void addStep(const Step& step);
84
92 void addStep(
93 const String& name,
94 const String& prompt_template,
95 std::function<bool(const JsonObject&)> validator = nullptr,
96 std::function<JsonObject(const JsonObject&)> transformer = nullptr
97 );
98
104 JsonObject run(const String& input) override;
105
111
112private:
116 std::vector<Step> steps_;
117
121 JsonObject step_outputs_;
122
128 JsonObject run(const JsonObject& input);
129};
130
131} // namespace workflows
132} // namespace agents
void addStep(const Step &step)
Add a step to the workflow.
PromptChainingWorkflow(std::shared_ptr< AgentContext > context)
Constructor with context.
JsonObject run(const String &input) override
Execute the workflow with input.
JsonObject run()
Execute the workflow using the latest USER message from context memory.
void addStep(const String &name, const String &prompt_template, std::function< bool(const JsonObject &)> validator=nullptr, std::function< JsonObject(const JsonObject &)> transformer=nullptr)
Add a step to the workflow with basic params.
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
Step in the workflow.
Definition prompt_chaining_workflow.h:31
bool use_tools
Flag to control tool usage.
Definition prompt_chaining_workflow.h:55
String prompt_template
Prompt template for this step.
Definition prompt_chaining_workflow.h:40
std::function< JsonObject(const JsonObject &)> transformer
Function to transform step output for the next step.
Definition prompt_chaining_workflow.h:50
String name
Name of the step.
Definition prompt_chaining_workflow.h:35
std::function< bool(const JsonObject &)> validator
Function to validate step output (returns true if valid)
Definition prompt_chaining_workflow.h:45
Step(const String &name, const String &prompt_template, std::function< bool(const JsonObject &)> validator=nullptr, std::function< JsonObject(const JsonObject &)> transformer=nullptr)
Constructor.
Definition prompt_chaining_workflow.h:64