A workflow that chains multiple prompts together.
More...
#include <prompt_chaining_workflow.h>
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.
- Examples
- prompt_chain_example.cpp, and simple_workflow.cpp.
◆ PromptChainingWorkflow()
agents::workflows::PromptChainingWorkflow::PromptChainingWorkflow |
( |
std::shared_ptr< AgentContext > | context | ) |
|
Constructor with context.
- Parameters
-
context | The context to use |
◆ addStep() [1/2]
void agents::workflows::PromptChainingWorkflow::addStep |
( |
const Step & | step | ) |
|
◆ addStep() [2/2]
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.
- Parameters
-
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 |
◆ getContext()
std::shared_ptr< AgentContext > agents::workflows::Workflow::getContext |
( |
| ) |
const |
|
inherited |
Get the workflow's context.
- Returns
- The context
◆ getMaxSteps()
int agents::workflows::Workflow::getMaxSteps |
( |
| ) |
const |
|
inherited |
Get maximum number of steps.
- Returns
- The maximum number of steps
◆ run() [1/2]
JsonObject agents::workflows::PromptChainingWorkflow::run |
( |
| ) |
|
Execute the workflow using the latest USER message from context memory.
- Returns
- The result of the workflow execution
◆ run() [2/2]
JsonObject agents::workflows::PromptChainingWorkflow::run |
( |
const String & | input | ) |
|
|
overridevirtual |
◆ runAsync()
virtual void agents::workflows::Workflow::runAsync |
( |
const String & | input, |
|
|
std::function< void(const JsonObject &)> | callback ) |
|
virtualinherited |
Run the workflow with a user input asynchronously.
- Parameters
-
input | The user input |
callback | The callback |
◆ setMaxSteps()
void agents::workflows::Workflow::setMaxSteps |
( |
int | max_steps | ) |
|
|
inherited |
Set maximum number of steps.
- Parameters
-
max_steps | The maximum number of steps |
◆ setStepCallback()
void agents::workflows::Workflow::setStepCallback |
( |
std::function< void(const String &, const JsonObject &)> | callback | ) |
|
|
inherited |