
Introduction
Jinja templates are a powerful way to create dynamic prompts. You can use Jinja templates to create prompts that are tailored to the user’s input. Below are examples of how to use Jinja templates in the prompt. You can also find Jinja’s complete documentation here.Variables
This is the same as the variables in the prompt. So you can just use the{{}}
to refer to the variables.
Conditionals
You can use the{% if %}
tag to create conditionals in the prompt.
Comments
You can use the{# ... #}
syntax to add comments to the prompt.
JSON Inputs
You can use the{{ input.variable_name }}
syntax to refer to the variables in the JSON input.
For example, if you have a JSON input with the following structure:
Filters
You can use the|
syntax to apply filters to the variables.