Spaces:
Sleeping
Sleeping
添加命令行参数
Browse files- ChuanhuChatbot.py +10 -2
ChuanhuChatbot.py
CHANGED
@@ -2,10 +2,18 @@ import gradio as gr
|
|
2 |
# import openai
|
3 |
import os
|
4 |
import sys
|
|
|
5 |
from utils import *
|
6 |
from presets import *
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
|
10 |
|
11 |
gr.Chatbot.postprocess = postprocess
|
@@ -140,7 +148,7 @@ else:
|
|
140 |
if authflag:
|
141 |
demo.queue().launch(share=False, auth=(username, password))
|
142 |
else:
|
143 |
-
demo.queue().launch(share=
|
144 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
145 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
146 |
#demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
|
|
2 |
# import openai
|
3 |
import os
|
4 |
import sys
|
5 |
+
import argparse
|
6 |
from utils import *
|
7 |
from presets import *
|
8 |
|
9 |
+
parse = argparse.ArgumentParser()
|
10 |
+
parse.add_argument('--host', type=str, help='Server Host', default="127.0.0.1")
|
11 |
+
parse.add_argument('--port', type=int, help='Server Port', default=7860)
|
12 |
+
parse.add_argument('--api_key', type=str, help='OpenAI API Key', default="")
|
13 |
+
parse.add_argument('--share', type=bool, help='Share to public', default=False)
|
14 |
+
args = parse.parse_args()
|
15 |
+
|
16 |
+
my_api_key = args.api_key # 在这里输入你的 API 密钥
|
17 |
HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
|
18 |
|
19 |
gr.Chatbot.postprocess = postprocess
|
|
|
148 |
if authflag:
|
149 |
demo.queue().launch(share=False, auth=(username, password))
|
150 |
else:
|
151 |
+
demo.queue().launch(server_name=args.host, server_port=args.port, share=args.share) # 改为 share=True 可以创建公开分享链接
|
152 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
153 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
154 |
#demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|