Code - Python
A component to run Python
Although AgenticFlow AI is generally a zero or low-code platform, the functionality of adding Python code snippets to your workflows is available and fully supported. Code snippets can be useful in tasks such as pre- or post-processing of data or analysis tasks where LLMs might not be the best fit.
How to Use a Python Action
Adding the Component
To use Python, you need to add a “Code-Python” action to your workflow. Follow these steps to get started:
Navigate to the Workflow page.
Click on + Create Workflow or select an existing workflow.
Click on + Add Action.
Select Code - Python from the list of action components.
Python Packages and Runtime Commands
You can specify all the required Python packages (e.g., pandas) under Packages and all the Runtime Commands (e.g., apt-get install cuda
) under Runtime Commands.
Enter your code in the code section as you would in any other IDE (e.g., VS Code, PyCharm).
Access to Input Variables and Other Actions’ Output
Access Input Variables
Input variables can be accessed via params
. params
is a dictionary, and the names of variables are the dictionary keys. For example, if there is an input parameter named “title,” you can access its value using params["title"]
.
Access Other Actions’ Output
Outputs from other actions can be accessed via steps
. steps
is a dictionary, and the names of actions are the dictionary keys. For example, if there is an action named “summary,” you can access its produced value using steps["summary"]["output"]
.
Access the Step Output
If the name of a Python action is python
, you can access the action's output using python.transformed
. Note that an action name is different from the action title. Action titles can be found on the top left of actions. An action name is shown on the bottom left, in a smaller font and highlighted green.
Follow the links below for more information about:
Common Errors
The most common errors seen in our logs are Python coding-related errors, for which there are millions of resources available online. However, occasionally, users encounter the Code execution timed out
error. Keep in mind that Python snippet execution time cannot exceed 4 hours.
Last updated