ffreemt commited on
Commit
5618f5b
1 Parent(s): bd61bf0

Update Stop Button

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -379,7 +379,7 @@ with gr.Blocks(
379
  with gr.Column(scale=1, min_width=50):
380
  with gr.Row():
381
  submit = gr.Button("Submit", elem_classes="xsmall")
382
- stop = gr.Button("Stop", visible=False)
383
  clear = gr.Button("Clear History", visible=True)
384
  with gr.Row(visible=False):
385
  with gr.Accordion("Advanced Options:", open=False):
@@ -415,7 +415,7 @@ with gr.Blocks(
415
  elem_classes=["disclaimer"],
416
  )
417
 
418
- msg.submit(
419
  # fn=conversation.user_turn,
420
  fn=user,
421
  inputs=[msg, chatbot],
@@ -424,7 +424,7 @@ with gr.Blocks(
424
  show_progress="full",
425
  # api_name=None,
426
  ).then(bot, chatbot, chatbot, queue=True)
427
- submit.click(
428
  # fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
429
  fn=user1, # clear msg
430
  inputs=[msg, chatbot],
@@ -434,7 +434,13 @@ with gr.Blocks(
434
  show_progress="full",
435
  # api_name=None,
436
  ).then(bot, chatbot, chatbot, queue=True)
437
-
 
 
 
 
 
 
438
  clear.click(lambda: None, None, chatbot, queue=False)
439
 
440
  with gr.Accordion("For Chat/Translation API", open=False, visible=False):
 
379
  with gr.Column(scale=1, min_width=50):
380
  with gr.Row():
381
  submit = gr.Button("Submit", elem_classes="xsmall")
382
+ stop = gr.Button("Stop", visible=True)
383
  clear = gr.Button("Clear History", visible=True)
384
  with gr.Row(visible=False):
385
  with gr.Accordion("Advanced Options:", open=False):
 
415
  elem_classes=["disclaimer"],
416
  )
417
 
418
+ msg_submit_event = msg.submit(
419
  # fn=conversation.user_turn,
420
  fn=user,
421
  inputs=[msg, chatbot],
 
424
  show_progress="full",
425
  # api_name=None,
426
  ).then(bot, chatbot, chatbot, queue=True)
427
+ submit_click_event = submit.click(
428
  # fn=lambda x, y: ("",) + user(x, y)[1:], # clear msg
429
  fn=user1, # clear msg
430
  inputs=[msg, chatbot],
 
434
  show_progress="full",
435
  # api_name=None,
436
  ).then(bot, chatbot, chatbot, queue=True)
437
+ stop.click(
438
+ fn=None,
439
+ inputs=None,
440
+ outputs=None,
441
+ cancels=[msg_submit_event, submit_click_event],
442
+ queue=False,
443
+ )
444
  clear.click(lambda: None, None, chatbot, queue=False)
445
 
446
  with gr.Accordion("For Chat/Translation API", open=False, visible=False):