A sleek, modern AI-powered chat application built with pure vanilla JavaScript, featuring a beautiful UI and powered by Hugging Face’s free AI models. No frameworks, no dependencies - just clean, fast code!
Before you begin, ensure you have:
# clone repositry
git clone https://github.com/codergangganesh/StudentAI.git
cd StudentAI
Open script.js and replace the API key on line 8:
const HUGGINGFACE_API_KEY = "hf_your-actual-api-key-here"
Simply open aibot.html in your web browser, or use a local server:
# Using Python
python -m http.server 8000
# Using Node.js (if you have http-server installed)
npx http-server
# Using PHP
php -S localhost:8000
Then visit http://localhost:8000
User: "Explain quantum computing in simple terms"
AI: "Quantum computing uses quantum mechanics principles..."
User: "What's in this image?" + [uploaded image]
AI: "I can see a beautiful sunset over mountains..."
You can switch between different Qwen models by changing line 22 in script.js:
// Fast and Free (Current)
this.model = "qwen/qwen-2.5-7b-instruct"
// More Capable (May have costs)
this.model = "qwen/qwen-2.5-72b-instruct"
// Alternative Free Option
this.model = "qwen/qwen-2-7b-instruct"
Edit the CSS variables in style.css:
:root {
--primary-color: #4f46e5;
--secondary-color: #7c3aed;
--background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
The modular structure makes it easy to add features:
OpenRouterAI classStudentAI/
├── aibot.html # Main HTML file
├── style.css # Styling and animations
├── script.js # JavaScript logic and API integration
├── README.md # Project documentation
└── assets/ # Images and other assets (if any)
class OpenRouterAI {
constructor(apiKey) {
this.apiKey = apiKey
this.model = "qwen/qwen-2.5-7b-instruct"
}
async generateContent(message, imageData = null) {
// API call implementation
}
}
Enable detailed logging by opening browser console (F12) to see:
https://yourusername.github.io/StudentAIContributions are welcome! Here’s how you can help:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.