Chat with your Data (RAG)
In this tutorial, you'll learn how to use chat to converse with your data using AI.
What is RAG?
RAG (Retrieval-Augmented Generation) is a technique that combines:
Retrieval: Finds the most relevant information in your data
Augmented Generation: Uses that information as context for AI to generate a response
Result: Accurate answers based on your data, without hallucinations.
Search vs Chat: Which to Use?
Need exact excerpts
Search
Returns original chunks
Need an elaborate answer
Chat
AI synthesizes the information
Need to cite exact source
Both
Chat returns sources
High performance/low latency
Search
No LLM call
Complex questions
Chat
AI interprets and responds
Prerequisites
A valid
tenant_id(See how to find it)Data already ingested in the Knowledge Base
Step 1: Ask a Question
Step 2: Understand the Response
Response Fields
answer
AI-generated answer based on your data
sources
List of sources used to generate the answer
sources[].id
Chunk ID in the vector database
sources[].score
Source relevance (0-1)
sources[].text
Original excerpt used as context
sources[].snack_item_id
Source item ID
sources[].snack_elemental_id
Source elemental ID
Step 3: Use Filters for Specific Context
You can direct chat to search in specific data:
This ensures the AI only uses documents with these tags as context.
Using Streaming for Real-time Chat
For real-time chat interfaces, use the streaming endpoint:
The response comes as Server-Sent Events (SSE):
To implement streaming in the frontend, see the guide Real-time Chat.
Understanding Citations (Sources)
The sources allow you to verify where each piece of information came from:
You can use these IDs to:
Link to the original document in your interface
Show users the source of information
Validate response accuracy
Tips for Better Responses
1. Be Specific in Your Question
2. Use Filters for Context
If you know where the information is, use filters:
3. Comparison Questions Work Well
4. List Questions Work Well
When Chat Doesn't Find Information
If the AI doesn't find relevant information, it will respond something like:
What to do:
Check if the data was ingested correctly
Try rephrasing the question
Remove overly restrictive filters
Use semantic search to explore available data
Next Steps
Now that you've mastered RAG chat:
Real-time Chat - Implement streaming in the frontend
Filter by Tags - Direct context with precision
Error Handling - Handle errors gracefully
Estimated time: 10 minutes ✅
Last updated
Was this helpful?