The Code component executes Python or JavaScript code for complex data processing, format conversion, calculation, file generation and custom logic.
Prerequisite: The Code component depends on a secure sandbox environment. The deployment environment needs to install and enable gVisor, RAGFlow sandbox and related environment variables. Restart the service after dependency changes.
Configuration:
1.**Input**: Define parameters passed into code; variables can be directly referenced inside scripts.
2.**Code**: Select Python or JavaScript and write business logic.
3.**Return Value**: Define output data returned to downstream components.
Variable Assignor writes or updates variables during workflow execution. It can save upstream results to target variables and support overwrite, clear, append and arithmetic operations for numbers, arrays and objects.
Configuration:
Add variable rules. Select target variable, choose operation type, and fill constant or reference variable as value if required. Multiple rules execute sequentially.
Supported Operations:
| Operation | Requires Value | Description |
| ---- | ---- | ---- |
| Overwritten by | Yes | Overwrite target variable with another variable's value |
| Set | Yes | Assign fixed constant value to target variable |
List Operation processes array data, supporting element extraction, head/tail fetching, filtering, sorting and deduplication. Suitable for array outputs from Begin, HTTP Request, Code and SQL.
Configuration:
1. Select array variable in Query variables.
2. Choose operation in Operations and fill parameters.
3. Optional: Enable Strict mode.
Strict Mode:
- Enabled: Return error when input data format is abnormal
- Disabled: Handle abnormal data with default tolerance
Supported Operations:
- Nth: Get element at specified index (starting from 0)
- Head: Get first N elements
- Tail: Get last N elements
- Filter: Filter array by conditions
- Sort: Sort array by specified field (asc/desc)
- Drop duplicates: Remove duplicate entries
## Variable Aggregator Component
Variable Aggregator combines multiple independent variables into one output group for unified reference by downstream nodes. Widely used in multi-branch conditional workflows to collect data from different branches.
Configuration:
1. Select variables and add into variable groups (default Group0).
2. Click `+` to create new variable groups; delete groups via remove button.
3. Save configuration and run tests.
Output: Variables inside each group can be referenced via group name such as `Group0`.