Although Relevance in general is a zero or low code platform, the functionality of adding Python code snippets to your Tools is available and fully supported. Code snippets can be useful in tasks such as pre or post processing of data or analysis at which LLMs are not good.

How to use a Python step

Add the component

To use Python, you need to add a “Code-Python” step to your Tool (check how to get started with creating a tool). Python step

Python packages and runtime commands

Python step

You can specify all the required Python packages (e.g. pandas) under Packages and all the Runtime commands (apt-get install cuda) under Runtime Commands.

Enter your code in the code section as you do in any other IDE (e.g. VS code, PyCharm)

Access to input variables and other steps’ output

  • Access to input variables is 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 to title value using params["title"].

  • Access to other steps’ output is via steps. steps is a dictionary and the names of steps are the dictionary keys. For example, if there is a step named “summary” you can access its produced value using steps["summary"]["output"].

Follow the links below for more information about

Access the step output

If the name of a Python step is python, you can access the step output using python.transformed. Note that a step name is different from the step title. Step titles can be found on the top left of steps. A step name is shown on the bottom left, in smaller font and highlighted green.

Common errors

The most common errors seen in our logs are Python coding related errors to 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.