Spaces:
Running
Running
okabe
commited on
Commit
•
4b21ebd
1
Parent(s):
17d9a06
feat: support stop generate button (#53)
Browse files
main.py
CHANGED
@@ -52,6 +52,7 @@ with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
|
52 |
with gr.Row():
|
53 |
resetBtn = gr.Button("重置", variant="secondary")
|
54 |
submitBtn = gr.Button("提交", variant="primary")
|
|
|
55 |
with gr.Row():
|
56 |
from check_proxy import check_proxy
|
57 |
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:
|
|
79 |
|
80 |
txt.submit(**predict_args)
|
81 |
txt.submit(**empty_txt_args)
|
82 |
-
submitBtn.click(**predict_args)
|
83 |
submitBtn.click(**empty_txt_args)
|
84 |
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
|
|
|
85 |
for k in functional:
|
86 |
functional[k]["Button"].click(predict,
|
87 |
[txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
|
|
|
52 |
with gr.Row():
|
53 |
resetBtn = gr.Button("重置", variant="secondary")
|
54 |
submitBtn = gr.Button("提交", variant="primary")
|
55 |
+
stopBtn = gr.Button("停止", variant="stop")
|
56 |
with gr.Row():
|
57 |
from check_proxy import check_proxy
|
58 |
statusDisplay = gr.Markdown(f"Tip: 按Enter提交, 按Shift+Enter换行. \nNetwork: {check_proxy(proxies)}\nModel: {LLM_MODEL}")
|
|
|
80 |
|
81 |
txt.submit(**predict_args)
|
82 |
txt.submit(**empty_txt_args)
|
83 |
+
submit_event = submitBtn.click(**predict_args)
|
84 |
submitBtn.click(**empty_txt_args)
|
85 |
resetBtn.click(lambda: ([], [], "已重置"), None, [chatbot, history, statusDisplay])
|
86 |
+
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=[submit_event])
|
87 |
for k in functional:
|
88 |
functional[k]["Button"].click(predict,
|
89 |
[txt, top_p, temperature, chatbot, history, system_prompt, gr.State(True), gr.State(k)], [chatbot, history, statusDisplay], show_progress=True)
|