Skip to main content

[Advanced] Liquid Variables: Access Content Storage.

Learn to use Liquid variables for precise control over Content Storage searches in your prompts, beyond the simple Context switch method.

Written by Promptitude Team
Updated today

If you've been using Promptitude's Context switch to automatically pull information from your Content Storage, you might be ready to take more control over how and what content gets retrieved.

This guide will show you how to use Liquid variables to perform precise searches that give you exactly the content you need, formatted exactly how you want it. While this method requires a bit more setup than the simple Context switch, it opens up powerful possibilities for creating more sophisticated prompts that can adapt to different scenarios and user inputs.

When to Use This Feature

Before diving into the technical details, let's clarify when you should consider using this advanced method instead of the simpler Context switch on your prompt's Input tab.

πŸ“Œ Stick with the Context switch if: you want automatic content retrieval that works behind the scenes without any configuration. It's perfect for straightforward use cases where you just want relevant content to appear based on user input.

πŸ“Œ Use Liquid variables when you need:

  • Precise control over which folders and tags to search

  • Dynamic searches where the folders or tags to search come from user input

  • Multiple separate searches within a single prompt

  • Custom formatting of results (JSON, plain text, or specific layouts)

  • Variable result quantities depending on the situation

For example, if you're building a customer support bot where different departments need different knowledge bases, or if you want users to specify which product documentation they're asking about, the advanced Liquid method gives you that flexibility.


What is Content Search?

Content Search is your gateway to accessing the knowledge you've stored in Content Storage. Think of it as your personal search engine that looks through all your uploaded documents, guides, policies, and other materials to find the most relevant information for any given question or topic.

This feature is incredibly powerful because it allows your AI responses to be grounded in your specific information rather than relying solely on general knowledge. Here's why this matters:

  • Accuracy: Your AI gets up-to-date information from your actual documents

  • Relevance: Responses are based on your organization's specific content

  • Consistency: All answers align with your established documentation

  • Reliability: Reduces the chance of the AI making up information (hallucinations)

Behind the scenes, Content Search uses RAG (Retrieval-Augmented Generation) technology. Don't worry about the technical jargon – just know that it's a smart system that understands the meaning behind your search query and finds the most semantically similar content from your knowledge base.


How Does It Work?

The process is straightforward: you provide a search query (usually from user input), specify where to look (folders and tags), and get back the most relevant content chunks.

Here's a simple comparison to help you understand the difference:

πŸ“Œ With the Context switch: Your prompt automatically searches all your content based on user input. It's like having a helpful assistant who automatically brings you relevant files without you asking.

πŸ“Œ With Liquid variables: You explicitly tell the system where to look and how many results you want. It's like being specific with your assistant: "Please search the HR documents, specifically those tagged 'benefits,' and bring me the top 3 most relevant pieces."

Let's look at a basic example. If you have an input variable called user_question where users type their questions, you could write:

{{ user_question | content_search: "help-docs", "troubleshooting" }}

This tells the system: "Take whatever the user asked in user_question, search only in the 'help-docs' folder, look specifically for content tagged 'troubleshooting,' and return the most relevant results."

✏️ Basic Syntax

The basic structure for Content Search using Liquid variables follows this pattern:

{{ query_variable | content_search: folders, tags, chunks, minSimilarity, format }}

Don't let this syntax intimidate you – each part has a clear purpose, and you only need to specify what you want to customize.


Understanding Query Variables

The query variable is typically an input variable you create on the Input tab of your prompt editor. This variable captures what users want to search for.

Here's how to set this up:

πŸ“Œ Step 1: Create an input variable (let's call it user_question)

  • Type: Text

  • Label: Something user-friendly like "What would you like to know?"

πŸ“Œ Step 2: Use it in your prompt:

{{ user_question | content_search: "documentation" }}

When a user types "How do I reset my password?" into the user_question field, that text becomes your search query. The system then looks through your "documentation" folder to find content related to password resets.

You can also use multiple variables for more dynamic searches. For instance, if you have separate variables for topic and department, you could search different folders based on user selections.

✏️ Parameters

Parameters let you fine-tune your search. The good news is that you can skip parameters you don't need – they'll just use sensible defaults. However, you must provide them in order, and you can't skip middle parameters.

Here are your options:

Parameter

Type

Default

Description

folders

String

all folders

Folder name(s) to search. Use semicolon-separated for multiple: "docs;guides". Use "" to search all folders.

tags

String

all tags

Tag name(s) to filter by. Use semicolon-separated for multiple: "api;tutorial". Use "" to search all tags.

chunks

Integer

5

Number of results to return (1-50)

minSimilarity

Integer

70

Minimum similarity score as percentage: 0, 10, 20, 30, 40, 50, 60, 70, 80, or 90

format

String

markdown

Output format: text, textWithMetadata, markdown, or json

maxTokens

Integer

1500

Maximun tokens to use

πŸ”” Important note: When specifying multiple folders or tags, use semicolons (;) as separators, not commas. This is because folder and tag names might contain commas themselves.

Example configurations:

  • {{ query | content_search: "docs" }} - uses defaults for tags, chunks, minSimilarity, format

  • {{ query | content_search: "docs", "api", 10 }} - uses defaults for minSimilarity and format

  • You cannot skip middle parameters (you can't skip tags but provide chunks)

By mastering these Liquid variables, you'll have complete control over how your prompts access and use your Content Storage, creating more targeted and effective AI interactions for your specific needs.

βœ… Next Steps and Related Articles

After familiarizing yourself with the basics of using Liquid variables for content retrieval, you can deepen your skills with the following help articles:

  1. Simple and Complex Examples

    • Dive into a variety of examples that illustrate both straightforward and intricate uses of Liquid variables to enhance your understanding and application.

  2. Output Formats and Advanced Usage

    • Explore different ways to format your retrieved content, including JSON and structured data, and learn advanced techniques for leveraging Liquid variables in complex scenarios.

  3. Best Practices, Tips, and Common Mistakes

    • Gain insights into organizing your content storage effectively, common pitfalls to avoid, and tips to optimize the performance and accuracy of your AI prompts.

These resources will equip you with the knowledge to use Liquid variables more effectively, allowing you to build powerful AI-driven solutions with precision and reliability.

Did this answer your question?