Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
791aec3
1
Parent(s):
6bb9d92
降低处理延迟
Browse files- ChuanhuChatbot.py +3 -7
- modules/utils.py +6 -0
ChuanhuChatbot.py
CHANGED
@@ -318,7 +318,7 @@ with gr.Blocks(
|
|
318 |
)
|
319 |
|
320 |
transfer_input_args = dict(
|
321 |
-
fn=
|
322 |
)
|
323 |
|
324 |
keyTxt.submit(submit_key, keyTxt, [user_api_key, status_display])
|
@@ -326,13 +326,9 @@ with gr.Blocks(
|
|
326 |
# Chatbot
|
327 |
cancelBtn.click(cancel_outputing, [], [])
|
328 |
|
329 |
-
user_input.submit(**transfer_input_args).then(**
|
330 |
-
**start_outputing_args
|
331 |
-
).then(**chatgpt_predict_args).then(**end_outputing_args)
|
332 |
|
333 |
-
submitBtn.click(**transfer_input_args).then(**
|
334 |
-
**start_outputing_args
|
335 |
-
).then(**chatgpt_predict_args).then(**end_outputing_args)
|
336 |
|
337 |
emptyBtn.click(
|
338 |
reset_state,
|
|
|
318 |
)
|
319 |
|
320 |
transfer_input_args = dict(
|
321 |
+
fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn, cancelBtn], show_progress=True
|
322 |
)
|
323 |
|
324 |
keyTxt.submit(submit_key, keyTxt, [user_api_key, status_display])
|
|
|
326 |
# Chatbot
|
327 |
cancelBtn.click(cancel_outputing, [], [])
|
328 |
|
329 |
+
user_input.submit(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
|
|
|
|
|
330 |
|
331 |
+
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
|
|
|
|
|
332 |
|
333 |
emptyBtn.click(
|
334 |
reset_state,
|
modules/utils.py
CHANGED
@@ -409,3 +409,9 @@ def end_outputing():
|
|
409 |
def cancel_outputing():
|
410 |
logging.info("中止输出……")
|
411 |
shared.state.interrupt()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
def cancel_outputing():
|
410 |
logging.info("中止输出……")
|
411 |
shared.state.interrupt()
|
412 |
+
|
413 |
+
def transfer_input(inputs):
|
414 |
+
# 一次性返回,降低延迟
|
415 |
+
textbox = reset_textbox()
|
416 |
+
outputing = start_outputing()
|
417 |
+
return inputs, gr.update(value=""), gr.Button.update(visible=False), gr.Button.update(visible=True)
|