Skip to main content

Race Inputs Node

Race Inputs Node Screenshot

Overview

The Race Inputs Node is used to handle multiple inputs and outputs the value of the first input to finish, force-cancelling the other inputs. This node is particularly useful when you have multiple operations such as LLM Chat Node calls that can potentially fulfill the same requirement, and you want to use the result of the operation that finishes first.

Inputs

TitleData TypeDescriptionDefault ValueNotes
Input [i]anyThe ith input to be raced. The number of inputs is dynamic based on the number of connectionsN/ADynamic number of inputs based on how many connections there are

Example 1: Race Two LLM Calls

  1. Create a new graph, and add two LLM Chat Nodes to the graph.
  2. Create a Prompt Node, and give it a prompt message that will be answered in a short time, such as "What is your favorite color?". Connect it to the Prompt input of the first LLM Chat Node.
  3. Create another Prompt Node, and give it a prompt message that will take a much longer time, such as "Describe to me in detail the story of Hamlet." Connect it to the Prompt input of the second LLM Chat Node.
  4. Connect both Response outputs of the LLM Chat Nodes to a Race Inputs node.
  5. Run the graph. Notice that the first LLM call finishes first, and the value of the Race Inputs node is the response from that node. The other LLM call gets canceled.

Race Inputs Node Example 1

Error Handling

The Race Inputs Node will not error if none of the inputs finish. Instead, the Result output will not be ran.

FAQ

Q: What happens if none of the inputs finish?

A: If none of the inputs finish, the Race Inputs Node will not error. Instead, the Result output will not be ran.

Q: Can I use the Race Inputs Node with inputs of different data types?

A: Yes, the Race Inputs Node can handle inputs of any data type.

Q: What happens if one of the inputs errors?

A: If one of the inputs errors, the Race Inputs Node will not be affected. It will still output the value of the first input to finish, regardless of whether other inputs error.

See Also