studentchatbot / README.md
aak007's picture
Initial commit for Hugging Face
45b17a5
|
Raw
History Blame Contribute Delete
5.44 kB
metadata
title: Student Support Chatbot
emoji: πŸŽ“
colorFrom: purple
colorTo: indigo
sdk: docker
pinned: false

πŸŽ“ Student Support Chatbot

A fully deployed AI-powered RAG (Retrieval-Augmented Generation) chatbot that answers student queries about admissions, fees, courses, campus life, and more. Built with LangChain, Google Gemini, Pinecone, and Flask.


πŸ—οΈ Architecture

Student Question
      ↓
HuggingFace Embeddings (all-MiniLM-L6-v2)
      ↓
Pinecone Vector DB (semantic search β†’ top 3 results)
      ↓
Google Gemini LLM (generates final answer)
      ↓
Flask Web App (chat interface)

Dataset: bot-remains/student-assistance-chatbot β€” 217 student Q&A pairs covering admissions, eligibility, fees, academics, and campus life.


πŸ› οΈ Tech Stack

Layer Technology
LLM Google Gemini 2.5 Flash
Embeddings HuggingFace all-MiniLM-L6-v2
Vector Database Pinecone
Framework LangChain
Web App Flask
Deployment AWS App Runner + Amazon ECR / Docker

πŸš€ How to Run Locally

Step 1: Clone the repository

git clone https://github.com/aak007/Build-a-Complete-Medical-Chatbot-with-LLMs-LangChain-Pinecone-Flask-AWS.git
cd Build-a-Complete-Medical-Chatbot-with-LLMs-LangChain-Pinecone-Flask-AWS

Step 2: Create and activate conda environment

conda create -n medibot python=3.10 -y
conda activate medibot

Step 3: Install dependencies

pip install -r requirements.txt

Step 4: Set up environment variables

Create a .env file in the root directory:

PINECONE_API_KEY=your_pinecone_api_key
GOOGLE_API_KEY=your_gemini_api_key

# Optional: choose your index name
PINECONE_INDEX_NAME=student-chatbot

# Dataset source options: hf | local | pdf
DATA_SOURCE=hf

# If DATA_SOURCE=hf
HF_DATASET_NAME=bot-remains/student-assistance-chatbot

# If DATA_SOURCE=local (csv/json/jsonl/txt/md)
LOCAL_DATASET_PATH=data/my_dataset.csv
TEXT_COLUMNS=question,answer

# If DATA_SOURCE=pdf (single file or folder)
# LOCAL_DATASET_PATH=data/student_buddy_qa.pdf

Step 5: Index the dataset into Pinecone (Run only once)

python store_index.py

This downloads the student Q&A dataset from HuggingFace and stores it as vector embeddings in your Pinecone student-chatbot index.

Use Your Own Dataset

You can replace the default dataset with your own data and re-index it.

  1. Put your file inside the project, for example data/my_dataset.csv.
  2. Update .env:
DATA_SOURCE=local
LOCAL_DATASET_PATH=data/my_dataset.csv
TEXT_COLUMNS=question,answer
PINECONE_INDEX_NAME=my-student-bot-index
  1. Rebuild vectors:
python store_index.py
  1. Start app:
python app.py

Supported local file formats:

  • csv (recommended)
  • json (array of objects)
  • jsonl (one JSON object per line)
  • txt / md (split by blank lines)

For PDF knowledge bases:

DATA_SOURCE=pdf
LOCAL_DATASET_PATH=data/student_buddy_qa.pdf
PINECONE_INDEX_NAME=student-buddy-index

Then run:

python store_index.py
python app.py

Example CSV schema:

question,answer,category
What is eligibility for B.Tech?,Candidates must pass 10+2 with PCM and required cutoff,admissions
What are hostel fees?,Hostel fees vary by room type and campus policy,fees

Step 6: Start the app

python app.py

Step 7: Open in browser

http://localhost:7860

☁️ Deployment

AWS App Runner + ECR (Recommended)

# 1. Authenticate Docker to AWS ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com

# 2. Build Docker image
docker build --no-cache -t medical-bot .

# 3. Tag image
docker tag medical-bot:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/medical-bot:latest

# 4. Push to ECR
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/medical-bot:latest

Then deploy via AWS App Runner, set port 7860, and add your PINECONE_API_KEY and GOOGLE_API_KEY as environment variables.


πŸ“ Project Structure

β”œβ”€β”€ app.py                  # Flask web server
β”œβ”€β”€ store_index.py          # Downloads dataset & indexes into Pinecone
β”œβ”€β”€ Dockerfile              # Docker config for deployment
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ setup.py
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ helper.py           # load_hf_dataset(), text_split(), embeddings
β”‚   └── prompt.py           # System prompt for student support
β”œβ”€β”€ static/
β”‚   └── style.css           # Premium student-themed UI
└── templates/
    └── chat.html           # Chat interface

πŸ”‘ Required API Keys

Key Where to Get
PINECONE_API_KEY app.pinecone.io
GOOGLE_API_KEY aistudio.google.com