Knowledge Base Overview
Agentium provides a KnowledgeBase abstraction for Retrieval-Augmented Generation (RAG). Store documents in a vector store, search by semantic similarity, and expose retrieval as a tool so agents can answer questions using your private data.What is RAG?
Retrieve
Convert documents to embeddings, store in a vector database, and search by semantic similarity.
Augment
Inject retrieved chunks into the LLM context before generating a response.
Generate
The model produces answers grounded in the retrieved content instead of relying only on its training data.
KnowledgeBase Class
string
required
Display name for the knowledge base. Used in tool descriptions.
VectorStore
required
A vector store implementation (InMemory, PgVector, Qdrant, MongoDB).
string
Collection/index name inside the vector store. Defaults to a sanitized version of
name."vector" | "keyword" | "hybrid"
default:"vector"
Default search strategy.
"hybrid" combines vector + keyword search via Reciprocal Rank Fusion for the best results. See Hybrid Search.HybridSearchConfig
Fine-tune hybrid search weights and RRF constant. See Hybrid Search.
asTool() — Expose KB to Agents
The most powerful feature: turn a KnowledgeBase into a ToolDef that agents can call automatically.string
Tool name exposed to the LLM. Default:
search_<collection>.string
Custom tool description. Default: auto-generated from KB name.
number
default:"5"
Number of results to return per search.
number
Minimum similarity score to include a result.
Record<string, unknown>
Metadata filter applied to every search.
"vector" | "keyword" | "hybrid"
Override search mode for this tool. Inherits from KB config if not set.
(results) => string
Custom formatter for search results. Default: numbered list with scores.
Flow Diagram
1
Create KnowledgeBase
Configure name, vector store, and optional collection.
2
Initialize
Call
kb.initialize() to ensure the vector store is ready.3
Add Documents
Use
add() or addDocuments() to ingest content. Embeddings are computed if not provided.4
Expose as Tool
Call
kb.asTool() and pass the result to Agent({ tools: [...] }).5
Query
When the user asks a question, the agent calls the search tool and uses results in its response.
Next Steps
- Vector Stores — InMemory, PgVector, Qdrant, MongoDB
- Embeddings — OpenAI and Google embedding providers
- Hybrid Search — BM25, RRF, and hybrid search modes
- RAG Example — End-to-end walkthrough