Skip to main content
Skip table of contents

Code Execution

The Code Execution node is a powerful feature that allows you to write and execute custom Python code directly within your tool. This node is ideal for performing advanced computations, data transformations, or custom logic that cannot be achieved using other nodes. By leveraging Python, you can extend the functionality of your tools and handle complex scenarios with precision.

Overview

The Code Execution node enables you to write Python code in a dedicated editor and execute it during the tool's workflow. Input variables can be mapped to the function parameters, and the output of the code can be stored in a variable for use in subsequent steps.

Key Components

Code Editor

The code editor is where you write your Python code. The editor provides a clean and focused environment for coding, with syntax highlighting for better readability.

  • Function Definition: The code must be written inside the predefined main function. This function serves as the entry point for the code execution.

    • Example:

      CODE
      def main(result):
          # Your custom logic here
          return result
  • Return Statement: The main function must return a value. This value will be stored in the output variable and can be used in subsequent steps.

image-20250515-135019.png

Function Parameters Mapping

The Function Parameters Mapping section allows you to map input variables to the parameters of the main function. This ensures that the data required for the code execution is passed correctly.

  • Input Variables: Select the input variables from the dropdown menu to map them to the function parameters.

  • Custom Parameters: You can define additional parameters in the main function and map them to specific variables or values.

image-20250515-135203.png

Example:

  • If the main function is defined as:

    CODE
    def main(a, b):
        return a + b

    You would need to add a and b in the parameters list and map them to a variable.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.