How brenjoel/adaptive-agentic-rag works
Adaptive Agentic RAG routes a question to vector retrieval or web search, grades retrieved context, generates an answer, and checks grounding and usefulness before returning it or taking corrective action. The graph separates orchestration, workflow nodes, LLM decision/generation chains, and corpus retrieval. README documents local embeddings and Chroma; ingestion.py shows the configured retriever, but its example indexing operation is commented out. The workflow wiring is visible in graph.py; unsampled implementation details are not inferred.
Main entry points: graph.py Graph Orchestrator · ingestion.py Corpus Preparation · answer_grader.py Answer Grader · main.py Application Entry
Components 19
Application Entry
- Application Entry
main.py
RAG Workflow
- Graph Orchestrator
graph/graph.py - Workflow State
graph/state.py - Vector Retrieval
graph/nodes/retrieve.py - Document Grading
graph/nodes/grade_document.py - Web Search Fallback
graph/nodes/web_search.py - Answer Generation
graph/nodes/generate.py
LLM Chains
- Query Router
graph/chains/router.py - Relevance Grader
graph/chains/retrieval_grader.py - Generation Chain
graph/chains/generation.py - Grounding Grader
graph/chains/hallucination_grader.py - Answer Grader
graph/chains/answer_grader.py
Knowledge Sources
- Chroma Retriever
ingestion.py - Corpus Preparation
ingestion.py
Other components
- User
- Tavily Search
- Groq LLM
- Ollama Embeddings
- Web Document Loader
Connections 22
- User → Application Entry: asks question
README.md - Application Entry → Graph Orchestrator: loads graph
main.py - Graph Orchestrator → Workflow State: uses state
graph/graph.py - Graph Orchestrator → Query Router: routes question
graph/graph.py - Graph Orchestrator → Vector Retrieval: dispatches retrieval
graph/graph.py - Graph Orchestrator → Document Grading: dispatches grading
graph/graph.py - Graph Orchestrator → Web Search Fallback: dispatches fallback
graph/graph.py - Graph Orchestrator → Answer Generation: dispatches generation
graph/graph.py - Graph Orchestrator → Grounding Grader: checks grounding
graph/graph.py - Graph Orchestrator → Answer Grader: checks usefulness
graph/graph.py - Vector Retrieval → Chroma Retriever: queries retriever
graph/nodes/retrieve.py - Corpus Preparation → Web Document Loader: loads source pages
ingestion.py - Corpus Preparation → Ollama Embeddings: configures embeddings
ingestion.py - Corpus Preparation → Chroma Retriever: configures Chroma
ingestion.py - Document Grading → Relevance Grader: grades documents
graph/nodes/grade_document.py - Web Search Fallback → Tavily Search: searches web
graph/nodes/web_search.py - Answer Generation → Generation Chain: builds answer
graph/nodes/generate.py - Generation Chain → Groq LLM: invokes model
graph/chains/generation.py - Relevance Grader → Groq LLM: scores relevance
- Grounding Grader → Groq LLM: scores grounding
- Answer Grader → Groq LLM: scores usefulness
graph/chains/answer_grader.py - Query Router → Answer Grader: uses shared model
graph/chains/router.py