How ariharasudhan-adaikalam/wikibot works
Project Type and Purpose
• This is a full-stack Python application implementing a Retrieval-Augmented Generation (RAG) chatbot (“WikiBot🤖”) with a Streamlit UI, Wikipedia scraper, embedding pipeline, vector store, and LLM via HuggingFace.
File-Structure Analysis
• Top-level scripts:
• wikibot.py – entry point (Streamlit UI + orchestration)
• wiki_content.py – fetch & parse Wikipedia pages
• vector_embeddings.py – chunk text & build embeddings
• Config: .env (HuggingFace API token), requirements.txt, wheel for pysqlite3
• No sub-folders: a monolithic Python service with clearly separated modules.
Main Components
a. Streamlit UI (wikibot.py) – user-facing web interface
b. Wikipedia Scraper (wiki_content.py) – HTTP GET to wikipedia.org → parse HTML → extract text
c. Text Splitter & Embedding Generator (vector_embeddings.py) – use RecursiveTextSplitter → sentence-transformers model → produce embeddings
d. Chroma Vector Store – local vector DB (via chromadb + pysqlite3)
e. LangChain Orchestrator – glue code that handles retrieval and calls LLM
g. External Services – Wikipedia (HTTP), HuggingFace Hub API
Relationships and Data Flow
1. User enters query in Streamlit UI
2. UI → calls LangChain orchestrator in wikibot.py
3. Orchestrator invokes:
• Scraper module to fetch & parse Wikipedia
• Text splitter & embedding module to chunk & embed content
• Stores embeddings + chunks in Chroma DB (if not already cached)
4. For each new query:
• Retrieve top-k relevant chunks from Chroma by embedding the query
• Construct prompt (directive-based pattern) with retrieved chunks
• Send prompt to HuggingFace LLM API → receive generated answer
5. UI displays answer back to user
Architectural Patterns & Principles
• Modular design: separation of concerns (UI, scraping, embedding, storage, retrieval, generation)
• RAG pattern: combine external retrieval (Wikipedia + vector store) with generative model
• Caching: persist embeddings in Chroma to avoid re-computing
• Single process container (monolith) but logically divided into components