How nepseli/langchain-rag-agent works
This is a Streamlit-based financial-document RAG agent. Users upload documents for extraction and indexing, then ask questions; the agent may clarify ambiguity, retrieve evidence, fetch structured tables, execute calculations, and generate cited answers. The graph preserves the documented workflow and major OCR, table, HyDE, comparative-retrieval, and per-document-cap capabilities. Some feature details and call paths are documented rather than shown in sampled source, so unverified relationships are omitted.
Main entry points: graph.py Agent workflow · pipeline.py Ingestion pipeline · streamlit_app.py Chat and uploads · vector_store.py Vector index
Components 21
User interface
- Chat and uploads
app/streamlit_app.py - Runtime settings
config.py
Document ingestion
- Ingestion pipeline
core/ingestion/pipeline.py - Document loaders
core/ingestion/document_loader.py - OCR supplement
core/ingestion/ocr.py - Table extraction
core/ingestion/table_extractor.py - Text and table chunks
core/ingestion/chunker.py
Question answering
- Agent workflow
core/agent/graph.py - Clarity check
core/agent/nodes.py - Clarification response
core/agent/nodes.py - Query classification
core/agent/nodes.py - HyDE rewriting
core/agent/nodes.py - Chunk retrieval
core/agent/nodes.py - Table data fetch
core/agent/nodes.py - Calculation execution
core/agent/nodes.py - Answer generation
core/agent/nodes.py
Retrieval and state
- Document data models
models/schemas.py - Metadata and chat store
core/retrieval/metadata_store.py - Vector index
core/retrieval/vector_store.py
Other components
- User
- OpenAI models
Connections 30
- User → Chat and uploads: uploads and asks
README.md - Chat and uploads → Ingestion pipeline: ingests uploads
app/streamlit_app.py - Chat and uploads → Agent workflow: invokes questions
app/streamlit_app.py - Chat and uploads → Metadata and chat store: lists documents
app/streamlit_app.py - Chat and uploads → Vector index: deletes indexed chunks
app/streamlit_app.py - Ingestion pipeline → Document loaders: loads files
core/ingestion/pipeline.py - Ingestion pipeline → OCR supplement: supplements page text
core/ingestion/pipeline.py - Ingestion pipeline → Table extraction: extracts tables
core/ingestion/pipeline.py - Ingestion pipeline → Text and table chunks: creates chunks
core/ingestion/pipeline.py - Ingestion pipeline → Metadata and chat store: records documents and tables
core/ingestion/pipeline.py - Ingestion pipeline → Vector index: indexes chunks
core/ingestion/pipeline.py - Agent workflow → Clarity check: registers first node
core/agent/graph.py - Agent workflow → Clarification response: routes unclear queries
core/agent/graph.py - Agent workflow → Query classification: routes clear queries
core/agent/graph.py - Agent workflow → HyDE rewriting: routes classified queries
core/agent/graph.py - Agent workflow → Chunk retrieval: routes rewritten queries
core/agent/graph.py - Agent workflow → Table data fetch: routes table queries
core/agent/graph.py - Agent workflow → Calculation execution: routes calculations
core/agent/graph.py - Agent workflow → Answer generation: routes answer generation
core/agent/graph.py - Clarity check → Metadata and chat store: checks indexed documents
core/agent/nodes.py - Query classification → OpenAI models: classifies query
core/agent/nodes.py - HyDE rewriting → OpenAI models: generates hypothetical answer
README.md - Chunk retrieval → Vector index: searches chunks
core/agent/nodes.py - Table data fetch → Metadata and chat store: loads table data
core/agent/graph.py - Calculation execution → OpenAI models: generates calculation code
core/agent/nodes.py - Answer generation → OpenAI models: generates cited answer
core/agent/nodes.py - Chat and uploads → Metadata and chat store: creates chat session
app/streamlit_app.py - Ingestion pipeline → Document data models: creates document records
core/ingestion/pipeline.py - Vector index → OpenAI models: embeds chunks and queries
core/retrieval/vector_store.py - Runtime settings → Vector index: configures embedding model
config.py