Types of Task Steps
Learn about different types of task steps and their use
Overview
In Julep broadly speaking there are two types of steps:
Control Flow Steps
These steps control the flow of the task. They are used to create conditional logic, loops, and parallel execution.
Key-Value Steps
These steps are used to get and set values in the task.
Iteration Steps
These steps are used to iterate over a collection.
Conditional Steps
These steps are used to create conditional logic.
Other Control Flow Steps
These steps are used to control the flow of the task.
The steps defined out here are in the YAML format. You can learn more about the YAML format here.
Control Flow Steps
Prompt Step
Send messages to the AI model:
In the prompt step we offer a bunch of Python functions to help you manipulate data. Here is a list of the functions you can use:
-
Standard library modules:
re
: Regular expressions (safe against ReDoS)json
: JSON encoding/decodingyaml
: YAML parsing/dumpingstring
: String constants and operationsdatetime
: Date and time operationsmath
: Mathematical functionsstatistics
: Statistical operationsbase64
: Base64 encoding/decodingurllib
: URL parsing operationsrandom
: Random number generationtime
: Time operations
-
Constants:
NEWLINE
: Newline charactertrue
: Boolean truefalse
: Boolean falsenull
: None value
Tool Call Step
Execute tools defined in the task:
Evaluate Step
Perform calculations or data manipulation:
In the evaluate step we offer a bunch of Python functions to help you manipulate data. Check out the Python Expressions for more information.
Wait for Input Step
Pause workflow for user input:
Subworkflow Step
Executing a subworkflow from a main workflow:
- The
arguments
passed from the main workflow to the subworkflow are available in thesteps[0].input
of the subworkflow. - The
result
of the subworkflow is available in thesteps[1].output.result
of the main workflow. - The
Input/Output Data References
between steps is exclusive to the workflow they are defined in. A workflow cannot reference theinput
oroutput
of another workflow between the steps. To learn more aboutInput/Output Data References
click here.
Self recursion is allowed in a subworkflow but not in a main workflow.
Key-Value Steps
Get Step
Retrieve values from storage:
Set Step
Store values for later use:
Values stored using the set step are added to the workflowβs global state
object, which can be accessed anywhere in the workflow using state.variable_name
. For example:
Each subworkflow has its own isolated state
object. Values set in one subworkflow are not accessible from other subworkflows or the parent workflow.
Label Step
Label a step to make it easier to identify and access those values later in any step:
In any steps following the label step, you can access the values set in the label step using the $ steps['label_name'].input.attribute_name
or $ steps['label_name'].output.attribute_name
syntax. For example:
Iteration Steps
Foreach Step
Iterate over a collection:
Map-Reduce Step
Process collections in parallel:
- By default the
parallelism
if not mentioned is 100. If mentioned, it is the maximum number of steps that can run in parallel concurrently. - When using
over
step, themap
step is executed for each value in the collection. - The
reduce
step is executed after themap
step.
Conditional Steps
If-Else Step
Conditional execution:
Switch Step
Multiple condition handling:
Other Control Flow
Sleep Step
Pause execution:
Return Step
Return values from workflow:
Yield Step
Execute subworkflows:
Log Step
Log messages or specific values:
Error Step
Handle errors by specifying an error message:
Example: Complex Workflow
Hereβs an example combining various step types:
Best Practices
Step Organization
- Group related steps logically
- Use comments to explain complex steps
- Keep step chains focused and manageable
Error Handling
- Use if-else for error conditions
- Provide fallback options
- Log important state changes
Performance
- Use parallel execution when possible
- Optimize data passing between steps
- Cache frequently used values
Support
If you need help with further questions in Julep:
- Join our Discord community
- Check the GitHub repository
- Contact support at hey@julep.ai