RAG & Document Loading
Using document loaders and vector memory with agents to provide grounded, factual responses from your knowledge base.
Agents can leverage document loaders and vector memory to access knowledge bases and provide grounded, factual responses.
🔄 Agent RAG Workflow
Basic RAG Agent
// Step 1: Create vector memory
vectorMemory = aiMemory( memory: "chroma", config: {
collection : "product_docs",
embeddingProvider: "openai",
embeddingModel : "text-embedding-3-small"
} )
// Step 2: Ingest documents
result = aiDocuments( "/docs/products", {
type : "directory",
recursive : true,
extensions: [ "md", "txt", "pdf" ]
} ).toMemory(
memory : vectorMemory,
options : { chunkSize: 1000, overlap: 200 }
)
println( "Loaded #result.documentsIn# documents as #result.chunksOut# chunks" )
// Step 3: Create agent with vector memory
agent = aiAgent(
name : "Product Support",
description : "Product documentation specialist",
instructions: "Answer questions using the product documentation. Always cite sources.",
memory : vectorMemory
)
// Step 4: Query — agent automatically retrieves relevant docs
response = agent.run( "How do I configure SSL certificates?" )Multi-Source RAG Agent
Combine multiple knowledge bases by passing an array of memories:
RAG Agent with Real-Time Tools
Combine document retrieval with live data access:
📚 For Full RAG Capabilities
This page covers agent-level RAG setup. For deeper detail on:
Document loaders (PDF, CSV, JSON, XML, HTTP, web crawlers, SQL, etc.) — see Document Loaders
Chunking strategies, batch loading, async ingestion — see RAG Guide
Vector memory configuration (Pinecone, Chroma, Qdrant, pgvector, etc.) — see Vector Memory Systems
Related Pages
Memory Management — Memory types and per-call identity routing
Vector Memory Systems — Full vector store configuration
Document Loaders — All loader types
RAG Guide — End-to-end RAG implementation
Last updated