Overview
1
Set up embeddings and vector store
Choose an embedding provider and vector store for your documents.
2
Create a KnowledgeBase
Initialize the KnowledgeBase with your vector store.
3
Add documents
Index your content into the knowledge base.
4
Create an agent with the KB tool
Use
kb.asTool() to give the agent retrieval capabilities.5
Query
Ask questions and get grounded answers.
Complete Example
In-Memory RAG
RAG with Qdrant
RAG with MongoDB Atlas
RAG with Hybrid Search
For the best retrieval accuracy, enable hybrid search. It combines semantic (vector) and keyword (BM25) matching:Customizing the Tool
TheasTool() method accepts configuration to customize how the knowledge base is exposed to the agent:
string
Name of the generated tool. Defaults to
search_<collection>.string
Description shown to the LLM. Auto-generated if not provided.
number
default:"5"
Maximum number of results to return.
number
Minimum similarity score threshold.
(results: VectorSearchResult[]) => string
Custom function to format search results into a string for the LLM.