Saltar a contenido

🤖 Explicar con IA

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:

  1. Upload — Add documents (PDF, DOCX, TXT, CSV)
  2. Process — Documents are chunked and embedded
  3. Store — Embeddings are stored for semantic search
  4. Retrieve — When a user asks a question, relevant chunks are retrieved
  5. Generate — The AI uses retrieved context to generate accurate responses

Uploading Documents

Via the Agent Studio

  1. Open the Agent Studio (agent creation wizard)
  2. Navigate to the Knowledge Base step
  3. Click Upload Documents
  4. Select files from your computer
  5. Wait for processing to complete
  6. Click Continue

Supported File Types

Format Description Max Size
PDF 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:

  1. Text Extraction — Content is extracted from the file
  2. Chunking — Text is split into semantic chunks (~500 tokens each)
  3. Embedding — Each chunk is converted to a vector embedding
  4. Storage — Embeddings are stored in the knowledge base

Processing typically takes 1-5 minutes depending on document size.

Managing Knowledge Files

Viewing Uploaded Files

  1. Open the agent details
  2. Navigate to the Knowledge Base section
  3. 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:

  1. Open the agent details
  2. Click Add Documents
  3. Upload new files
  4. Wait for processing

New documents are immediately available for retrieval.

Removing Documents

  1. Open the knowledge base
  2. Find the file to remove
  3. Click Delete
  4. 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]
  1. Embed Query — The user’s message is converted to a vector
  2. Semantic Search — The vector is compared against stored embeddings
  3. Retrieve Chunks — The most relevant chunks are selected (top-k)
  4. Inject Context — Retrieved chunks are added to the AI’s prompt
  5. 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-knowledge edge 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