Knowledge Base (RAG)¶
Give your AI agents domain-specific knowledge by uploading documents. The knowledge base uses Retrieval-Augmented Generation (RAG) to provide accurate, context-aware responses grounded in your own data.
Overview¶
The knowledge base system:
- Upload — Add documents (PDF, DOCX, TXT, CSV)
- Process — Documents are chunked and embedded
- Store — Embeddings are stored for semantic search
- Retrieve — When a user asks a question, relevant chunks are retrieved
- Generate — The AI uses retrieved context to generate accurate responses
Uploading Documents¶
Via the Agent Studio¶
- Open the Agent Studio (agent creation wizard)
- Navigate to the Knowledge Base step
- Click Upload Documents
- Select files from your computer
- Wait for processing to complete
- Click Continue
Supported File Types¶
| Format | Description | Max Size |
|---|---|---|
| Portable Document Format | 50 MB | |
| DOCX | Microsoft Word document | 25 MB |
| TXT | Plain text file | 10 MB |
| CSV | Comma-separated values | 10 MB |
| MD | Markdown file | 10 MB |
Processing¶
When a document is uploaded:
- Text Extraction — Content is extracted from the file
- Chunking — Text is split into semantic chunks (~500 tokens each)
- Embedding — Each chunk is converted to a vector embedding
- Storage — Embeddings are stored in the knowledge base
Processing typically takes 1-5 minutes depending on document size.
Managing Knowledge Files¶
Viewing Uploaded Files¶
- Open the agent details
- Navigate to the Knowledge Base section
- View the list of uploaded files:
| Column | Description |
|---|---|
| File Name | Name of the uploaded file |
| Size | File size |
| Chunks | Number of text chunks extracted |
| Status | Processing, Ready, Error |
| Uploaded | Upload date |
Adding More Documents¶
You can add documents at any time:
- Open the agent details
- Click Add Documents
- Upload new files
- Wait for processing
New documents are immediately available for retrieval.
Removing Documents¶
- Open the knowledge base
- Find the file to remove
- Click Delete
- Confirm removal
The file’s chunks and embeddings are permanently deleted.
How RAG Works¶
Retrieval Process¶
When a user sends a message to the agent:
graph LR
A[User Message] --> B[Embed Query]
B --> C[Search Knowledge Base]
C --> D[Retrieve Top Chunks]
D --> E[Inject Context]
E --> F[Generate Response] - Embed Query — The user’s message is converted to a vector
- Semantic Search — The vector is compared against stored embeddings
- Retrieve Chunks — The most relevant chunks are selected (top-k)
- Inject Context — Retrieved chunks are added to the AI’s prompt
- Generate Response — The AI generates a response using the context
Retrieval Configuration¶
| Setting | Description | Default |
|---|---|---|
| Top-K | Number of chunks to retrieve | 5 |
| Similarity Threshold | Minimum relevance score | 0.7 |
| Max Context Length | Maximum tokens from knowledge base | 3,000 |
Best Practices for Knowledge Bases¶
Document Quality¶
- Use clear, well-structured documents — The AI can only retrieve what’s there
- Include headers and sections — Helps with chunking quality
- Keep documents current — Remove outdated information
- Be specific — Detailed documents produce better retrieval results
Document Organization¶
- One topic per document — Avoid mixing unrelated topics
- Use consistent formatting — Standardize document structure
- Name files descriptively — Makes management easier
- Version control — Re-upload when documents change significantly
Common Use Cases¶
| Use Case | Document Types |
|---|---|
| Product Support | Product manuals, FAQ docs, troubleshooting guides |
| Company Policies | HR handbooks, policy documents, compliance guides |
| Sales Enablement | Product catalogs, pricing sheets, case studies |
| Technical Docs | API documentation, architecture guides, runbooks |
| Training Materials | Course content, onboarding guides, SOPs |
Storage¶
Knowledge base files are stored in the agent-knowledge Supabase Storage bucket:
- Files are stored per-user in isolated folders
- Access is controlled by authentication
- Files are encrypted at rest
- Processing is handled by the
process-knowledgeedge function
Limitations¶
| Limitation | Value |
|---|---|
| Max files per agent | 50 |
| Max file size | 50 MB (PDF), 25 MB (DOCX), 10 MB (others) |
| Total storage per agent | 500 MB |
| Max chunks per agent | 10,000 |
Troubleshooting¶
Document stuck in “Processing”¶
- Wait up to 10 minutes for large files
- Check file format is supported
- Try re-uploading the file
- Contact support if the issue persists
Agent not using knowledge base¶
- Verify documents are in “Ready” status
- Check that the query is related to the document content
- Try rephrasing the question
- Add more relevant documents to the knowledge base
Poor response quality¶
- Review document quality and structure
- Add more specific documents
- Check retrieval settings (top-k, threshold)
- Ensure documents are up to date
What’s Next¶
- Website Analysis — Auto-generate prompts from websites
- Voice AI — Set up voice agents with phone integration
AĂşn con dudas? Pregunta en Discord o explore tutoriales