A powerful dual-mode intelligent chatbot powered by Google's Gemini AI. Switch between Sustainability Teacher mode for ethics and UN SDG education, or Multi-Persona Assistant mode featuring six specialized AI personalities (Chef, Teacher, Tech, Motivation, Finance, Knowledge) that automatically switch based on your needs. Features personalized video analysis, advanced conversation memory, multimodal capabilities, and AI Locket (ESP32-CAM wearable) integration for hands-free AI assistance anywhere.
- ๐ค Voice-Activated: Say "start capture" for hands-free recording - no buttons needed
- ๐น Smart Video Capture: 12-second automatic video recording with simultaneous audio
- ๐ง Bluetooth Audio: Wireless communication via Bluetooth A2DP earbuds (input & output)
- ๐ One-Time Device Linking: Register your ESP32 device once - no repeated logins required
- ๐ WiFi Sync: Automatic synchronization with server over WiFi
- ๐พ Unified Memory: Shared conversation history across web interface and wearable device
- ๐ Portable Power: LiPo battery with TP4056 charging for all-day wearability
- ๐ Visual AI: Analyzes what you see and provides context-aware responses
- ๐ฏ Intelligent Routing: Automatically uses Personal Assistant mode for quick, practical help
- โจ Markdown Formatting: Bold, italic, and formatted text in AI responses
- ๐ฑ Mobile-Optimized: Responsive interface works great on phones and tablets
See ESP32_SETUP_GUIDE.md for hardware setup and ESP32_INTEGRATION_SUMMARY.md for deployment details.
- ๐ค User Accounts: Secure registration and login system
- ๐ Password Security: SHA-256 password hashing (never stored in plain text)
- ๐พ Persistent Memory: Your conversations are saved to your account and persist across sessions
- ๐ Cross-Device: Access your chat history from any device after logging in
- ๐ข Dual Storage: Automatically uses PostgreSQL (Railway) or JSON files (local development)
- ๐ฑ Sustainability Teacher Mode: Educational focus on ethics, sustainability, and UN SDGs with personalized, caring responses
- ๐ญ Multi-Persona Assistant Mode: Six specialized AI personalities that automatically switch based on your needs
- ๐จโ๐ณ Chef Rile: Cooking, recipes, meal planning, nutrition, food safety, kitchen organization
- ๐จโ๐ซ Teacher Rile: Learning, education, study tips, explaining concepts, homework help, skill development
- ๐จโ๐ป Tech Rile: Technology, gadgets, software, troubleshooting, digital organization, apps, devices
- ๐ช Motivation Rile: Encouragement, goal setting, productivity, wellness, mental health, personal growth
- ๐ฐ Finance Rile: Money management, budgeting, savings, investment basics, financial planning
- ๐ง Knowledge Rile: General knowledge, facts, research, curiosity-driven questions, trivia
Each persona automatically activates based on your question and responds with their specialized expertise!
- ๐ฌ Cross-mode conversation memory: Seamlessly remembers discussions across both modes
- ๐ฏ Context-aware responses: AI adapts to your mood and needs (offers support if you look sad/stressed in videos)
- ๐ Ultra-detailed media analysis: Comprehensive breakdown of your environment, belongings, and activities
- โฐ Time-tracking: Monitors changes in your space and habits over time
- ๐ Enhanced context window: Up to 20 recent exchanges for better conversation continuity
- ๐ท Webcam integration: Capture photos directly in-browser for instant analysis
- ๐ฅ Video recording with optional context: Record videos and optionally add text descriptions for targeted analysis
- ๐ File uploads: Upload images and videos for detailed analysis
- ๐ค Voice input: Record voice messages with automatic transcription and environmental audio analysis
- ๏ฟฝ Video context feature: After recording, add optional text context like "Review my presentation skills" or "Check my cooking technique"
- ๐ท๏ธ Smart tagging: Visual confirmation when video is saved with optional description field
- ๐ฏ Modern UI: Clean, responsive design with smooth animations
- ๐ฑ Mobile optimized: Full responsive design for phones and tablets
- ๐ Mode-based theming: Blue gradient for Personal Assistant, green for Sustainability Teacher
- ๐ผ๏ธ Media preview: Corner preview system for captured media with clear/remove controls
- ๐ Markdown support: Rich text formatting in responses (bold, italic, code)
- โฉ๏ธ Intuitive navigation: Fixed header with back button and mode toggle
- ๐ญ Modal system: Elegant profile creation with background collection
- ๐ Optimized spacing: Compact, efficient use of screen space
- ๐ Aligned controls: Perfectly aligned media buttons (camera, video, file upload)
- ๐ฌ Smart input bar: Fixed to bottom with no gaps, always accessible
- Python 3.7 or higher
- A free Google Gemini API key
-
Clone or download this project to your local machine
-
Navigate to the project directory:
cd "Chat bot"
-
Create and activate a virtual environment (recommended):
python -m venv .venv
.venv\Scripts\activate # On Windows
4. **Install required packages**:
```bash
pip install fastapi uvicorn requests
-
Run the chatbot:
uvicorn app:app --reload
Or if you're using the virtual environment:
.venv/bin/python -m uvicorn app:app --reload
-
Open your browser and go to:
http://localhost:8000
-
Login or Register:
- New users: Click "Create New Account" and choose a username and password (minimum 6 characters)
- Returning users: Enter your username and password to access your saved conversations
-
Choose your mode using the toggle switch:
- ๐ฑ Sustainability Teacher: For education about ethics, sustainability, and SDGs
- ๐ค Personal Assistant: For environment analysis and personalized help (default mode)
-
Start chatting - your conversations are automatically saved to your account and persist across all sessions
Perfect for learning and education. Ask questions like:
- "What is SDG 2?"
- "How can I live more sustainably?"
- "What are the ethics of fast fashion?"
- "Tell me about circular economy"
- "Analyze the environmental impact in this image/video"
Ideal for practical help and environment analysis. Try:
- Environment scanning: "What do you see in my room?" (with photos/videos)
- Meal planning: "What can I cook with these ingredients?" (show your fridge/pantry)
- Organization help: "How should I organize this space?"
- Resource optimization: "What can I do with these items?"
- Safety assessment: "Is there anything unsafe here?"
- Voice messages: Record speech for automatic transcription and environmental audio analysis
- Camera capture: Take photos directly in the app for instant analysis
- Video recording: Record your environment for comprehensive assessment
- File uploads: Upload existing images and videos
Chat bot/
โโโ app.py # Main FastAPI application with authentication & dual-mode support
โโโ database.py # Database layer (PostgreSQL + JSON fallback) with user auth
โโโ config/
โ โโโ gemini_key.py # Holds GEMINI_API_KEY (keep private)
โโโ personas/ # AI persona configurations
โ โโโ chef_rile.json
โ โโโ teacher_rile.json
โ โโโ tech_rile.json
โ โโโ motivation_rile.json
โ โโโ finance_rile.json
โ โโโ knowledge_rile.json
โ โโโ sustainability_rile.json
โโโ templates/
โ โโโ index.html # HTML with login/register screens and dual-mode interface
โโโ static/
โ โโโ style.css # CSS with auth screens, mode-specific themes
โ โโโ script.js # Frontend with authentication, media handling
โโโ memory/ # Local storage (auto-created for development)
โ โโโ users.json # User accounts (local only)
โ โโโ sustainability/ # Sustainability mode conversations by username
โ โ โโโ {username}.json
โ โโโ personal_assistant/ # Personal Assistant mode conversations by username
โ โโโ {username}.json
โโโ README.md # This file
The chatbot uses Google's Gemini-2.5-Flash model, which is free tier compatible. The API key is configured in config/gemini_key.py.
- Local Development: Uses JSON files in
memory/users.json - Production (Railway): Automatically uses PostgreSQL database
- Password Security: SHA-256 hashing (never stores plain text passwords)
- User-Based Memory: All conversations are tied to username and persist across sessions
- users: id, username (unique), password_hash, created_at, last_login
- conversations: id, session_id, username, mode, user_message, bot_response, timestamp
- detailed_memories: id, session_id, media_type, detailed_analysis, extracted_memory
- Cross-mode continuity: Conversations are remembered across both Sustainability Teacher and Personal Assistant modes
- Profile-based memory: Each profile maintains its own conversation history and environment observations
- Enhanced context window: AI receives up to 20 recent exchanges for better conversation flow
- Time-aware memory: Environment observations are timestamped for tracking changes over time
- Background-aware responses: AI tailors advice based on your profile background (student, professional, etc.)
- Background collection: Profiles store your living situation and background for personalized responses
- Multiple profiles: Create different profiles for different contexts or users
- Modal interface: Clean, professional profile creation with detailed background collection
- Persistent sessions: Each profile maintains its own conversation continuity
- Educational responses focused on ethics, sustainability, and UN SDGs
- Gentle redirection of off-topic questions to relevant themes
- Teacher-like explanations that inspire and educate
- Analysis of media through sustainability lens
- Detailed environment analysis: Comprehensive inventory of visible objects, conditions, safety assessment
- Meal planning: Recipe suggestions based on visible ingredients
- Organization advice: Space optimization and resource management
- Adaptive responses: Advice tailored to your background (student budget-friendly, professional efficiency-focused, etc.)
- Environmental memory: Detailed tracking of your belongings and space changes over time
- Dual-mode toggle: Smooth switching between modes with visual feedback
- Modern design: Glass-morphism effects, smooth animations, professional appearance
- Responsive layout: Optimized for mobile and desktop with touch-friendly controls
- Media integration: Corner preview system, camera overlay, real-time recording feedback
- Navigation: Easy return to main page, clear visual hierarchy
Chat not working?
- Check your internet connection (required for Gemini API)
- Look at the browser console for error messages (F12 โ Console)
Want to reset conversations?
- Delete the
memory/folder to clear all saved conversations and user accounts (local only). The folder will be recreated automatically when you start a new chat.
Authentication issues?
- Ensure you're using correct username/password (case-sensitive)
- Password must be at least 6 characters
- Check console (F12) for specific error messages
- For Railway: Ensure PostgreSQL service is connected and DATABASE_URL is set
Created by Namai, an interdisciplinary dual major student passionate about sustainability and ethical technology. This chatbot serves as an educational tool to promote awareness about the UN Sustainable Development Goals and encourage ethical thinking.
This project is open source and available for educational purposes.