Template Kit

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

The promptTemplate component

Use this component 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 component, ready to be wired in. The component will replace all placeholders with values from the wired in input ports and pass the result along as output.

Input ports

The promptTemplate component has a variable number of input ports.

promptTemplate component input ports

Output ports

The promptTemplate component 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 component

Use this component to safely construct URLs. It's similar in spirit to the promptTemplate component, except it ensures that the handlebar parameters are properly encoded as part of the URL. This component 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 component has a variable number of input ports.

Outputs ports

The urlTemplate component 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