Update app.py
Browse files
app.py
CHANGED
|
@@ -165,7 +165,7 @@ def process_delivery_query(query, user_session_id, request: gr.Request):
|
|
| 165 |
cleanup_static_folder()
|
| 166 |
|
| 167 |
# return html_response, map_display, user_session_id
|
| 168 |
-
return html_response, map_display, user_session_id, "
|
| 169 |
|
| 170 |
|
| 171 |
except Exception as e:
|
|
@@ -307,19 +307,6 @@ def clear_all():
|
|
| 307 |
with gr.Blocks(
|
| 308 |
theme=gr.themes.Soft(primary_hue="green", secondary_hue="emerald"),
|
| 309 |
title="SparkDelivery - Intelligent Route Planning",
|
| 310 |
-
# css="""
|
| 311 |
-
# .gradio-container { max-width: 100% !important; }
|
| 312 |
-
# .input-box textarea { font-size: 1.05em !important; }
|
| 313 |
-
# button.primary {
|
| 314 |
-
# background: #78C841 !important;
|
| 315 |
-
# border-color: #78C841 !important;
|
| 316 |
-
# color: white !important;
|
| 317 |
-
# }
|
| 318 |
-
# button.primary:hover {
|
| 319 |
-
# background: #5d8a47 !important;
|
| 320 |
-
# border-color: #5d8a47 !important;
|
| 321 |
-
# }
|
| 322 |
-
# """
|
| 323 |
css=css
|
| 324 |
) as demo:
|
| 325 |
|
|
@@ -340,11 +327,11 @@ with gr.Blocks(
|
|
| 340 |
</div>
|
| 341 |
<div style='text-align: center;'>
|
| 342 |
<p style='margin-top:20px; font-size:1.30em; opacity:0.92; color: white;'>
|
| 343 |
-
|
| 344 |
</p>
|
| 345 |
|
| 346 |
<p style='margin-top:5px; font-size:1.05em; opacity:0.85; color: white;'>
|
| 347 |
-
|
| 348 |
</p>
|
| 349 |
</div>
|
| 350 |
""")
|
|
@@ -437,32 +424,17 @@ with gr.Blocks(
|
|
| 437 |
Plan a route to see the map</p></div></div>"""
|
| 438 |
)
|
| 439 |
|
| 440 |
-
# def reset_before_new_query():
|
| 441 |
-
# """Show loading state while processing"""
|
| 442 |
-
# return (
|
| 443 |
-
# "<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:300px;'>Processing new request...</div>",
|
| 444 |
-
# "<div style='padding:40px; text-align:center; color:#757575; background:#fafafa; border-radius:10px; min-height:300px;'>Loading new map...</div>",
|
| 445 |
-
# )
|
| 446 |
|
| 447 |
def reset_before_new_query(query):
|
| 448 |
"""Show loading state in query input while processing"""
|
| 449 |
loading_message = f"{query}\n\n⏳ Processing your request..."
|
| 450 |
return loading_message
|
| 451 |
|
| 452 |
-
# submit_btn.click(
|
| 453 |
-
# fn=reset_before_new_query,
|
| 454 |
-
# inputs=None,
|
| 455 |
-
# outputs=[output, map_output]
|
| 456 |
-
# ).then(
|
| 457 |
-
# fn=process_delivery_query,
|
| 458 |
-
# inputs=[query_input, user_session_state],
|
| 459 |
-
# outputs=[output, map_output, user_session_state], # Updates thread_id state
|
| 460 |
-
# )
|
| 461 |
|
| 462 |
submit_btn.click(
|
| 463 |
fn=reset_before_new_query,
|
| 464 |
-
inputs=[query_input],
|
| 465 |
-
outputs=[query_input]
|
| 466 |
).then(
|
| 467 |
fn=process_delivery_query,
|
| 468 |
inputs=[query_input, user_session_state],
|
|
|
|
| 165 |
cleanup_static_folder()
|
| 166 |
|
| 167 |
# return html_response, map_display, user_session_id
|
| 168 |
+
return html_response, map_display, user_session_id, "Response generated successfully! Check your results below."
|
| 169 |
|
| 170 |
|
| 171 |
except Exception as e:
|
|
|
|
| 307 |
with gr.Blocks(
|
| 308 |
theme=gr.themes.Soft(primary_hue="green", secondary_hue="emerald"),
|
| 309 |
title="SparkDelivery - Intelligent Route Planning",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
css=css
|
| 311 |
) as demo:
|
| 312 |
|
|
|
|
| 327 |
</div>
|
| 328 |
<div style='text-align: center;'>
|
| 329 |
<p style='margin-top:20px; font-size:1.30em; opacity:0.92; color: white;'>
|
| 330 |
+
Intelligent Route Planning with Real-Time Weather and Traffic Analysis
|
| 331 |
</p>
|
| 332 |
|
| 333 |
<p style='margin-top:5px; font-size:1.05em; opacity:0.85; color: white;'>
|
| 334 |
+
Powered by SparkBrains
|
| 335 |
</p>
|
| 336 |
</div>
|
| 337 |
""")
|
|
|
|
| 424 |
Plan a route to see the map</p></div></div>"""
|
| 425 |
)
|
| 426 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 427 |
|
| 428 |
def reset_before_new_query(query):
|
| 429 |
"""Show loading state in query input while processing"""
|
| 430 |
loading_message = f"{query}\n\n⏳ Processing your request..."
|
| 431 |
return loading_message
|
| 432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
|
| 434 |
submit_btn.click(
|
| 435 |
fn=reset_before_new_query,
|
| 436 |
+
inputs=[query_input],
|
| 437 |
+
outputs=[query_input]
|
| 438 |
).then(
|
| 439 |
fn=process_delivery_query,
|
| 440 |
inputs=[query_input, user_session_state],
|