A Retrieval-Augmented Generation (RAG) system focused on Ethiopian history. It indexes local text documents, retrieves the most relevant information based on user queries, and uses a Groq-hosted large language model (LLM) to generate clear, concise, and accurate answers.
# Ethiopian History RAG Assistant
A lightweight Retrieval-Augmented Generation (RAG) application that answers questions about Ethiopian history using a local text corpus, a persistent Chroma vector database, and a Groq-hosted LLM. The project ships with a Streamlit UI and an optional CLI.
## Features
- Ingest `.txt` sources from `data/`, chunk and embed them with `sentence-transformers/all-MiniLM-L6-v2`.
- Persist embeddings in Chroma (`chroma_db/`) for fast reloads.
- Retrieve top-k relevant chunks via semantic similarity with deduplication and thresholding.
- Build a concise, source-aware prompt for the LLM.
- Generate succinct answers using `langchain_groq.ChatGroq` authenticated via `GROQ_API_KEY`.
- Streamlit UI and CLI entry points.
## Architecture
- `app.py`: Streamlit UI for querying and displaying answers.
- `vectordb_and_ingestion.py`: `VectorDBManager` handles chunking, embedding, persistence, and retrieval.
- `prompt_builder.py`: Builds compact prompts from retrieved chunks with minimal source hints.
- `retrieval_and_response.py`: CLI pipeline mirroring the app (load/ingest → retrieve → prompt → answer).
- `logger.py`: Minimal console logger shared across modules.
- `wiki_fetcher.py`: Helper to fetch Wikipedia pages into `data/` as `.txt`.
## Prerequisites
- Python 3.12+
- A Groq API key
## Quickstart
```bash
# 1) Create and activate a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 2) Install dependencies
pip install -r requirements.txt
# 3) Configure environment
# Create .env and set GROQ_API_KEY
printf "GROQ_API_KEY=your_key_here\n" > .env
# 4) (Optional) Seed/expand the corpus with Wikipedia content
python -c "from wiki_fetcher import fetch_and_save_page; fetch_and_save_page('Axum Empire')"
# 5) Run the Streamlit app
streamlit run code/app.py
```
## Screenshots
Answer found from context
(
Answer not found (out-of-scope question):
### CLI Usage
```bash
python -m code.r …