Spaces:
Paused
Paused
timer teext
Browse files
app.py
CHANGED
|
@@ -320,17 +320,6 @@ with gr.Blocks() as demo:
|
|
| 320 |
ready = bool((user_input or "").strip())
|
| 321 |
return gr.update(interactive=ready)
|
| 322 |
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
# def disable_support_type(text, locked, current_value):
|
| 326 |
-
# if locked:
|
| 327 |
-
# return gr.update(interactive=False, value=current_value), True
|
| 328 |
-
|
| 329 |
-
# if text and text.strip():
|
| 330 |
-
# return gr.update(interactive=False, value=current_value), True
|
| 331 |
-
|
| 332 |
-
# return gr.update(interactive=True, value=current_value), False
|
| 333 |
-
|
| 334 |
initial_issue.input(
|
| 335 |
toggle_start_button,
|
| 336 |
inputs=[initial_issue, support_type],
|
|
@@ -348,6 +337,7 @@ with gr.Blocks() as demo:
|
|
| 348 |
|
| 349 |
with gr.Row():
|
| 350 |
send_btn = gr.Button("Send", interactive=False)
|
|
|
|
| 351 |
user_input.input(
|
| 352 |
toggle_send_button,
|
| 353 |
inputs=[user_input],
|
|
@@ -384,14 +374,20 @@ with gr.Blocks() as demo:
|
|
| 384 |
|
| 385 |
def disable_after_timeout(start_time):
|
| 386 |
if start_time is None:
|
| 387 |
-
return gr.update()
|
| 388 |
-
|
| 389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
timer.tick(
|
| 391 |
disable_after_timeout,
|
| 392 |
inputs=[start_time_state],
|
| 393 |
-
outputs=[send_btn]
|
| 394 |
-
)
|
| 395 |
|
| 396 |
demo.launch(css=custom_css)
|
| 397 |
|
|
|
|
| 320 |
ready = bool((user_input or "").strip())
|
| 321 |
return gr.update(interactive=ready)
|
| 322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
initial_issue.input(
|
| 324 |
toggle_start_button,
|
| 325 |
inputs=[initial_issue, support_type],
|
|
|
|
| 337 |
|
| 338 |
with gr.Row():
|
| 339 |
send_btn = gr.Button("Send", interactive=False)
|
| 340 |
+
time_left_text = gr.Markdown("")
|
| 341 |
user_input.input(
|
| 342 |
toggle_send_button,
|
| 343 |
inputs=[user_input],
|
|
|
|
| 374 |
|
| 375 |
def disable_after_timeout(start_time):
|
| 376 |
if start_time is None:
|
| 377 |
+
return gr.update(), ""
|
| 378 |
+
|
| 379 |
+
remaining = max(0, int(SESSION_LIMIT_SECONDS - (time.time() - start_time)))
|
| 380 |
+
expired = remaining <= 0
|
| 381 |
+
|
| 382 |
+
if expired:
|
| 383 |
+
return gr.update(interactive=False), "Time remaining: 0 seconds"
|
| 384 |
+
|
| 385 |
+
return gr.update(interactive=True), f"Time remaining: {remaining} seconds"
|
| 386 |
timer.tick(
|
| 387 |
disable_after_timeout,
|
| 388 |
inputs=[start_time_state],
|
| 389 |
+
outputs=[send_btn, time_left_text]
|
| 390 |
+
)
|
| 391 |
|
| 392 |
demo.launch(css=custom_css)
|
| 393 |
|