chansung commited on
Commit
ae23fc1
β€’
1 Parent(s): bc329fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -378,28 +378,34 @@ with gr.Blocks(css="constants/styles.css", theme=gr.themes.Soft()) as demo:
378
 
379
  chat_button.click(None, [cur_arxiv_id], [local_data, chatbot], js=OPEN_CHAT_IF)
380
 
381
- prompt_txtbox.submit(
382
- before_chat_begin, None, [close, reset, regen],
383
  concurrency_limit=20,
384
- ).then(
 
385
  chat_stream,
386
  [cur_arxiv_id, local_data, prompt_txtbox, chat_state],
387
- [prompt_txtbox, chatbot, local_data, close, reset, regen],
388
  concurrency_limit=20, queue=True
389
- ).then(
 
390
  None, [cur_arxiv_id, local_data], None,
391
  js=UPDATE_CHAT_HISTORY
392
  )
393
 
394
- close.click(None, None, None,js=CLOSE_CHAT_IF)
 
 
 
 
395
 
396
  reset.click(
397
- before_chat_begin, None, [close, reset, regen],
398
  concurrency_limit=20,
399
  ).then(
400
  chat_reset,
401
  [local_data, chat_state],
402
- [prompt_txtbox, chatbot, local_data, close, reset, regen],
403
  concurrency_limit=20,
404
  ).then(
405
  None, [cur_arxiv_id, local_data], None,
 
378
 
379
  chat_button.click(None, [cur_arxiv_id], [local_data, chatbot], js=OPEN_CHAT_IF)
380
 
381
+ chat_event1 = prompt_txtbox.submit(
382
+ before_chat_begin, None, [reset, regen],
383
  concurrency_limit=20,
384
+ )
385
+ chat_event2 = chat_event1.then(
386
  chat_stream,
387
  [cur_arxiv_id, local_data, prompt_txtbox, chat_state],
388
+ [prompt_txtbox, chatbot, local_data, reset, regen],
389
  concurrency_limit=20, queue=True
390
+ )
391
+ chat_event2.then(
392
  None, [cur_arxiv_id, local_data], None,
393
  js=UPDATE_CHAT_HISTORY
394
  )
395
 
396
+ close.click(
397
+ None, None, None, cancels=[chat_event1, chat_event2]
398
+ ).then(
399
+ None, None, None,js=CLOSE_CHAT_IF
400
+ )
401
 
402
  reset.click(
403
+ before_chat_begin, None, [reset, regen],
404
  concurrency_limit=20,
405
  ).then(
406
  chat_reset,
407
  [local_data, chat_state],
408
+ [prompt_txtbox, chatbot, local_data, reset, regen],
409
  concurrency_limit=20,
410
  ).then(
411
  None, [cur_arxiv_id, local_data], None,