Map Node

In pipelines you may want to repeat the same action on multiple pieces of data. The map node can be used to run nodes across multiple inputs.

Map Node Parameters

The map node, has two input handles

  • inputs: The inputs should be pipeline output with multiple

  • function: Attach another node to act the the function that will be mapped over the inputs

The map node will execute the given function on each element of the inputs and combine the results in the output.

Map Node Examples

Bacic Map Functionality

In this pipeline we show the key concepts for the map node

  1. The split text node splits text on newlines and returns a list of strings

  2. The map node is given the OpenAI LLM node as the function.

  3. The LLM will be called with the system message on each of the elements from the split text node

  4. The outputs from all the LLM calls are fed to the output node

Note how the OpenAI LLM has an empty prompt handle. This is the variable that will be filled in with each element of the Map node inputs. The system prompt will be the same for every execution

hello
racecar

If we input the above text to the pipeline, the LLM will run on each line.

The output will be:

['olleh', 'racecar']

Last updated