Zebra668/Bano_qabil_Chatbot
0
Bano Qabil AI Chatbot v2.0
Official AI chatbot for Bano Qabil IT training program. Built by Ali — a Bano Qabil student.
Tech Stack
Project Structure
bq_chatbot/
├── main.py # Flask app — entry point
├── requirements.txt # Dependencies
├── .env # Your secrets (create from .env.example)
├── .env.example # Template
├── bq_chatbot.db # SQLite DB (auto-created)
├── knowledge/ # Put your RAG PDFs here
│ └── RAG.pdf
├── frontend/ # Optional: HTML frontend
│ └── index.html
└── backend/
├── config.py # Environment variables
├── database.py # SQLite setup + helpers
├── memory.py # Conversation history
├── llm.py # Gemini 2.5 Flash calls
├── rag.py # PDF knowledge retrieval
├── tools.py # Web search (DuckDuckGo)
├── relevance.py # BQ/tech topic detection
├── multimodal.py # Image analysis
└── personalization.py # User profile managementSetup (Local)
1. Clone & install
git clone <your-repo>
cd bq_chatbot
pip install -r requirements.txt2. Create .env file
cp .env.example .env
# Edit .env and add your Gemini API key.env contents:
GEMINI_API_KEY=your_actual_gemini_api_key_here
SECRET_KEY=banoqaabil2024
DB_PATH=bq_chatbot.db3. Get Gemini API Key
- Go to: https://aistudio.google.com/app/apikey
- Create API key (free tier available)
- Paste in
.env
4. Add Knowledge PDF (optional)
# Put your Bano Qabil knowledge PDF in knowledge/ folder
cp your_bq_knowledge.pdf knowledge/RAG.pdf5. Run
python main.py
# Server starts at http://localhost:7860API Endpoints
POST /chat
{
"message": "bano qabil mein registration kaise karein?",
"session_id": 1,
"user_id": 1
}Response:
{
"response": "Bano Qabil mein registration ke liye...",
"session_id": 1,
"sources_used": ["pdf_rag", "llm_knowledge"]
}POST /chat/image
multipart/form-data
- file: image file
- question: "is mein kya course hai?"
- session_id: 1
- user_id: 1GET /health
{
"status": "ok",
"db": true,
"rag": {"loaded": true, "chunks": 245}
}GET /session/new?user_id=1
{"session_id": 5}Deployment (Hugging Face Spaces)
- Create new Space → Python → Flask
- Upload all files
- Add
GEMINI_API_KEYin Space Settings → Secrets - Set
app.pyas entry (or renamemain.pytoapp.py) - Done!
Deployment (Railway / Render)
# Procfile
web: python main.pySet GEMINI_API_KEY in environment variables.
How It Works
User Message
↓
Relevance Check (BQ/tech related?)
↓ Yes
[Source 1] PDF RAG → search knowledge base
[Source 2] Web Search → DuckDuckGo (time-sensitive queries)
↓
Combine context + user message
↓
Gemini 2.5 Flash (with system prompt + history)
↓
Response → Save to SQLite → Return to userLanguages Supported
- Roman Urdu ✓
- Urdu Script ✓
- English ✓
- Auto-detection ✓
Contact
BQ WhatsApp: 0317-8226244 | Helpline: 021-111-503-504
