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
|
@@ -185,7 +185,7 @@ def chatbot_function(message, mood, conversation_mode, region, state):
|
|
185 |
if user_msg:
|
186 |
chat_display += f"🧑: {user_msg}\n\n"
|
187 |
if bot_msg:
|
188 |
-
chat_display += f"
|
189 |
|
190 |
return chat_display, state
|
191 |
|
@@ -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
|
231 |
-
return
|
232 |
|
233 |
# Create MIME message for Gmail API
|
234 |
def create_message(to, subject, message_text):
|
@@ -326,8 +326,8 @@ def schedule_appointment(therapist, time_slot, date, user_email, state):
|
|
326 |
return "Invalid date format (use YYYY-MM-DD).", state
|
327 |
|
328 |
try:
|
329 |
-
#
|
330 |
-
|
331 |
if time_slot not in therapists[therapist]["times"]:
|
332 |
return f"Time {time_slot} is not available for {therapist}.", state
|
333 |
except ValueError:
|
@@ -420,7 +420,8 @@ with gr.Blocks(title="Healora Chatbot", css=custom_css) as demo:
|
|
420 |
with gr.Accordion("Appointments"):
|
421 |
therapist = gr.Dropdown(
|
422 |
choices=list(therapists.keys()),
|
423 |
-
label="Select Therapist"
|
|
|
424 |
)
|
425 |
date = gr.Textbox(
|
426 |
label="Date",
|
@@ -431,6 +432,7 @@ with gr.Blocks(title="Healora Chatbot", css=custom_css) as demo:
|
|
431 |
choices=["Select time"],
|
432 |
label="Time",
|
433 |
interactive=True,
|
|
|
434 |
allow_custom_value=True
|
435 |
)
|
436 |
user_email = gr.Textbox(
|
@@ -473,7 +475,7 @@ with gr.Blocks(title="Healora Chatbot", css=custom_css) as demo:
|
|
473 |
therapist.change(
|
474 |
fn=get_available_times,
|
475 |
inputs=therapist,
|
476 |
-
outputs=
|
477 |
)
|
478 |
schedule_btn.click(
|
479 |
fn=schedule_appointment,
|
|
|
121 |
}
|
122 |
|
123 |
# Initialize Gemini model
|
124 |
+
model = genai.GenerativeModel("learnlm-1.5-pro-experimental",
|
125 |
generation_config={"temperature": 0.7, "max_output_tokens": 200})
|
126 |
|
127 |
# Chatbot function
|
|
|
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 |
|
|
|
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"]
|
231 |
+
return ["Select time"]
|
232 |
|
233 |
# Create MIME message for Gmail API
|
234 |
def create_message(to, subject, message_text):
|
|
|
326 |
return "Invalid date format (use YYYY-MM-DD).", state
|
327 |
|
328 |
try:
|
329 |
+
# Validate 12-hour format
|
330 |
+
datetime.strptime(time_slot, "%I:%M %p")
|
331 |
if time_slot not in therapists[therapist]["times"]:
|
332 |
return f"Time {time_slot} is not available for {therapist}.", state
|
333 |
except ValueError:
|
|
|
420 |
with gr.Accordion("Appointments"):
|
421 |
therapist = gr.Dropdown(
|
422 |
choices=list(therapists.keys()),
|
423 |
+
label="Select Therapist",
|
424 |
+
value=None
|
425 |
)
|
426 |
date = gr.Textbox(
|
427 |
label="Date",
|
|
|
432 |
choices=["Select time"],
|
433 |
label="Time",
|
434 |
interactive=True,
|
435 |
+
value=None,
|
436 |
allow_custom_value=True
|
437 |
)
|
438 |
user_email = gr.Textbox(
|
|
|
475 |
therapist.change(
|
476 |
fn=get_available_times,
|
477 |
inputs=therapist,
|
478 |
+
outputs=time_slot
|
479 |
)
|
480 |
schedule_btn.click(
|
481 |
fn=schedule_appointment,
|