How hnib1908/chatpdf-modern works
Chat PDF is a local-first Streamlit RAG application. A user uploads PDFs, chooses extraction and chunking settings, indexes the document, selects it, asks a question, and receives a streamed or complete LLM answer with cited chunks. The main stages are ingestion, persistent vector storage, hybrid retrieval/re-ranking, prompt-based generation, and conversation persistence. The sampled code clearly shows Ollama and optional Sambanova generation; some surrounding app wiring is omitted, so only supported relationships are shown.
Components 19
User Interface
- Streamlit App
app.py - Chat UI
ui/components.py - Theme UI
ui/theme.py - Citation View
ui/components.py
Document Ingestion
- Ingest Service
app_services/ingest_service.py - PDF Processing
app_services/ingest_service.py - Markdown Converter
rag_core/md_convertor.py - Embedding Model
- Chroma Vector Store
app_services/ingest_service.py
RAG Retrieval
- RAG System
rag_core/rag.py - Vector Retriever
rag_core/rag.py - Hybrid Re-ranker
rag_core/rag.py - Prompt Builder
rag_core/rag.py - LLM Inference
rag_core/llm_inference.py
Conversation Services
- History Service
app_services/history_service.py - Chat History DB
app_services/history_service.py
Other components
- PDF User
- Ollama Runtime
- Sambanova API
Connections 23
- PDF User → Streamlit App: uploads and asks
- Streamlit App → Ingest Service: indexes PDFs
- Ingest Service → PDF Processing: extracts text
- Ingest Service → Markdown Converter: converts advanced
- Ingest Service → Embedding Model: embeds chunks
- Embedding Model → Ollama Runtime: runs embeddings
- Ingest Service → Chroma Vector Store: writes chunks
- Streamlit App → Theme UI: injects theme
- Streamlit App → Chat UI: renders controls
- Streamlit App → RAG System: submits query
- RAG System → Vector Retriever: retrieves chunks
- Vector Retriever → Chroma Vector Store: queries vectors
- RAG System → LLM Inference: creates query embedding
- LLM Inference → Ollama Runtime: embeds query
- RAG System → Hybrid Re-ranker: reranks chunks
- RAG System → Prompt Builder: builds prompt
- RAG System → LLM Inference: generates answer
- LLM Inference → Ollama Runtime: generates or streams
- LLM Inference → Sambanova API: generates answer
- RAG System → Streamlit App: returns answer and sources
- Streamlit App → Citation View: renders citations
- Streamlit App → History Service: loads and saves chats
- History Service → Chat History DB: reads and writes