Files
zeekayandHanzo Dev ff7d100496 Everything that calls the control plane calls /v1
The server mounts /v1, /v1/ui and /v2/ui. The UI and its dev proxy, the helm
and kubernetes health probes, functional tests, project templates, examples
and scripts still called /api/v1, so the probes failed and the UI's requests
missed.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 04:10:35 -07:00

2.0 KiB

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:

  1. Smart Chunking - Intelligent text segmentation
  2. Query Analysis - Complexity assessment & routing
  3. Ensemble Retrieval - 3 parallel strategies
  4. Iterative Refinement - Confidence-driven loops
  5. Claim Verification - Parallel fact-checking
  6. Answer Synthesis - Verified claims only
  7. Quality Check - Completeness assessment

Files

  • main.py - Agent with all reasoners
  • schemas.py - Simple Pydantic models (2-4 fields)
  • skills.py - Deterministic functions + embeddings
  • embedding_manager.py - FastEmbed wrapper
  • sample_document.txt - Test document

License

Apache 2.0