File size: 769 Bytes
f8187ee
 
1597306
f8187ee
1597306
 
f8187ee
1597306
 
f8187ee
1597306
f8187ee
 
1597306
 
f8187ee
 
 
1597306
 
 
 
 
 
 
 
f8187ee
1597306
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()