Jinja support
We support Jinja templates in the prompt. This guide will show you how to use Jinja templates in the prompt.
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:
You can refer to the variables in the JSON input as follows:
Filters
You can use the |
syntax to apply filters to the variables.
Check out the Filters in Jinja templates guide to learn more about filters.
Log variables via API
You can use our API to log variables in the prompt. Check out the guide here.
Was this page helpful?