A mental health therapy chatbot that uses Google's Gemini and Hugging Face Transformers for sentiment analysis and mental health support. The app provides personalized responses to user queries and visualizes sentiment score in the form of pie charts to assess emotional states.
- Sentiment Analysis: Uses Hugging Face's transformer models to analyze the sentiment of user input.
- Mental Health Assistance: Interacts with the user and provides emotional support based on predefined guidelines.
- Emotion Visualization: Visualizes sentiment analysis results (positive and negative emotions) as pie charts.
- Crisis Detection: Flags potential emotional crises based on sentiment score thresholds.
- Flask: A lightweight web framework for building the web app.
- Google Generative AI (Gemini): For generating responses based on the input provided by the user.
- Hugging Face Transformers: For sentiment analysis of user input.
- Matplotlib: For generating pie chart visualizations of sentiment.
- Markdown: For rendering Markdown responses in the chat.
Ensure you have Python 3.7 or higher installed.
git clone https://github.com/RohitMugalya/Mental-Health-Therapy-Chatbot.git
cd Mental-Health-Therapy-Chatbot
python -m venv venv
- on Linux system
source venv/bin/activate
- on Windows system
.\venv\Scripts\activate.bat
pip install -r requirements.txt
To use Google Generative AI (Gemini), you'll need an API key. Create a project in the Google AI Studio, enable the Generative AI API, and obtain an API key.
- Copy your API key and place it in the
bot.py
file as shown:API_KEY = "your-api-key"
python app.py
The application will run locally on http://127.0.0.1:5000/
.
- Open your browser and go to
http://127.0.0.1:5000/
. - Enter a query in the provided text box and submit.
- The chatbot will analyze the sentiment of your input and provide a response.
- The sentiment results will be displayed as a pie chart showing the distribution of positive and negative emotions.
- If the sentiment analysis indicates a potential crisis (based on the defined threshold), it will redirect to a crisis page.
Feel free to fork the repository, make improvements, or open an issue if you find any bugs or have suggestions for enhancements.
Happy Coding :)