Lightweight AI chatbot using Sentence Transformers + OpenRouter — smart, simple, and resource‑friendly.
This project is a lightweight demo chatbot that shows how to build AI‑driven conversational systems using sentence transformers for semantic understanding and a free OpenRouter model for generating responses. It is designed to run on minimal resources while still understanding user intent, following context, and producing meaningful replies across different use cases.
- Uses a small, optimized Sentence Transformer model for embedding‑based context understanding.
- Connects to a free OpenRouter model for high‑quality conversational responses.
- Easily customizable system role and behavior through a single configuration point.
- Suitable as an educational, proof‑of‑concept, and starter template for RAG‑style chatbots.
- Python 3.9+ installed on your machine.
- Git installed (optional but recommended) to clone the repository.
- A free account and API key from OpenRouter: https://openrouter.ai/settings/keys.
git clone https://github.com/Dhavanesh24cs412/Simple-RAG-GHC.git
cd Simple-RAG-GHCpython -m venv venv
# On macOS / Linux
source venv/bin/activate
# On Windows
venv\Scripts\activatepython -m pip install --upgrade pippip install -r requirements.txtIf requirements.txt is not used, install manually:
pip install streamlit requests pypdf sentence-transformers faiss-cpu numpy python-dotenv- Go to https://openrouter.ai and sign up.
- Create an API key from: https://openrouter.ai/settings/keys.
Create a .env file in the project root (same level as app.py) with:
OPENROUTER_API_KEY=your_openrouter_api_key_hereMake sure the key is copied correctly with no extra quotes or spaces.
From the project root with the virtual environment activated, run:
# On macOS / Linux
source venv/bin/activate
# On Windows
venv\Scripts\activate
streamlit run main.pyThen open the local URL shown in the terminal (usually http://localhost:8501) in your browser.
Once loaded, you can start chatting — your chatbot is live.
This chatbot is built as an educational and proof‑of‑concept project to demonstrate that:
- A compact Sentence Transformer model can power semantic search and context understanding.
- A free OpenRouter model can be used for high‑quality, low‑cost conversational generation.
- The same engine can be adapted for roles like personal assistants, bug analyzers, code reviewers, or study buddies with minimal changes.
- Developers can deploy practical conversational AI without heavy GPUs or paid APIs.
You can customize the chatbot’s personality and purpose by editing the system role configuration in the code (for example, in app.py).
Example system roles:
system_role = "You are an AI software assistant that helps debug frontend and backend web apps."
system_role = "You are a friendly study assistant that explains computer science concepts in simple words."
system_role = "You are an AI interviewer conducting mock technical interviews."By changing just these lines, the same chatbot can adapt to multiple domains and workflows without structural changes.
This chatbot is not designed to process, store, or analyze Protected Health Information (PHI) or any other sensitive personal data. Use it only for general and educational purposes; for professional or production use, ensure compliance with privacy and security regulations such as HIPAA or GDPR.
This code is provided for demonstration and educational purposes only. You may modify and adapt it for your own non‑commercial projects with appropriate credit to the original author.