RAG Integration
RAG (Retrieval-Augmented Generation) connects your knowledge base to your agent for accurate, contextual responses.
How RAG Works
- User asks question: "What's your return policy?"
- Retrieval: System searches knowledge base for relevant info
- Augmentation: Retrieved context is added to LLM prompt
- Generation: LLM generates response using the context
Configuration
Basic Setup
{
"knowledgeBaseId": "kb_abc123",
"ragConfig": {
"topK": 5,
"minScore": 0.7
}
}
Advanced Configuration
{
"ragConfig": {
"topK": 5,
"minScore": 0.7,
"reranking": true,
"hybridSearch": true
}
}
| Parameter | Default | Description |
|---|---|---|
topK |
5 | Number of chunks to retrieve |
minScore |
0.7 | Minimum relevance score (0-1) |
reranking |
false | Re-rank results for better relevance |
hybridSearch |
false | Combine keyword and semantic search |
System Prompt Integration
Tell your agent how to use retrieved information:
You have access to a knowledge base with company information.
When answering questions:
1. Use the provided context to answer accurately
2. If the context doesn't contain the answer, say so
3. Never make up information not in the context
4. Cite the source when relevant
If no relevant information is found, respond:
"I don't have specific information about that. Would you like me to connect you with a specialist?"
Tuning RAG Performance
Low Recall (Missing Relevant Info)
- Decrease
minScore(e.g., 0.5) - Increase
topK(e.g., 10) - Check document quality
Low Precision (Irrelevant Info)
- Increase
minScore(e.g., 0.8) - Decrease
topK(e.g., 3) - Improve document chunking
Best Practice Scores
| Use Case | topK | minScore |
|---|---|---|
| FAQ/Support | 3 | 0.8 |
| Product Info | 5 | 0.7 |
| General Knowledge | 7 | 0.6 |
Debugging
Enable RAG debugging to see what's being retrieved:
- Go to Call History
- Open a call transcript
- View RAG Context for each turn