Jinja Templating

Variables

When deploying an AI Agent, your API calls will typically consist of two types of content:

  • Fixed content Static instructions or context that remain constant across multiple interactions

  • Variable content: Dynamic elements that change with each request or conversation, such as:

    • User inputs

    • Retrieved content for Retrieval-Augmented Generation (RAG)

    • Conversation context such as user account history

    • System-generated data such as tool use results fed in from other independent calls to Claude

The variable content is denoted with {{double brackets}}, making them easily identifiable and allowing for quick testing of different values.

In the example below, there is a JSON object with a title and pageContent that is passed to the LLM Prompt

See the Example here

Conditional statements

It is a common use-case that the same AI Agent example might be deployed/integrated on various platforms like SLACK, WHATSAPP, WEB and so on. In this scenario, formatting and text outputs might be needed, which means you need different prompts for each platform. With Jinja Templating, this issue is solved. You can use the prompt example below and tweak it as needed:

Last updated

Was this helpful?