12#include <agents-cpp/workflow.h>
51 std::shared_ptr<LLMInterface>
llm;
69 std::shared_ptr<LLMInterface>
llm =
nullptr,
81 std::shared_ptr<AgentContext> context,
82 const String& orchestrator_prompt_template =
""
100 const String& description,
101 const String& prompt_template,
102 std::shared_ptr<LLMInterface> worker_llm =
nullptr
145 String orchestrator_prompt_template_;
150 std::vector<Worker> workers_;
155 std::function<
JsonObject(
const std::vector<JsonObject>&)> synthesizer_;
160 std::map<String, Worker> worker_map_;
165 int max_iterations_ = 5;
170 JsonObject defaultSynthesizer(
const std::vector<JsonObject>& results);
176 String createOrchestratorSystemPrompt()
const;
182 const String& worker_name,
void addWorker(const String &name, const String &description, const String &prompt_template, std::shared_ptr< LLMInterface > worker_llm=nullptr)
Add a worker with basic params.
void init()
Initialize the workflow.
JsonObject getWorkersSchema() const
Get the schema for available workers.
void addWorker(const Worker &worker)
Add a worker to the workflow.
JsonObject run(const String &input) override
Execute the workflow with input.
void setOrchestratorPrompt(const String &orchestrator_prompt_template)
Set the orchestrator prompt template.
void setSynthesizer(std::function< JsonObject(const std::vector< JsonObject > &)> synthesizer)
Set the result synthesizer function.
OrchestratorWorkflow(std::shared_ptr< AgentContext > context, const String &orchestrator_prompt_template="")
Constructor with context and orchestrator prompt.
void setMaxIterations(int max_iterations)
Set the max number of iterations.
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
Worker definition.
Definition orchestrator_workflow.h:35
String description
The description of the worker.
Definition orchestrator_workflow.h:43
String prompt_template
The prompt template of the worker.
Definition orchestrator_workflow.h:47
Worker(const String &name, const String &description, const String &prompt_template, std::shared_ptr< LLMInterface > llm=nullptr, std::function< JsonObject(const String &, const JsonObject &)> handler=nullptr)
Constructor.
Definition orchestrator_workflow.h:65
String name
The name of the worker.
Definition orchestrator_workflow.h:39
std::shared_ptr< LLMInterface > llm
The llm of the worker.
Definition orchestrator_workflow.h:51
std::function< JsonObject(const String &, const JsonObject &)> handler
The handler of the worker.
Definition orchestrator_workflow.h:55