Run Arbitrary Python Code

Sometimes you may want to run arbitrary Python code in a workflow. This can be done using the Python Sandbox action. Each Python Sandbox action runs in a secure sandbox environment, which ensures that the code is executed safely. Your python code can install any package from PyPI, and use any package that is pre-installed in the sandbox.

Static Code

Just write your Python code in the code editor.

Dynamic Code

You can use LLM to generate Python code. For example, you can use LLM to generate a Python code and pass the generated code to the Python Sandbox action.

Accessing upstream action output

Each Python Sandbox action can access the output of the upstream actions. The output of the upstream action is available in the 'ACTION_NAME' variable. For example, if the upstream action is a LLM action called 'CALL_LLM', the output of the LLM action is available in the CALL_LLM variable.

Secrets

Team level secrets are automatically injected into the Python Sandbox environment. Your code can access them via environment variables.

User level secrets are not available in the Python Sandbox environment.