Text
Last updated
Last updated
Text nodes allow you to write text to send as inputs to other nodes.
You can define variables in Text nodes using bracket notation: {{ variable }}
. Ensure you usre two brackets.
Defining variables will add input handles to your Text node and serve as placeholders for textual information; information from the node that you connect to the handle associated with your Text node's variable will replace whatever {{ variable }}
you define in the node's final output.
Use a text node when you want to input raw text that does not change between runs into your pipeline.
Some examples or common use cases for Text nodes include:
Composing instructions for the "system" input for LLMs
Composing prompts for the "prompt" input for LLMs
Include a link to a website to be connected to a URL data loader
Include a link to a youtube video to be connected to a youtube data loader
Text nodes support more advanced templating using handlebars syntax. To iterate over a series of objects in a template use the following pattern:
In this example, the template tells us to iterate over the input documents and store the "title" metadata field in a list.
A common use case is to select certain fields from the documents returned by a vector query node. For example, we can query for the "title" metadata of each chunk returned from a Wikipedia query.
If we run the pipeline with the query "Napoleon" we can see the list of titles for each returned chunk:
Use the "set" keyword instead of "list" to return unique elements only.