This project is an innovative mental health support application that leverages Gemini (GPT-based LLM) and FastAPI to provide empathetic responses, coping strategies, and resources for professional help. The application enables users to anonymously discuss their mental health concerns, offering support in real-time.
MIT License
This project is an innovative mental health support application that leverages Gemini (GPT-based LLM) and FastAPI to provide empathetic responses, coping strategies, and resources for professional help. The application enables users to anonymously discuss their mental health concerns, offering support in real-time.
requests
for API callspydantic
for data validation in FastAPIuvicorn
to run the FastAPI servergit clone https://github.com/mr-rakesh-ranjan/mental-health-support-app.git
cd mental-health-support-app
It’s recommended to use a virtual environment to avoid dependency conflicts.
python3 -m venv venv
source venv/bin/activate # For Linux/MacOS
venv\Scripts\activate # For Windows
pip install -r requirements.txt
You need an GEMINI API Key to interact with the Gemini LLM.
.env
file or set environment variables for your API key.GEMINI_API_KEY=your_gemini_api_key
config.py
file to hardcode your API key (not recommended for production).First, start the backend API service using FastAPI and Uvicorn.
cd backend
uvicorn backend.main:app --reload
This will start the backend on http://localhost:8000
.
Next, start the Streamlit client interface where users can submit their concerns.
cd frontend
streamlit run frontend/app.py
This will launch the frontend in your browser at http://localhost:8501
.
The FastAPI backend exposes the following endpoints:
/analyze/
){
"text": "I feel very stressed and anxious about work."
}
{
"llm_response": "It's completely normal to feel anxious during tough times at work. Try taking breaks and practicing mindfulness.",
"coping_strategies": [
"Take deep breaths and focus on the present moment.",
"Engage in a hobby or activity that brings you joy.",
"Reach out to a trusted friend or family member."
]
}
/resources/
)[
{"name": "National Suicide Prevention Lifeline", "contact": "1-800-273-8255"},
{"name": "BetterHelp", "website": "https://www.betterhelp.com"},
{"name": "Talkspace", "website": "https://www.talkspace.com"}
]
The Streamlit client provides an easy-to-use interface for users to input their mental health concerns.
The FastAPI backend provides the main logic for processing input, calling the Gemini LLM API, and returning coping strategies.
You can run the FastAPI server locally using uvicorn
.
uvicorn backend.main:app --reload
This project is licensed under the MIT License. See the LICENSE file for more information.
Feel free to modify the README as per your specific project requirements and branding! Let me know if you need further adjustments or additions.