Code Block
Supports writing Python or JavaScript code in workflows. Code execution can process input variable parameters and output new result parameters for further reference in subsequent nodes, helping developers enhance their workflow orchestration capabilities.
1. Overview
Code block execution enables more flexible custom business logic and enhanced agent orchestration extensibility, completing tasks such as logical calculations, external API interactions, and data processing:
- Supports Python and JavaScript programming languages
- Supports defining outputs from previous nodes or variables set in start nodes as code input parameters for use within code
- Can output structured code execution results as parameters for further use in subsequent nodes
2. Usage Instructions
Code block nodes require developers to write a function that implements business logic through three steps: referencing input parameters, executing logic, and outputting results:
- Input Variables: Can reference outputs from previous workflow nodes or variables defined in start nodes. Input variables will be used as function parameters
- Code Writing: Write the internal code logic for the function, supporting Python or JavaScript syntax. Python functions can import dependencies using import statements
- Output Variables: Code blocks produce structured JSON format output, where each variable can be referenced by subsequent nodes
Note: Function definitions, input parameters, and output parameters are automatically generated by the system based on input/output variables and don't need manual modification. Developers only need to fill in the internal code execution logic.
