When you want more precise control over how your AI prompts access your stored content, Liquid variables offer a powerful solution. While Promptitude's automatic Context switch works great for most situations, Liquid variables let you customize exactly which content gets retrieved and how it's formatted in your prompts.
Think of this as the difference between asking someone to "grab some tools from the garage" versus "get me the Phillips head screwdriver from the red toolbox on the second shelf." Both approaches work, but the second gives you exactly what you need when you need it.
Consider using Liquid variables when:
You need to search multiple folders separately within one prompt
Your search criteria come from user inputs (like letting users choose which documentation to search)
You want specific formatting for your retrieved content
The automatic Context switch doesn't give you enough precision
You're building complex workflows that require multiple content searches
π‘ Simple Examples
Let's start with straightforward examples that show you the basic syntax and concepts.
Basic Folder Search
The simplest way to search your content storage:
{{ user_question | content_search: "documentation" }}
This takes whatever the user asked (stored in user_question) and searches through your "documentation" folder for relevant content.
Adding Tag Filters
Want to narrow down your search? Add tags to focus on specific types of content:
{{ user_question | content_search: "help-docs", "troubleshooting;faq" }}
This searches the "help-docs" folder but only looks at content tagged with either "troubleshooting" or "faq".
Searching Everywhere with Tag Focus
Sometimes you want to search all your folders but only get content with specific tags:
{{ user_question | content_search: "", "api;sdk" }}
The empty quotes for the folder name means "search everywhere", but only return content tagged with "api" or "sdk".
Getting More Results
By default, you'll get a few relevant chunks of content. If you need more comprehensive context:
{{ user_question | content_search: "documentation", "", 10 }}
This retrieves up to 10 pieces of relevant content instead of the default amount.
High-Precision Searches
For technical queries where you need very exact matches:
{{ technical_query | content_search: "engineering", "specifications", 3, 90 }}
The "90" sets a high similarity threshold, so you only get content that's very closely related to your query.
π‘ Complete Prompt Examples
Now let's see how these content searches work within full, real-world prompts.
Customer Support Assistant
Here's a complete prompt that helps answer customer questions using your support documentation:
You are a helpful customer support assistant for our company.
**Relevant Documentation:** {{ customer_question | content_search: "support-docs", "troubleshooting" }}
**Customer Question:** {{ customer_question }}
Please provide a clear, step-by-step answer based on the documentation above. If the documentation doesn't contain the answer, let the customer know and suggest they contact our support team directly.
This prompt first retrieves relevant troubleshooting content, then asks the AI to use that specific information to answer the customer's question.
Technical Documentation Assistant
For detailed technical responses that need high accuracy:
{{ user_query | content_search: "api-docs;sdk-docs", "authentication;security", 3, 80 }}
Based on the above documentation, here's how to implement secure authentication...
This searches multiple technical folders with high precision to ensure accurate, detailed technical guidance.
Multi-Source Knowledge Assistant
Sometimes you need information from different parts of your content storage:
{% assign product_info = product_query | content_search: "products", "", 3 %}
{% assign policy_info = product_query | content_search: "policies", "returns;warranty", 2 %}
**Product Information:** {{ product_info }}
**Related Policies:** {{ policy_info }}
Now I can help you with your question about {{ product_query }}
This example searches two different folders separately, giving you product details and relevant policies in one response.
Dynamic User-Controlled Search
You can let your users control what gets searched by using their input as variables:
Input Variables You'd Set Up:
user_question- What they're asking aboutsearch_folder- Which folder they want to searchsearch_tags- What types of content they want
Your prompt:
Searching your {{ search_folder }} folder for content related to "{{ search_tags }}"...
{{ user_question | content_search: search_folder, search_tags }}
Based on the above information, here's the answer to your question: {{ user_question }}
This gives users complete control over where their question gets answered from.
β Next Steps and Related Articles
Begin your journey with Liquid variables by exploring the foundational aspects and expand your skills with the subsequent help articles:
Understand the core concepts of Liquid variables, including how they function and the basic syntax needed to get started.
β
Learn about the different search parameters and how they affect your content retrieval process.
β
Discover the various output formats available and delve into advanced techniques for integrating Liquid variables in complex workflows to maximize your AI's capabilities.
β
Learn best practices for organizing your content, uncover common mistakes to avoid, and get tips to boost the efficiency and effectiveness of your AI prompts.
β
You'll learn how to format your retrieved content exactly how you need it and build sophisticated knowledge-based AI assistants that can handle complex, multi-step queries with precision and reliability.
