BNS QnA Chatbot is an AI-powered legal assistant designed to help users understand the Bharatiya Nyaya Sanhita (BNS) — the updated Indian Penal Code. Built using Retrieval-Augmented Generation (RAG) and OpenAI's powerful language models, this chatbot fetches the most relevant sections from the latest BNS documents to answer user queries with high accuracy and context awareness.
- 📘 BNS-Aware: Trained on the latest Bharatiya Nyaya Sanhita files.
- 🤖 Conversational Interface: Ask questions in natural language.
- 📄 Contextual Retrieval: Uses RAG to fetch accurate, up-to-date legal references.
- ❗ Fact-First Answers: No hallucinations—if an answer isn’t in the context, it tells you.
- 🌐 Streamlit Frontend: Clean and responsive UI for a seamless chat experience.
- Streamlit: Web application framework
- FastAPI: Web server
- Langchain: MLOps & orchestration
- Pinecone: Vector Database
text-embedding-3-small: for embedding text into vectorsgpt 4o-mini: LLM
bns-rag/
├── controllers/ # Application logic controllers
├── db/ # Database interaction components
├── frontend/ # Streamlit UI elements
├── model/ # OpenAI model setup
├── routes/ # API routes for various functions
├── temp/ # Temporary file storage
├── utils/ # Utility functions and helpers
├── .gitignore # Git ignore file
├── main.py # Main application entry point
└── requirements.txt # Required dependencies
- Python 3.7 or higher
- pip (Python package manager)
- Git
-
Clone the repository:
git clone https://github.com/nakul-krishnakumar/bns-rag.git cd bns-rag -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Setup environment variables:
OPENAI_API_KEY=your-openai-api-key PINECONE_API_KEY=your-pinecone-api-key PINECONE_INDEX_NAME=your-pinecone-index-name PINECONE_NAMESPACE=your-pinecone-namespace
-
Install dependencies:
pip install -r requirements.txt
-
Launch the server:
python main.py
-
Launch the application:
streamlit run frontend/app.py
-
Open your browser and navigate to the URL displayed in the terminal (typically http://localhost:8501)
For questions, suggestions, or issues, please contact:
- Developer: Nakul Krishnakumar
- Email: [email protected]
- GitHub Issues: Submit issues through the repository's issue tracker
