Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import google.generativeai as genai
|
| 4 |
+
|
| 5 |
+
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
| 6 |
+
|
| 7 |
+
model = genai.GenerativeModel("gemini-2.0-flash")
|
| 8 |
+
|
| 9 |
+
def chat(message):
|
| 10 |
+
try:
|
| 11 |
+
response = model.generate_content(
|
| 12 |
+
f"You are a calm mental health assistant. Reply kindly:\n{message}"
|
| 13 |
+
)
|
| 14 |
+
return response.text
|
| 15 |
+
except:
|
| 16 |
+
return "I'm here for you 💙 Please try again."
|
| 17 |
+
|
| 18 |
+
gr.ChatInterface(chat).launch()
|