How aarthireddyyy/selfheal_rag works
This repository is a self-healing retrieval-augmented question-answering service. Its main workflow validates a user question, retrieves and reranks knowledge-base chunks, generates an answer, and grades groundedness; incomplete answers get a caveat, while failures trigger query rewrites and bounded retries before an honest fallback. A separate ingestion workflow loads and semantically chunks documents into persistent vector storage. The graph preserves the README’s hybrid-search, security, and API capabilities. Relationships involving the omitted portions of the agent are supported by its excerpts or README; no unshown implementation details are assumed.
Main entry points: rag_agent.py Grade Router · retriever.py Hybrid Search · ingest.py Chroma Store · api.py REST API
Components 21
API and Security
- REST API
src/api.py - Input Guardrails
src/guardrails.py
Knowledge Ingestion
- Document Ingestion
src/ingest.py - Knowledge Documents
- Semantic Chunking
src/ingest.py - Chroma Store
src/ingest.py
Self-Healing Answering
- RAG Agent
src/rag_agent.py - Retrieve Node
src/rag_agent.py - Answer Generation
src/rag_agent.py - Groundedness Grader
src/rag_agent.py - Grade Router
src/rag_agent.py - Query Rewrite
src/rag_agent.py - Partial Answer
src/rag_agent.py - Give-Up Response
src/rag_agent.py
Hybrid Retrieval
- Hybrid Search
src/retriever.py - Vector Search
src/retriever.py - BM25 Search
src/retriever.py - Cross-Encoder Reranker
src/retriever.py
Other components
- Questioner
- Groq LLM
- Answer and Sources
Connections 29
- Questioner → REST API: submits question
src/api.py - REST API → Input Guardrails: checks input
src/api.py - REST API → RAG Agent: invokes query
src/api.py - RAG Agent → Retrieve Node: starts workflow
src/rag_agent.py - Retrieve Node → Hybrid Search: calls retrieval
src/rag_agent.py - Hybrid Search → Vector Search: searches vectors
src/retriever.py - Hybrid Search → BM25 Search: searches keywords
src/retriever.py - Hybrid Search → Cross-Encoder Reranker: reranks candidates
src/retriever.py - Retrieve Node → Chroma Store: opens store
src/rag_agent.py - Vector Search → Chroma Store: searches store
src/retriever.py - BM25 Search → Chroma Store: reads chunks
src/retriever.py - Retrieve Node → Answer Generation: then generates
src/rag_agent.py - Answer Generation → Groq LLM: requests completion
src/rag_agent.py - Answer Generation → Groundedness Grader: grades answer
src/rag_agent.py - Groundedness Grader → Groq LLM: requests judgment
src/rag_agent.py - Groundedness Grader → Grade Router: routes by grade
src/rag_agent.py - Grade Router → Query Rewrite: retries failures
src/rag_agent.py - Query Rewrite → Groq LLM: rewrites query
src/rag_agent.py - Query Rewrite → Retrieve Node: retries retrieval
src/rag_agent.py - Grade Router → Partial Answer: returns partial
src/rag_agent.py - Grade Router → Give-Up Response: ends exhausted
src/rag_agent.py - Grade Router → Answer and Sources: returns passing answer
README.md - Partial Answer → Answer and Sources: adds caveat
src/rag_agent.py - Give-Up Response → Answer and Sources: returns fallback
src/rag_agent.py - RAG Agent → Answer and Sources: returns result
src/rag_agent.py - Knowledge Documents → Document Ingestion: loads files
README.md - Document Ingestion → Semantic Chunking: splits semantically
src/ingest.py - Semantic Chunking → Chroma Store: stores chunks
src/ingest.py - Answer and Sources → Questioner: serves response
README.md