RAG & Knowledge Bases
Connect your documents and data to agents through Retrieval-Augmented Generation (RAG). Give agents access to your organization's knowledge for accurate, contextual responses.
How RAG Works
RAG enhances AI responses by retrieving relevant context from your documents before generating an answer. This ensures agents have access to up-to-date, organization-specific information.
1. Ingest
Documents are chunked and embedded
2. Retrieve
Semantic search finds relevant chunks
3. Generate
Agent responds with context
Document Ingestion
Upload documents to create a searchable knowledge base. Aethyr supports multiple file formats and automatically handles chunking and embedding.
Supported Formats
Via API
const formData = new FormData();
formData.append('file', document);
formData.append('corpusId', 'my-knowledge-base');
fetch('/api/knowledge/ingest', {
method: 'POST',
body: formData
})Semantic Search
Aethyr uses pgvector for efficient semantic search. Queries are embedded and compared against document chunks using cosine similarity.
// Search the knowledge base
const results = await fetch('/api/knowledge/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: 'What is our refund policy?',
corpusId: 'company-docs',
topK: 5, // Number of results
threshold: 0.7 // Minimum similarity score
})
});
// Results include relevant chunks with scores
[
{ text: '...', score: 0.92, source: 'policies.pdf' },
{ text: '...', score: 0.87, source: 'faq.md' }
]Search Parameters
| Parameter | Type | Description |
|---|---|---|
| query | string | Natural language search query |
| corpusId | string | Knowledge base to search |
| topK | number | Number of results (default: 5) |
| threshold | number | Minimum similarity (0-1) |
Connecting to Agents
Link a knowledge base to an agent to enable automatic context retrieval during conversations.
{
"name": "Customer Support Agent",
"model": "gpt-4",
"systemPrompt": "You are a helpful support agent...",
"knowledgeBase": {
"corpusId": "support-docs",
"topK": 3,
"autoRetrieve": true // Automatically search for context
}
}