project-baize commited on
Commit
2736189
1 Parent(s): f758461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -107,6 +107,8 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
107
  ).style(container=False)
108
  with gr.Column(min_width=70, scale=1):
109
  submitBtn = gr.Button("Send")
 
 
110
 
111
 
112
  with gr.Row(scale=1):
@@ -191,9 +193,9 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
191
  fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn], show_progress=True
192
  )
193
 
194
- user_input.submit(**transfer_input_args).then(**predict_args)
195
 
196
- submitBtn.click(**transfer_input_args).then(**predict_args)
197
 
198
  emptyBtn.click(
199
  reset_state,
@@ -202,7 +204,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
202
  )
203
  emptyBtn.click(**reset_args)
204
 
205
- retryBtn.click(**retry_args)
206
 
207
  delLastBtn.click(
208
  delete_last_conversation,
@@ -210,11 +212,18 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
210
  [chatbot, history, status_display],
211
  show_progress=True,
212
  )
213
-
 
 
 
 
 
214
  demo.title = "Baize"
215
 
216
- if __name__ == "__main__":
217
- reload_javascript()
218
- demo.queue(concurrency_count=1).launch(
219
- share=False, favicon_path="./assets/favicon.ico", inbrowser=True
220
- )
 
 
 
107
  ).style(container=False)
108
  with gr.Column(min_width=70, scale=1):
109
  submitBtn = gr.Button("Send")
110
+ with gr.Column(min_width=70, scale=1):
111
+ cancelBtn = gr.Button("Stop")
112
 
113
 
114
  with gr.Row(scale=1):
 
193
  fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn], show_progress=True
194
  )
195
 
196
+ predict_event1 = user_input.submit(**transfer_input_args).then(**predict_args)
197
 
198
+ predict_event2 = submitBtn.click(**transfer_input_args).then(**predict_args)
199
 
200
  emptyBtn.click(
201
  reset_state,
 
204
  )
205
  emptyBtn.click(**reset_args)
206
 
207
+ predict_event3 = retryBtn.click(**retry_args)
208
 
209
  delLastBtn.click(
210
  delete_last_conversation,
 
212
  [chatbot, history, status_display],
213
  show_progress=True,
214
  )
215
+ cancelBtn.click(
216
+ cancel_outputing, [], [status_display],
217
+ cancels=[
218
+ predict_event1,predict_event2,predict_event3
219
+ ]
220
+ )
221
  demo.title = "Baize"
222
 
223
+ demo.queue(
224
+ concurrency_count=1,
225
+ max_size=100,
226
+ ).launch(
227
+ max_threads=5,
228
+ server_name="0.0.0.0",
229
+ )