Agents 0.0.2
Edge AI Agents SDK
|
A workflow that chains multiple prompts together. More...
#include <prompt_chaining_workflow.h>
Classes | |
struct | Step |
Step in the workflow. More... | |
Public Member Functions | |
PromptChainingWorkflow (std::shared_ptr< AgentContext > context) | |
Constructor with context. | |
void | addStep (const Step &step) |
Add a step to the workflow. | |
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. | |
JsonObject | run (const String &input) override |
Execute the workflow with input. | |
JsonObject | run () |
Execute the workflow using the latest USER message from context memory. | |
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. | |
A workflow that chains multiple prompts together.
This workflow decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one. It can add programmatic checks between steps to ensure the process is on track.
agents::workflows::PromptChainingWorkflow::PromptChainingWorkflow | ( | std::shared_ptr< AgentContext > | context | ) |
Constructor with context.
context | The context to use |
void agents::workflows::PromptChainingWorkflow::addStep | ( | const Step & | step | ) |
Add a step to the workflow.
step | The step to add |
void agents::workflows::PromptChainingWorkflow::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.
name | The name of the step |
prompt_template | The prompt template for the step |
validator | The validator function for the step |
transformer | The transformer function for the step |
|
inherited |
Get the workflow's context.
|
inherited |
Get maximum number of steps.
JsonObject agents::workflows::PromptChainingWorkflow::run | ( | ) |
Execute the workflow using the latest USER message from context memory.
|
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 |
|
inherited |
Set maximum number of steps.
max_steps | The maximum number of steps |
|
inherited |
Set a callback for intermediate steps.
callback | The callback |