feat: support stop generate button (#53)
This commit is contained in:
parent
17d9a060d8
commit
4b21ebdba6
4
main.py
4
main.py
@ -52,6 +52,7 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|||||||
with gr.Row():
|
with gr.Row():
|
||||||
resetBtn = gr.Button("重置", variant="secondary")
|
resetBtn = gr.Button("重置", variant="secondary")
|
||||||
submitBtn = gr.Button("提交", variant="primary")
|
submitBtn = gr.Button("提交", variant="primary")
|
||||||
|
stopBtn = gr.Button("停止", variant="stop")
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
from check_proxy import check_proxy
|
from check_proxy import check_proxy
|
||||||
statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
|
statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
|
||||||
@ -79,9 +80,10 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|||||||
|
|
||||||
txt.submit(**predict_args)
|
txt.submit(**predict_args)
|
||||||
txt.submit(**empty_txt_args)
|
txt.submit(**empty_txt_args)
|
||||||
submitBtn.click(**predict_args)
|
submit_event = submitBtn.click(**predict_args)
|
||||||
submitBtn.click(**empty_txt_args)
|
submitBtn.click(**empty_txt_args)
|
||||||
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
|
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
|
||||||
|
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
||||||
for k in functional:
|
for k in functional:
|
||||||
functional[k]["Button"].click(predict,
|
functional[k]["Button"].click(predict,
|
||||||
[txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
|
[txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user