Cookbook
RAG in 15 lines
createRAG with a file vector store. Working retrieval in under a screen of code.
RAG does not require a vector database, a cluster, or a PhD. Start here, swap pieces later.
import { createRAG } from '@agentskit/rag'
import { openaiEmbedder } from '@agentskit/adapters'
import { fileVectorMemory } from '@agentskit/memory'
const rag = createRAG({
embed: openaiEmbedder({ apiKey: process.env.OPENAI_API_KEY! }),
store: fileVectorMemory({ path: './vectors.json' }),
})
await rag.ingest([
{ id: 'streams', content: 'AgentsKit adapters emit streaming chunks.' },
])
const context = await rag.retrieve({
query: 'how do streams work?',
messages: [],
})Tip
Swap fileVectorMemory for another VectorMemory implementation without
changing the RAG pipeline.
Note
ingest embeds and stores every supplied chunk. Idempotency and replacement
semantics belong to the injected vector store.
Explore nearby
- PeerCookbook
Copy-paste recipes for the things every agent app needs. Each recipe stands on its own.
- PeerStreaming chat
useChat + abort + back-pressure. The minimum viable streaming chat, production-ready.
- PeerTools + memory together
The "chat with state and actions" loop β persistent memory plus tool execution.