Template Kit

This kit contains two nodes: promptTemplate and urlTemplate. Both are intended to facilitate the often-necessary string-munging when working with LLMs or accessing APIs.

The promptTemplate node

Use this node to populate simple handlebar-style templates. It takes a string template that can contain zero or more placeholders that will be replaced with values from inputs.

Specify placeholders in the handlebar-style in format -- like `` in the template. The placeholders in the template will pop up as input ports for the node, ready to be wired in. The node will replace all placeholders with values from the wired in input ports and pass the result along as output.

Input ports

The promptTemplate node has a variable number of input ports.

promptTemplate node input ports

Output ports

The promptTemplate node has a single output:

Example

If we set our Prompt to:

Question: {{question}}
Thought: {{thought}}

And then send "How old is planet Earth" to the question input port along with "I wonder how old planet Earth is?" to the thought input port, we will get this Result:

Question: How old is planet Earth?
Thought: I wonder how old planet Earth is?

Tip

This example is captured in the board above.

Implementation:

The urlTemplate node

Use this node to safely construct URLs. It's similar in spirit to the promptTemplate node, except it ensures that the handlebar parameters are properly encoded as part of the URL. This node relies on the URI template specification to construct URLs, so the syntax is using single curly braces instead of double curly braces.

Input ports

The urlTemplate node has a variable number of input ports.

Outputs ports

The urlTemplate node has a single output port.

Example

If we set the Template to:

https://www.googleapis.com/books/v1/volumes?q={query}&orderBy=relevance

And send "utopian sci-fi" to the query input, we will see this at the URL output:

https://www.googleapis.com/books/v1/volumes?q=utopian%20sci-fi&orderBy=relevance

Implementation