Python-based service providing supportive AI chat using Google Gemini 2.0 Flash with built-in crisis detection and scope enforcement for mental health safety.
- Python 3.x, FastAPI (or Flask, depending on implementation)
- Google Generative AI (Gemini 2.0 Flash)
- Uvicorn / Gunicorn, CORS
GET /health– service statusPOST /chat– chat with context{ message, conversation_history? }
- Crisis detection using regex patterns (e.g., suicide ideation, self-harm)
- India-specific resources returned on crisis (Aasra, Vandrevala, SNEHA)
- Scope enforcement for non-mental-health queries
- Prerequisites: Python 3.10+
- Install dependencies:
pip install -r requirements.txt
- Environment variables:
- GEMINI_API_KEY=your_api_key
- PORT=8080
- Run locally (example):
python application.py
{
"message": "I'm feeling overwhelmed lately",
"conversation_history": [
{"role":"user","content":"I'm stressed"},
{"role":"assistant","content":"I'm here to listen."}
]
}- Dockerized via
Dockerfile. Deploy on any Python host. Ensure API keys and CORS are configured.