How devanshsharma27/queryflow-ai works
Smart AI Agent is a Streamlit chat application backed by a FastAPI service and a LangGraph agent. Users can upload PDFs to a Pinecone knowledge base, then ask questions; the agent routes requests through RAG, judges whether retrieved context is sufficient, optionally searches the web, and generates an answer with a visible workflow trace. The graph preserves PDF parsing, indexing, and retrieval as distinct stages. Agent internals and some documented capabilities are represented from partial source excerpts and README descriptions; uncertain wiring is omitted.
Main entry points: app.py Chat App · backend_api.py Backend Client · agent.py Query Router · main.py Chat Endpoint
Components 20
User Interface
- Chat App
frontend/app.py - Session State
frontend/session_manager.py - UI Components
frontend/ui_components.py - Backend Client
frontend/backend_api.py
API Service
- Chat Endpoint
backend/main.py - Upload Endpoint
backend/main.py - PDF Extraction
backend/main.py - Trace Events
backend/main.py
Agent Workflow
- Query Router
backend/agent.py - RAG Lookup
backend/agent.py - RAG Judge
backend/agent.py - Web Search
backend/agent.py - Answer Generator
backend/agent.py
Knowledge Base
- Vector Retriever
backend/vectorstore.py - Text Chunking
backend/vectorstore.py - Text Embeddings
backend/vectorstore.py - Pinecone Index
backend/vectorstore.py
Other components
- User
- Groq LLM
- Tavily Search
Connections 31
- User → Chat App: sends query
- Chat App → Session State: initializes state
- Chat App → UI Components: renders controls
- Chat App → Backend Client: submits chat
- UI Components → Backend Client: uploads PDF
- Backend Client → Chat Endpoint: posts query
- Backend Client → Upload Endpoint: posts file
- Chat Endpoint → Query Router: streams agent
- Chat Endpoint → Trace Events: formats events
- Trace Events → Backend Client: returns trace
- Backend Client → Chat App: returns answer
- Chat App → UI Components: displays trace
- Upload Endpoint → PDF Extraction: loads PDF
- Upload Endpoint → Text Chunking: indexes text
- Query Router → Groq LLM: requests route
- Query Router → RAG Lookup: dispatches RAG
- Query Router → Web Search: dispatches web
- Query Router → Answer Generator: dispatches answer
- RAG Lookup → Vector Retriever: retrieves chunks
- RAG Lookup → RAG Judge: judges context
- RAG Judge → Groq LLM: requests verdict
- RAG Judge → Web Search: dispatches if lacking
- RAG Judge → Answer Generator: dispatches if sufficient
- Web Search → Tavily Search: searches query
- Web Search → Answer Generator: provides results
- Answer Generator → Groq LLM: generates response
- PDF Extraction → Text Chunking: provides text
- Text Chunking → Text Embeddings: creates chunks
- Text Embeddings → Pinecone Index: indexes vectors
- Vector Retriever → Text Embeddings: embeds query
- Vector Retriever → Pinecone Index: retrieves vectors