Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
75b3db6
1
Parent(s):
71f0617
最多允许100人同时使用
Browse files- ChuanhuChatbot.py +9 -7
- presets.py +1 -0
- utils.py +7 -0
ChuanhuChatbot.py
CHANGED
@@ -143,6 +143,7 @@ with gr.Blocks(
|
|
143 |
).style(container=False)
|
144 |
with gr.Column(min_width=70, scale=1):
|
145 |
submitBtn = gr.Button("发送", variant="primary")
|
|
|
146 |
with gr.Row(scale=1):
|
147 |
emptyBtn = gr.Button(
|
148 |
"🧹 新的对话",
|
@@ -298,6 +299,7 @@ with gr.Blocks(
|
|
298 |
)
|
299 |
user_input.submit(reset_textbox, [], [user_input])
|
300 |
|
|
|
301 |
submitBtn.click(
|
302 |
predict,
|
303 |
[
|
@@ -438,18 +440,18 @@ if __name__ == "__main__":
|
|
438 |
# if running in Docker
|
439 |
if dockerflag:
|
440 |
if authflag:
|
441 |
-
demo.queue().launch(
|
442 |
server_name="0.0.0.0", server_port=7860, auth=(username, password),
|
443 |
favicon_path="./assets/favicon.png"
|
444 |
)
|
445 |
else:
|
446 |
-
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
447 |
# if not running in Docker
|
448 |
else:
|
449 |
if authflag:
|
450 |
-
demo.queue().launch(share=False, auth=(username, password), favicon_path="./assets/favicon.png", inbrowser=True)
|
451 |
else:
|
452 |
-
demo.queue().launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
453 |
-
# demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
454 |
-
# demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
455 |
-
# demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
|
|
143 |
).style(container=False)
|
144 |
with gr.Column(min_width=70, scale=1):
|
145 |
submitBtn = gr.Button("发送", variant="primary")
|
146 |
+
cancelBtn = gr.Button("取消", variant="secondary", visible=False)
|
147 |
with gr.Row(scale=1):
|
148 |
emptyBtn = gr.Button(
|
149 |
"🧹 新的对话",
|
|
|
299 |
)
|
300 |
user_input.submit(reset_textbox, [], [user_input])
|
301 |
|
302 |
+
# submitBtn.click(return_cancel_btn, [], [submitBtn, cancelBtn])
|
303 |
submitBtn.click(
|
304 |
predict,
|
305 |
[
|
|
|
440 |
# if running in Docker
|
441 |
if dockerflag:
|
442 |
if authflag:
|
443 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
|
444 |
server_name="0.0.0.0", server_port=7860, auth=(username, password),
|
445 |
favicon_path="./assets/favicon.png"
|
446 |
)
|
447 |
else:
|
448 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
449 |
# if not running in Docker
|
450 |
else:
|
451 |
if authflag:
|
452 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(share=False, auth=(username, password), favicon_path="./assets/favicon.png", inbrowser=True)
|
453 |
else:
|
454 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
455 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
456 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
457 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
presets.py
CHANGED
@@ -21,6 +21,7 @@ max_token_all = 3500 # 非流式对话时的最大 token 数
|
|
21 |
timeout_all = 200 # 非流式对话时的超时时间
|
22 |
enable_streaming_option = True # 是否启用选择选择是否实时显示回答的勾选框
|
23 |
HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
|
|
|
24 |
|
25 |
SIM_K = 5
|
26 |
INDEX_QUERY_TEMPRATURE = 1.0
|
|
|
21 |
timeout_all = 200 # 非流式对话时的超时时间
|
22 |
enable_streaming_option = True # 是否启用选择选择是否实时显示回答的勾选框
|
23 |
HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
|
24 |
+
CONCURRENT_COUNT = 100 # 允许同时使用的用户数量
|
25 |
|
26 |
SIM_K = 5
|
27 |
INDEX_QUERY_TEMPRATURE = 1.0
|
utils.py
CHANGED
@@ -387,3 +387,10 @@ def find_n(lst, max_num):
|
|
387 |
return n - i -1
|
388 |
total = total - lst[i]
|
389 |
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
387 |
return n - i -1
|
388 |
total = total - lst[i]
|
389 |
return 1
|
390 |
+
|
391 |
+
def return_cancel_btn():
|
392 |
+
return gr.Button.update(
|
393 |
+
visible=False
|
394 |
+
), gr.Button.update(
|
395 |
+
visible=True
|
396 |
+
)
|