mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
One version for the Go, TypeScript and Python SDKs and the templates. Co-authored-by: Hanzo Dev <[email protected]>
Agentic RAG - Hallucination-Proof Document Q&A
Production-ready RAG system with ensemble retrieval, iterative refinement, and claim verification.
Features
- ✅ Lazy-indexed ensemble retrieval (semantic + keyword + type-specific)
- ✅ Confidence-driven iterative refinement
- ✅ Parallel claim verification (anti-hallucination)
- ✅ FastEmbed for semantic search
- ✅ Memory-backed caching
Quick Start
1. Install Dependencies
cd examples/python_agent_nodes/agentic_rag
pip install -r requirements.txt
2. Set Environment
export OPENAI_API_KEY="your-key"
export HANZO_AGENTS_SERVER="http://localhost:8080"
3. Start Agent
python main.py
4. Query Document
curl -X POST http://localhost:8080/v1/execute/agentic-rag.query_document \
-H "Content-Type: application/json" \
-d '{
"input": {
"file_path": "examples/python_agent_nodes/agentic_rag/sample_document.txt",
"question": "When was the Dartmouth Conference?"
}
}'
Example Output
{
"answer": "The Dartmouth Conference was held in 1956...",
"citations": [
{
"chunk_id": "chunk_0_a3f2b1c8",
"quote": "The field was officially founded in 1956...",
"page_num": 0
}
],
"confidence_score": 0.92,
"verification_summary": {
"verified": 2,
"uncertain": 0,
"removed": 0
},
"completeness_score": 0.95,
"gaps": []
}
Architecture
7-phase pipeline:
- Smart Chunking - Intelligent text segmentation
- Query Analysis - Complexity assessment & routing
- Ensemble Retrieval - 3 parallel strategies
- Iterative Refinement - Confidence-driven loops
- Claim Verification - Parallel fact-checking
- Answer Synthesis - Verified claims only
- Quality Check - Completeness assessment
Files
main.py- Agent with all reasonersschemas.py- Simple Pydantic models (2-4 fields)skills.py- Deterministic functions + embeddingsembedding_manager.py- FastEmbed wrappersample_document.txt- Test document
License
Apache 2.0