RAG & Document Loading
Using document loaders and vector memory with agents to provide grounded, factual responses from your knowledge base.
🔄 Agent RAG Workflow
Basic RAG Agent
// Step 1: Create vector memory
vectorMemory = aiMemory( "chroma", {
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
RAG Agent with Real-Time Tools
📚 For Full RAG Capabilities
Related Pages
Last updated