Running a step in a loop
Run this transformation multiple times
is the input field that expects a list of items (e.g. list of movie names).
Provide the input list manually or activate the variable mode as shown in the image below.
{{variable-name}}
to access an existing variable in the Tool, for instance {{movies}}
.
{{ foreach.item }}
or/and {{ foreach.index }}
.
In the image below, there is a Python step returning a list of items. We wish to run a large language model
on each of the elements with the instruction “Write me a … ”.Run this transformation multiple times
, we enable the variable mode and access
the Python step output via {{python.transformed}}
- note that the name of the step is python
in our example.
Next, we use {{foreach.item}}
to access each of the elements in the list.
After running the step, we will have as many output tabs as the number of elements in the input list.