Nikki5 commited on
Commit
4bf1f3f
·
1 Parent(s): 885dee8

timer issue

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -288,16 +288,6 @@ button[aria-label="Copy all"] {
288
  with gr.Blocks() as demo:
289
  start_time_state = gr.State(None)
290
  timer = gr.Timer(1.0)
291
- def disable_after_timeout(start_time):
292
- if start_time is None:
293
- return gr.update()
294
- expired = (time.time() - start_time) >= SESSION_LIMIT_SECONDS
295
- return gr.update(interactive=not expired)
296
- timer.tick(
297
- disable_after_timeout,
298
- inputs=[start_time_state],
299
- outputs=[send_btn]
300
- )
301
  # gr.Markdown("## Support Chatbot")
302
  gr.Markdown("Describe a stressful situation in the past.")
303
  initial_issue = gr.Textbox(
@@ -391,6 +381,17 @@ with gr.Blocks() as demo:
391
  inputs=[user_input, history_state, context_state, support_type, session_state, start_time_state],
392
  outputs=[user_input, chatbot, context_state, history_state, session_state, start_time_state, send_btn]
393
  )
 
 
 
 
 
 
 
 
 
 
 
394
 
395
  demo.launch(css=custom_css)
396
 
 
288
  with gr.Blocks() as demo:
289
  start_time_state = gr.State(None)
290
  timer = gr.Timer(1.0)
 
 
 
 
 
 
 
 
 
 
291
  # gr.Markdown("## Support Chatbot")
292
  gr.Markdown("Describe a stressful situation in the past.")
293
  initial_issue = gr.Textbox(
 
381
  inputs=[user_input, history_state, context_state, support_type, session_state, start_time_state],
382
  outputs=[user_input, chatbot, context_state, history_state, session_state, start_time_state, send_btn]
383
  )
384
+
385
+ def disable_after_timeout(start_time):
386
+ if start_time is None:
387
+ return gr.update()
388
+ expired = (time.time() - start_time) >= SESSION_LIMIT_SECONDS
389
+ return gr.update(interactive=not expired)
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