Spaces:
Sleeping
Sleeping
feat: 将ip/port/share这些跟launch有关的参数转移到config.json中 (#608)
Browse files- ChuanhuChatbot.py +12 -32
- config_example.json +7 -2
- modules/config.py +20 -1
ChuanhuChatbot.py
CHANGED
@@ -432,35 +432,15 @@ demo.title = "川虎ChatGPT 🚀"
|
|
432 |
|
433 |
if __name__ == "__main__":
|
434 |
reload_javascript()
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
server_port=7860,
|
448 |
-
share=False,
|
449 |
-
favicon_path="./assets/favicon.ico",
|
450 |
-
)
|
451 |
-
# if not running in Docker
|
452 |
-
else:
|
453 |
-
if authflag:
|
454 |
-
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
|
455 |
-
share=False,
|
456 |
-
auth=auth_list,
|
457 |
-
favicon_path="./assets/favicon.ico",
|
458 |
-
inbrowser=True,
|
459 |
-
)
|
460 |
-
else:
|
461 |
-
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
|
462 |
-
share=False, favicon_path="./assets/favicon.ico", inbrowser=True
|
463 |
-
) # 改为 share=True 可以创建公开分享链接
|
464 |
-
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
465 |
-
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
466 |
-
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
|
|
432 |
|
433 |
if __name__ == "__main__":
|
434 |
reload_javascript()
|
435 |
+
auth = auth_list if authflag else None
|
436 |
+
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
|
437 |
+
server_name=server_name,
|
438 |
+
server_port=server_port,
|
439 |
+
share=share,
|
440 |
+
auth=auth_list,
|
441 |
+
favicon_path="./assets/favicon.ico",
|
442 |
+
inbrowser=not dockerflag, # 禁止在docker下开启inbrowser
|
443 |
+
)
|
444 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
445 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
446 |
+
# demo.queue(concurrency_count=CONCURRENT_COUNT).launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config_example.json
CHANGED
@@ -21,5 +21,10 @@
|
|
21 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
|
22 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
|
23 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
|
24 |
-
]
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
21 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
|
22 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
|
23 |
"sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
|
24 |
+
],
|
25 |
+
// 如果使用自定义端口、自定义ip,请取消注释并替换对应内容
|
26 |
+
// "server_name": "0.0.0.0",
|
27 |
+
// "server_port": 7860,
|
28 |
+
// 如果要share到gradio,设置为true
|
29 |
+
// "share": false,
|
30 |
+
}
|
modules/config.py
CHANGED
@@ -18,6 +18,9 @@ __all__ = [
|
|
18 |
"advance_docs",
|
19 |
"update_doc_config",
|
20 |
"multi_api_key",
|
|
|
|
|
|
|
21 |
]
|
22 |
|
23 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
@@ -147,4 +150,20 @@ def update_doc_config(two_column_pdf):
|
|
147 |
global advance_docs
|
148 |
advance_docs["pdf"]["two_column"] = two_column_pdf
|
149 |
|
150 |
-
logging.info(f"更新后的文件参数为:{advance_docs}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
"advance_docs",
|
19 |
"update_doc_config",
|
20 |
"multi_api_key",
|
21 |
+
"server_name",
|
22 |
+
"server_port",
|
23 |
+
"share",
|
24 |
]
|
25 |
|
26 |
# 添加一个统一的config文件,避免文件过多造成的疑惑(优先级最低)
|
|
|
150 |
global advance_docs
|
151 |
advance_docs["pdf"]["two_column"] = two_column_pdf
|
152 |
|
153 |
+
logging.info(f"更新后的文件参数为:{advance_docs}")
|
154 |
+
|
155 |
+
## 处理gradio.launch参数
|
156 |
+
server_name = config.get("server_name", None)
|
157 |
+
server_port = config.get("server_port", None)
|
158 |
+
if server_name is None:
|
159 |
+
if dockerflag:
|
160 |
+
server_name = "0.0.0.0"
|
161 |
+
else:
|
162 |
+
server_name = "127.0.0.1"
|
163 |
+
if server_port is None:
|
164 |
+
if dockerflag:
|
165 |
+
server_port = 7860
|
166 |
+
|
167 |
+
assert server_port is None or type(server_port) == int, "要求port设置为int类型"
|
168 |
+
|
169 |
+
share = config.get("share", False)
|