Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import google.generativeai as genai | |
| import os | |
| # π API KEY (replace with your own OR use HF secrets) | |
| genai.configure(api_key="AIzaSyCv41YJ6j_Iag1Lf9RrFeOBdeS5gOedmz8") | |
| # β‘ Model (stable working one) | |
| model = genai.GenerativeModel("gemini-1.5-flash") | |
| def chat(message, history): | |
| try: | |
| response = model.generate_content( | |
| "You are a kind, supportive mental health assistant. " | |
| "Reply calmly and helpfully.\n\nUser: " + message | |
| ) | |
| return response.text | |
| except: | |
| return "I'm here for you π Please tell me more." | |
| # π¬ Gradio Chat UI | |
| demo = gr.ChatInterface( | |
| fn=chat, | |
| title="π Mental Health Support Bot", | |
| description="A safe space to talk anytime π" | |
| ) | |
| demo.launch() |