Logo Lanfrica

waleyyy002/Nigeria-Laws-RAG

Domain:

natural language processing

Record type:

software
Creator:
wal
Host:
Nigeria-Laws-RAG # πŸ‡³πŸ‡¬ Nigerian Tax Reforms & Constitution Q&A A Streamlit chatbot that answers questions about Nigerian tax reform legislation and the Constitution of Nigeria, grounded in documents you provide (RAG), with an agent that can also run calculations (e.g. VAT/tax percentages) instead of guessing at math. > Informational tool only β€” not legal or tax advice. Answers are only as accurate as > the documents loaded into the knowledge base. ## How it works - Documents placed in `knowledge_base/` (`.txt`, `.pdf`, `.csv`) are split into chunks, embedded locally with a HuggingFace model, and upserted into a **Pinecone** vector index (talked to directly via the `pinecone` SDK, not the `langchain-pinecone` package β€” that package still pins `numpy<2`, which has no wheel for the Python version this app runs on). - A Groq-hosted model answers questions as an **agent** with two tools: - `search_documents` β€” embeds the question and queries Pinecone for the closest matching passages. - `calculator` β€” evaluates arithmetic (percentages, totals, etc.) safely. - The sidebar lets you upload more `.txt`/`.pdf`/`.csv` files at any time. Any change to the knowledge base clears the Pinecone index and re-uploads every chunk fresh, so the index never drifts from what's actually in the `knowledge_base/` folder. ## Running locally ```bash python -m venv rag rag\Scripts\activate # Windows pip install -r requirements.txt streamlit run main.py ``` You'll need: - A free Groq API key from console.groq.com β€” paste it into the sidebar each run, or set `GROQ_API_KEY` (see below) to skip that prompt. - A free Pinecone API key from app.pinecone.io (Starter plan is enough) β€” this one is **required**, set via `PINECONE_API_KEY`; there's no sidebar fallback for it, since the vector index is shared infrastructure for the app's one knowledge base, not something each visitor brings their own account for. Copy `.streamlit/secrets.toml.example` to `.streamlit/secrets.toml` and fill in both keys so they' …