A workflow that chains multiple prompts together.
More...
#include <prompt_chaining_workflow.h>
|
| | PromptChainingWorkflow (std::shared_ptr< Context > context) |
| | Constructor with context.
|
|
virtual | ~PromptChainingWorkflow ()=default |
| | Destructor.
|
| void | addStep (const Step &step) |
| | Add a step to the workflow.
|
| void | addStep (const std::string &name, const std::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 std::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 std::string &input, std::function< void(const JsonObject &)> callback) |
| | Run the workflow with a user input asynchronously.
|
| std::shared_ptr< Context > | getContext () const |
| | Get the workflow's context.
|
| void | setStepCallback (std::function< void(const std::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.
- Examples
- prompt_chain_example.cpp.
◆ PromptChainingWorkflow()
| agents::workflows::PromptChainingWorkflow::PromptChainingWorkflow |
( |
std::shared_ptr< Context > | context | ) |
|
Constructor with context.
- Parameters
-
| context | The context to use |
◆ addStep() [1/2]
| void agents::workflows::PromptChainingWorkflow::addStep |
( |
const std::string & | name, |
|
|
const std::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 |
◆ addStep() [2/2]
| void agents::workflows::PromptChainingWorkflow::addStep |
( |
const Step & | step | ) |
|
◆ getContext()
| std::shared_ptr< Context > 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 std::string & | input | ) |
|
|
overridevirtual |
◆ runAsync()
| virtual void agents::workflows::Workflow::runAsync |
( |
const std::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 std::string &, const JsonObject &)> | callback | ) |
|
|
inherited |