Skip to content

Lightweight AI chatbot using Sentence Transformers + OpenRouter — smart, simple, and resource-friendly.

Notifications You must be signed in to change notification settings

Dhavanesh24cs412/Simple-RAG-GHC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple-RAG-GHC

Lightweight AI chatbot using Sentence Transformers + OpenRouter — smart, simple, and resource‑friendly.


Overview

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.


Features

  • 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.

Prerequisites

  • 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.

Installation

1. Clone the repository

git clone https://github.com/Dhavanesh24cs412/Simple-RAG-GHC.git
cd Simple-RAG-GHC

2. Create and activate virtual environment

python -m venv venv

# On macOS / Linux
source venv/bin/activate

# On Windows
venv\Scripts\activate

3. Upgrade pip (recommended)

python -m pip install --upgrade pip

4. Install dependencies

pip install -r requirements.txt

If requirements.txt is not used, install manually:

pip install streamlit requests pypdf sentence-transformers faiss-cpu numpy python-dotenv

OpenRouter API Setup

1. Create an OpenRouter account and key

2. Configure .env

Create a .env file in the project root (same level as app.py) with:

OPENROUTER_API_KEY=your_openrouter_api_key_here

Make sure the key is copied correctly with no extra quotes or spaces.


Running the Chatbot

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.py

Then 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.


Purpose

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.

Customization: System Role & Prompt

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.


Caution — PHI and Sensitive Data

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.


License & Usage

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.

About

Lightweight AI chatbot using Sentence Transformers + OpenRouter — smart, simple, and resource-friendly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages