Update app.py
Browse files
app.py
CHANGED
|
@@ -309,16 +309,26 @@ def create_card(title, content, color, card_type):
|
|
| 309 |
return card_html
|
| 310 |
|
| 311 |
|
| 312 |
-
def clear_all():
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
return (
|
| 315 |
"",
|
| 316 |
"<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:300px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Your route details will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Enter a query and click Send to get started</p></div></div>",
|
| 317 |
"<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:600px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Interactive map will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Plan a route to see the map</p></div></div>",
|
| 318 |
-
|
| 319 |
)
|
| 320 |
|
| 321 |
|
|
|
|
| 322 |
with gr.Blocks(
|
| 323 |
theme=gr.themes.Soft(primary_hue="green", secondary_hue="emerald"),
|
| 324 |
title="SparkDelivery - Intelligent Route Planning",
|
|
@@ -463,9 +473,15 @@ with gr.Blocks(
|
|
| 463 |
outputs=[output, map_output, user_session_state,query_input]
|
| 464 |
)
|
| 465 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
clear_btn.click(
|
| 467 |
fn=clear_all,
|
| 468 |
-
inputs=
|
| 469 |
outputs=[query_input, output, map_output, user_session_state]
|
| 470 |
)
|
| 471 |
|
|
|
|
| 309 |
return card_html
|
| 310 |
|
| 311 |
|
| 312 |
+
# def clear_all():
|
| 313 |
+
# """Clear all outputs and reset session"""
|
| 314 |
+
# return (
|
| 315 |
+
# "",
|
| 316 |
+
# "<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:300px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Your route details will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Enter a query and click Send to get started</p></div></div>",
|
| 317 |
+
# "<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:600px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Interactive map will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Plan a route to see the map</p></div></div>",
|
| 318 |
+
# None # Reset thread_id to start new conversation
|
| 319 |
+
# )
|
| 320 |
+
|
| 321 |
+
def clear_all(current_session):
|
| 322 |
+
"""Clear all outputs but preserve session for memory continuity"""
|
| 323 |
return (
|
| 324 |
"",
|
| 325 |
"<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:300px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Your route details will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Enter a query and click Send to get started</p></div></div>",
|
| 326 |
"<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:600px; display:flex; align-items:center; justify-content:center;'><div><p style='font-size:1.1em;'>Interactive map will appear here</p><p style='font-size:0.9em; margin-top:10px; color:#9e9e9e;'>Plan a route to see the map</p></div></div>",
|
| 327 |
+
current_session # Keep the session to preserve conversation memory
|
| 328 |
)
|
| 329 |
|
| 330 |
|
| 331 |
+
|
| 332 |
with gr.Blocks(
|
| 333 |
theme=gr.themes.Soft(primary_hue="green", secondary_hue="emerald"),
|
| 334 |
title="SparkDelivery - Intelligent Route Planning",
|
|
|
|
| 473 |
outputs=[output, map_output, user_session_state,query_input]
|
| 474 |
)
|
| 475 |
|
| 476 |
+
# clear_btn.click(
|
| 477 |
+
# fn=clear_all,
|
| 478 |
+
# inputs=None,
|
| 479 |
+
# outputs=[query_input, output, map_output, user_session_state]
|
| 480 |
+
# )
|
| 481 |
+
|
| 482 |
clear_btn.click(
|
| 483 |
fn=clear_all,
|
| 484 |
+
inputs=[user_session_state],
|
| 485 |
outputs=[query_input, output, map_output, user_session_state]
|
| 486 |
)
|
| 487 |
|