An intelligent chatbot designed specifically for SR University that provides accurate, context-aware answers to student queries using advanced AI and document retrieval technology.
- π§ Intelligent Q&A: Powered by state-of-the-art language models (Qwen/QwQ-32B-Preview)
- π Document-Based Responses: Uses university handbook and official documents as knowledge base
- π Vector Search: FAISS-powered semantic search for accurate information retrieval
- π¬ Interactive Web Interface: Clean, responsive chat interface with drag-and-drop functionality
- β‘ Real-time Responses: Fast, contextual answers with typing indicators
- π― University-Specific: Trained specifically on SR University information
- π Secure: Environment-based API key management
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Flask API β β AI Pipeline β
β (HTML/JS/CSS) βββββΊβ (app.py) βββββΊβ (LangChain) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Templates β β FAISS Vector β
β (Jinja2) β β Database β
βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β University β
β Handbook PDF β
βββββββββββββββββββ
- Python 3.8 or higher
- HuggingFace API token
- 4GB+ RAM (for embedding models)
-
Clone the repository
git clone https://github.com/Karanraj-6/University_ChatBot.git cd University_ChatBot -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env file with your API keys -
Run the application
python app.py
-
Access the chatbot Open your browser and navigate to
http://localhost:5000
Create a .env file in the root directory:
HUGGINGFACEHUB_API_TOKEN=your_huggingface_token_here
PINECONE_API_KEY=your_pinecone_key_here # Optional for future use- Visit HuggingFace
- Create an account or log in
- Go to Settings β Access Tokens
- Create a new token with "Read" permissions
- Copy the token to your
.envfile
University_ChatBot/
βββ π app.py # Main Flask application
βββ π model.py # Alternative model implementation
βββ π templates/
β βββ π index.html # Main chat interface
βββ π static/
β βββ π styles.css # UI styling
β βββ π script.js # Frontend functionality
β βββ πΌοΈ chatbot_icon.png # Bot avatar
β βββ πΌοΈ user.png # User avatar
β βββ πΌοΈ sru_background.png # Background image
βββ π faiss_index/
β βββ π index.faiss # Vector database
β βββ π index.pkl # Embeddings metadata
βββ π handbook_2024_25.pdf # University knowledge base
βββ π code.ipynb # Development notebook
βββ π requirements.txt # Python dependencies
βββ π .env # Environment configuration
βββ π README.md # This file
-
Document Processing
- PDF text extraction using PyPDF
- Text chunking for optimal retrieval
- Sentence transformer embeddings (all-MiniLM-L6-v2)
-
Vector Database
- FAISS for efficient similarity search
- Pre-computed embeddings for fast retrieval
- Semantic search capabilities
-
Language Model
- Qwen/QwQ-32B-Preview from HuggingFace
- Customized prompts for university context
- Temperature-controlled generation (0.4)
-
Retrieval-Augmented Generation (RAG)
- Context-aware response generation
- Source document verification
- Fallback responses for unknown queries
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Serve main chat interface |
/chat |
POST | Process user messages and return responses |
{
"message": "What are the admission requirements?"
}{
"response": "The admission requirements for SR University include..."
}The chatbot features a modern, responsive web interface with:
- Floating Chat Button: Draggable, always-accessible chat trigger
- Collapsible Chat Window: Clean, modal-style chat interface
- User Avatars: Visual distinction between user and bot messages
- Typing Indicators: Real-time feedback during response generation
- Responsive Design: Works on desktop and mobile devices
- Chat Header: University branding and close button
- Message Area: Scrollable conversation history
- Input Field: Text input with send button and Enter key support
- Visual Feedback: Loading animations and status indicators
- "What are the admission requirements?"
- "How do I register for courses?"
- "What facilities are available in the hostel?"
- "Tell me about the examination system"
- "What is the grading system?"
- "How do I apply for a PhD program?"
- "What are the research opportunities?"
- "What are the contact details for admissions?"
- "How do I pay fees?"
- "What documents do I need for enrollment?"
export FLASK_ENV=development
export FLASK_DEBUG=1
python app.py- app.py: Main Flask application with chat endpoint
- model.py: Alternative implementation for testing
- get_answer(): Core function handling AI pipeline
- Templates: Jinja2 templates for web interface
- Static files: CSS, JavaScript, and images
- Place PDF files in the root directory
- Update the document processing code in
code.ipynb - Regenerate the FAISS index
- Test with new queries
-
Import Errors
# Solution: Install missing dependencies pip install -r requirements.txt -
HuggingFace API Errors
# Solution: Check your API token in .env file # Ensure token has proper permissions
-
FAISS Index Not Found
# Solution: Ensure faiss_index/ directory exists # Regenerate index if corrupted
-
Memory Issues
# Solution: Increase system RAM or use smaller models # Consider using sentence-transformers/all-MiniLM-L6-v2
Enable Flask debug mode for detailed error messages:
app.run(debug=True)- Replace
handbook_2024_25.pdfwith new document - Run the notebook to regenerate embeddings
- Update FAISS index
- Test with sample queries
To use a different language model:
- Update
repo_idinapp.py - Adjust
model_kwargsparameters - Test response quality
- Phone: 0(870) 281-8333/8311
- Email: info@sru.edu.in
- Website: SR University
For technical issues:
- Check the troubleshooting section
- Review error logs
- Ensure all dependencies are installed
- Verify API credentials
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow PEP 8 for Python code
- Use meaningful commit messages
- Test your changes thoroughly
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- SR University for providing the knowledge base
- HuggingFace for the language models and embeddings
- LangChain for the RAG framework
- FAISS for efficient vector search
- Flask for the web framework
- Average: 2-5 seconds
- Depends on query complexity and model size
- University-specific queries: ~95%
- General knowledge: Limited (by design)
- Fallback responses for unknown queries
Made with β€οΈ for SR University students and faculty