Pipelines
Adapted from the Griptape AI Framework documentation.
Overview
A Pipeline is very similar to an Agent, but allows for multiple tasks.
You can access the final output of the Pipeline by using the output attribute.
Context
Pipelines have access to the following context variables in addition to the base context.
task_outputs
: dictionary containing mapping of all task IDs to their outputs.parent_output
: output from the parent task if one exists, otherwiseNone
.parent
: parent task if one exists, otherwiseNone
.child
: child task if one exists, otherwiseNone
.
Pipeline
from griptape.structures import Pipeline from griptape.tasks import PromptTask pipeline = Pipeline() pipeline.add_tasks( # take the first argument from the pipeline `run` method PromptTask("{{ args[0] }}"), # take the output from the previous task and insert it into the prompt PromptTask("Say the following like a pirate: {{ parent_output }}"), ) pipeline.run("Write me a haiku about sailing.")
[02/27/25 20:26:03] INFO PromptTask 36e59dad4dca4eb887934532b2369534 Input: Write me a haiku about sailing. [02/27/25 20:26:04] INFO PromptTask 36e59dad4dca4eb887934532b2369534 Output: Wind whispers softly, Canvas wings embrace the sea— Freedom's course unfolds. INFO PromptTask 43d09fca2813415082bccedfe518b125 Input: Say the following like a pirate: Wind whispers softly, Canvas wings embrace the sea— Freedom's course unfolds. INFO PromptTask 43d09fca2813415082bccedfe518b125 Output: Arrr, the wind be whisperin' soft-like, Canvas wings be huggin' the briny deep— Freedom's course be unfurlin', aye!
Could this page be better? Report a problem or suggest an addition!