The CodeExecution dynamic column will execute a python function on every row of your dataset.

This can be useful to transform your data, which is often useful as an intermediary step for running evaluations or prompts.

Output type: any


  • Code: The code to be executed.

The python function must be named main.

The function will receive the row as a dictionary and should return the transformed row.

For example:

# Function name should be main only. You can access any column of the row using the kwargs.
def main(**kwargs):
    return kwargs['query'].replace(' ', '_')
You can access data from any column using kwargs.get('COLUMN_NAME')


You cannot import any external libraries in the code execution dynamic column.

The code execution dynamic column only supports the standard Python libraries.