Skip to main content
Context Management
RAG Quick Start
Build retrieval-augmented agents that answer from your documents and knowledge bases
RAG agents retrieve relevant chunks from your documents before answering, grounding responses in your own knowledge.
The user asks from their documents; the agent retrieves relevant chunks and grounds the reply.
Every stage below is now configurable from
Install knowledge extras:
How
KnowledgeConfig after the fields were wired up.
Quick Start
1
Simple Usage
Pass file paths or directories — the agent indexes on first run, then retrieves on each query:
2
With Configuration
Use
KnowledgeConfig for vector store, chunking, and reranking:With a different embedder provider
Setembedder_config to embed with Gemini, Cohere, or a local Ollama model instead of OpenAI.
- Gemini
- Cohere
- Ollama
How It Works
For pre-indexed stores, pass vector config via task context or call
agent.retrieve("query") directly.
Configuration Options
config={...} now updates the resolved retrieval config instead of replacing it — setting retrieval_k=20, config={"note":"mine"} keeps retrieval_k=20 (previously it silently reset to 5).pip install "praisonaiagents[knowledge]"
How config= overrides work
config={...} merges on top of the values resolved from KnowledgeConfig fields — it patches individual keys instead of replacing the whole config.
Every knob wired up
Chunking, vector store, retrieval, and reranking are all set from oneKnowledgeConfig.
Opting out of automatic context injection
Setauto_retrieve=False to retrieve manually instead of injecting context on every prompt.
Best Practices
Index documents before querying
Index documents before querying
Pass sources via
knowledge=["file.pdf"] at agent creation — first run indexes, later runs retrieve without re-indexing.Use specific questions
Use specific questions
Narrow questions retrieve better chunks than broad prompts like “tell me everything”.
Use persistent vector stores in production
Use persistent vector stores in production
Set
vector_store with Chroma path, Qdrant, or Pinecone — avoid in-memory stores for production.Combine RAG with tools for live data
Combine RAG with tools for live data
Pair
knowledge= with web tools when you need both static documents and real-time data.Related
Vector Store
Pluggable embedding storage
Knowledge
Sources and retrieval strategies


