Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
workflow.h
1
10#pragma once
11
12#include <agents-cpp/types.h>
13#include <agents-cpp/agent_context.h>
14#include <functional>
15#include <memory>
16
17namespace agents {
22namespace workflows {
23
30class Workflow {
31public:
36 Workflow(std::shared_ptr<AgentContext> context);
37
41 ~Workflow() = default;
42
48 virtual JsonObject run(const String& input) = 0;
49
55 virtual void runAsync(
56 const String& input,
57 std::function<void(const JsonObject&)> callback
58 );
59
64 std::shared_ptr<AgentContext> getContext() const;
65
70 void setStepCallback(std::function<void(const String&, const JsonObject&)> callback);
71
76 void setMaxSteps(int max_steps);
77
82 int getMaxSteps() const;
83
85protected:
89 std::shared_ptr<AgentContext> context_;
90
94 std::function<void(const String&, const JsonObject&)> step_callback_;
95
99 int max_steps_ = 10;
100
106 void logStep(const String& description, const JsonObject& result);
108};
109
110} // namespace workflows
111} // namespace agents
int getMaxSteps() const
Get maximum number of steps.
~Workflow()=default
Destructor.
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 setMaxSteps(int max_steps)
Set maximum number of steps.
void setStepCallback(std::function< void(const String &, const JsonObject &)> callback)
Set a callback for intermediate steps.
virtual JsonObject run(const String &input)=0
Run the workflow with a user input and return the result.
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