How mohamedtarekmostafa/hybrid-rag-agent works
This is an agentic PDF-and-web question-answering application. A user submits a question in Streamlit; the UI sends it to a FastAPI endpoint, which invokes a LangGraph workflow. The router selects PDF retrieval, web search, or direct generation, and the generator returns an answer for the UI. The README also describes conversational memory and persistent checkpoints; the sampled code uses an in-memory checkpointer and a fixed thread ID in the backend. The graph follows explicit calls and documented routing; unsampled behavior is not inferred.
Main entry points: nodes.py Query Router · main.py Ask API · agent.py Graph Workflow · app.py Chat UI
Components 12
Agent Runtime
- Graph Workflow
agent.py - Query Router
nodes.py - PDF Retrieval
nodes.py - Web Search
nodes.py - Answer Generator
nodes.py
Knowledge Sources
- PDF Vector Index
tools.py - Tavily Search
Models and Memory
- Groq LLM
- Conversation Checkpoint
agent.py
Other components
- User
Connections 16
- User → Chat UI: asks
app.py - Chat UI → Ask API: posts question
app.py - Ask API → Graph Workflow: invokes
main.py - Ask API → PDF Vector Index: builds retriever
main.py - Graph Workflow → Query Router: routes with
agent.py - Query Router → PDF Retrieval: selects PDF
agent.py - Query Router → Web Search: selects web
agent.py - Query Router → Answer Generator: selects direct
agent.py - PDF Retrieval → PDF Vector Index: queries
nodes.py - Web Search → Tavily Search: searches
nodes.py - PDF Retrieval → Answer Generator: passes context
agent.py - Web Search → Answer Generator: passes results
agent.py - Answer Generator → Groq LLM: generates with
nodes.py - Query Router → Groq LLM: classifies with
nodes.py - Graph Workflow → Conversation Checkpoint: configures
agent.py - Ask API → Chat UI: returns answer
main.py