Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,7 +121,7 @@ therapists = {
|
|
| 121 |
}
|
| 122 |
|
| 123 |
# Initialize Gemini model
|
| 124 |
-
model = genai.GenerativeModel("
|
| 125 |
generation_config={"temperature": 0.7, "max_output_tokens": 200})
|
| 126 |
|
| 127 |
# Chatbot function
|
|
@@ -183,9 +183,9 @@ def chatbot_function(message, mood, conversation_mode, region, state):
|
|
| 183 |
chat_display = ""
|
| 184 |
for user_msg, bot_msg in history:
|
| 185 |
if user_msg:
|
| 186 |
-
chat_display += f"
|
| 187 |
if bot_msg:
|
| 188 |
-
chat_display += f"
|
| 189 |
|
| 190 |
return chat_display, state
|
| 191 |
|
|
@@ -203,13 +203,13 @@ def log_mood(mood, state):
|
|
| 203 |
return "Mood logged!", trend_output, state
|
| 204 |
return "Please select a mood.", None, state
|
| 205 |
|
| 206 |
-
# Mood trend visualization (
|
| 207 |
def show_mood_trends(state):
|
| 208 |
if not state["mood_journal"]:
|
| 209 |
return "No moods logged yet.", state
|
| 210 |
df = pd.DataFrame(state["mood_journal"])
|
| 211 |
fig = px.line(df, x="timestamp", y="mood", title="Your Mood Trends", markers=True)
|
| 212 |
-
fig.update_layout(width=
|
| 213 |
return fig, state
|
| 214 |
|
| 215 |
# Feedback function
|
|
@@ -227,8 +227,8 @@ def show_emergency_resources(region):
|
|
| 227 |
# Get available times for selected therapist
|
| 228 |
def get_available_times(therapist):
|
| 229 |
if therapist and therapist in therapists:
|
| 230 |
-
return therapists[therapist]["times"], f"Available times for {therapist} loaded."
|
| 231 |
-
return ["Select time"], "Please select a therapist."
|
| 232 |
|
| 233 |
# Create MIME message for Gmail API
|
| 234 |
def create_message(to, subject, message_text):
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
# Initialize Gemini model
|
| 124 |
+
model = genai.GenerativeModel("gemini-1.5-flash",
|
| 125 |
generation_config={"temperature": 0.7, "max_output_tokens": 200})
|
| 126 |
|
| 127 |
# Chatbot function
|
|
|
|
| 183 |
chat_display = ""
|
| 184 |
for user_msg, bot_msg in history:
|
| 185 |
if user_msg:
|
| 186 |
+
chat_display += f"🧑: {user_msg}\n\n"
|
| 187 |
if bot_msg:
|
| 188 |
+
chat_display += f"🤗: {bot_msg}\n\n"
|
| 189 |
|
| 190 |
return chat_display, state
|
| 191 |
|
|
|
|
| 203 |
return "Mood logged!", trend_output, state
|
| 204 |
return "Please select a mood.", None, state
|
| 205 |
|
| 206 |
+
# Mood trend visualization (responsive size)
|
| 207 |
def show_mood_trends(state):
|
| 208 |
if not state["mood_journal"]:
|
| 209 |
return "No moods logged yet.", state
|
| 210 |
df = pd.DataFrame(state["mood_journal"])
|
| 211 |
fig = px.line(df, x="timestamp", y="mood", title="Your Mood Trends", markers=True)
|
| 212 |
+
fig.update_layout(width=None, height=400, autosize=True, margin=dict(l=20, r=20, t=40, b=20))
|
| 213 |
return fig, state
|
| 214 |
|
| 215 |
# Feedback function
|
|
|
|
| 227 |
# Get available times for selected therapist
|
| 228 |
def get_available_times(therapist):
|
| 229 |
if therapist and therapist in therapists:
|
| 230 |
+
return gr.update(choices=therapists[therapist]["times"], value=None), f"Available times for {therapist} loaded."
|
| 231 |
+
return gr.update(choices=["Select time"], value=None), "Please select a therapist."
|
| 232 |
|
| 233 |
# Create MIME message for Gmail API
|
| 234 |
def create_message(to, subject, message_text):
|