How ikramelhattab/rag_chatbot works
This repository is a document-grounded question-answering chatbot, with OpenAI-generated answers in its primary version and a local, retrieval-only alternative. The main workflow accepts PDF/TXT documents through the web or CLI, loads and chunks them, indexes chunks in persistent Chroma storage, then retrieves relevant passages to answer questions and expose sources. The local web app uses free embeddings and returns matching context without generation. The README documents both interfaces and source attribution; sampled code confirms their distinct wiring.
Main entry points: rag_chain.py RAG chain · document_processor.py Document processor · app.py Web chatbot · cli_chat.py CLI chatbot
Components 17
User interfaces
- Web chatbot
app.py - CLI chatbot
cli_chat.py - Local web chatbot
app_local.py
Document ingestion
- Document processor
document_processor.py - PDF/TXT loaders
document_processor.py - Chunk splitter
document_processor.py
Retrieval and answering
- RAG chain
rag_chain.py - Retriever
vector_store.py - Context search
app_local.py
Index and storage
- Vector store
vector_store.py - Free vector store
vector_store_completely_free.py - Chroma database
chroma_db - Embedding model
vector_store.py - Local embeddings
vector_store_completely_free.py
Other components
- User
- PDF/TXT documents
documents - OpenAI API
Connections 27
- User → Web chatbot: uploads and asks
- User → CLI chatbot: provides path and asks
- User → Local web chatbot: uploads and asks
- PDF/TXT documents → Document processor: loads from path
- Web chatbot → Document processor: processes uploads
- CLI chatbot → Document processor: processes path
- Local web chatbot → Document processor: processes uploads
- Document processor → PDF/TXT loaders: loads files
- Document processor → Chunk splitter: splits documents
- Web chatbot → Vector store: indexes chunks
- CLI chatbot → Vector store: indexes chunks
- Local web chatbot → Free vector store: indexes chunks
- Vector store → Embedding model: embeds chunks
- Free vector store → Local embeddings: embeds chunks
- Vector store → Chroma database: persists and loads
- Free vector store → Chroma database: persists and loads
- Web chatbot → RAG chain: queries
- CLI chatbot → RAG chain: queries
- RAG chain → Retriever: sets up and queries
- Retriever → Vector store: searches chunks
- RAG chain → OpenAI API: generates answer
- RAG chain → Web chatbot: returns answer and sources
- RAG chain → CLI chatbot: returns answer and sources
- Local web chatbot → Context search: searches question
- Context search → Free vector store: requests similar passages
- Free vector store → Context search: returns passages
- Context search → Local web chatbot: returns context