🧠 Mood Support Chatbot with PPO & GPT-3.5
This project is an AI-powered mental health support chatbot that infers a user's emotional state from natural language input and provides personalized wellness suggestions. It combines:
- GPT-3.5 for mood detection from conversation
- PPO (Proximal Policy Optimization) for reinforcement-learned action selection
- Gradio for an interactive web interface
- Hugging Face Spaces for free public hosting
🌟 Features
- Multi-turn Conversation Context: Mood detection takes the recent chat history into account
- Visual Mood Tracking: A mood trend chart tracks how the user's state evolves
- Personalized Suggestion Memory: Keeps count of which strategies are offered per session
- Custom PPO Policy: Trained in a simulated environment with an expanded action space of 8 wellness suggestions
- Deployment Ready: Packaged and hosted on Hugging Face Spaces with OpenAI key stored securely
🧩 Action Space
The agent selects from the following actions:
- meditation 🧘
- talk_therapy 💬
- journal_prompt 📝
- breathing_ex 💨
- video 🎥
- nature_walk 🌿
- soothing_music 🎶
- gratitude_exercise 🙏
🛠 Training
The PPO agent was trained using stable-baselines3 in a custom Gymnasium environment. The reward is based on simulated mood improvements, and training ends when the mood exceeds a threshold (e.g., 0.95).
Training script includes:
- SimulatedUser with mood boost logic
- MoodSupportEnv with gym-style
reset() and step()
- PPO training loop with model save + zip
🧪 How to Test
Use emotional prompts like:
- "I'm so tired and I can't stop overthinking."
- "I'm feeling hopeful but a bit nervous."
- "I don't feel like doing anything."
Or test edge cases like:
- Extremely long emotional rants
- Repeated vague responses ("I don't know")
- Rapid mood swings over turns
🚀 Deployment on Hugging Face Spaces
This project runs on Hugging Face using:
app.py: Main chatbot logic and UI
ppo_mental_health_model_expanded.zip: Trained PPO model
requirements.txt: Dependency list
OPENAI_API_KEY: Set as a Hugging Face Secret
🧠 Future Enhancements
- Mood-aware GPT text responses
- Feedback buttons (👍/👎) to improve the agent
- Session export or user login
- Local transformer fallback (offline mode)
- Mood milestone alerts ("You've improved by 40%!")
👤 Author
Built and maintained by Chirasmayee B and Pallavi Bichupriya.
📄 License
MIT License