ffreemt commited on
Commit
66e155f
1 Parent(s): dabc6d4

Update stop button

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -370,7 +370,7 @@ with gr.Blocks(
370
  with gr.Column(scale=1, min_width=50):
371
  with gr.Row():
372
  submit = gr.Button("Submit", elem_classes="xsmall")
373
- stop = gr.Button("Stop", visible=False)
374
  clear = gr.Button("Clear History", visible=True)
375
  with gr.Row(visible=False):
376
  with gr.Accordion("Advanced Options:", open=False):
@@ -406,7 +406,7 @@ with gr.Blocks(
406
  elem_classes=["disclaimer"],
407
  )
408
 
409
- msg.submit(
410
  # fn=conversation.user_turn,
411
  fn=user,
412
  inputs=[msg, chatbot],
@@ -415,7 +415,7 @@ with gr.Blocks(
415
  show_progress="full",
416
  # api_name=None,
417
  ).then(bot, chatbot, chatbot, queue=True)
418
- submit.click(
419
  # fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
420
  fn=user1, # clear msg
421
  inputs=[msg, chatbot],
@@ -425,7 +425,13 @@ with gr.Blocks(
425
  show_progress="full",
426
  # api_name=None,
427
  ).then(bot, chatbot, chatbot, queue=True)
428
-
 
 
 
 
 
 
429
  clear.click(lambda: None, None, chatbot, queue=False)
430
 
431
  with gr.Accordion("For Chat/Translation API", open=False, visible=False):
 
370
  with gr.Column(scale=1, min_width=50):
371
  with gr.Row():
372
  submit = gr.Button("Submit", elem_classes="xsmall")
373
+ stop = gr.Button("Stop", visible=True)
374
  clear = gr.Button("Clear History", visible=True)
375
  with gr.Row(visible=False):
376
  with gr.Accordion("Advanced Options:", open=False):
 
406
  elem_classes=["disclaimer"],
407
  )
408
 
409
+ msg_submit_event = msg.submit(
410
  # fn=conversation.user_turn,
411
  fn=user,
412
  inputs=[msg, chatbot],
 
415
  show_progress="full",
416
  # api_name=None,
417
  ).then(bot, chatbot, chatbot, queue=True)
418
+ submit_click_event = submit.click(
419
  # fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
420
  fn=user1, # clear msg
421
  inputs=[msg, chatbot],
 
425
  show_progress="full",
426
  # api_name=None,
427
  ).then(bot, chatbot, chatbot, queue=True)
428
+ stop.click(
429
+ fn=None,
430
+ inputs=None,
431
+ outputs=None,
432
+ cancels=[msg_submit_event, submit_click_event],
433
+ queue=False,
434
+ )
435
  clear.click(lambda: None, None, chatbot, queue=False)
436
 
437
  with gr.Accordion("For Chat/Translation API", open=False, visible=False):