Spaces:
Sleeping
Sleeping
修复`恢复默认设置`的bug、调整`高级`界面布局
Browse files- ChuanhuChatbot.py +18 -17
- modules/chat_func.py +1 -1
- modules/utils.py +1 -1
ChuanhuChatbot.py
CHANGED
@@ -179,8 +179,8 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
179 |
downloadFile = gr.File(interactive=True)
|
180 |
|
181 |
with gr.Tab(label="高级"):
|
182 |
-
default_btn = gr.Button("🔙 恢复默认设置")
|
183 |
gr.Markdown("# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置")
|
|
|
184 |
|
185 |
with gr.Accordion("参数", open=False):
|
186 |
top_p = gr.Slider(
|
@@ -200,22 +200,23 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
|
|
200 |
label="Temperature",
|
201 |
)
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
219 |
|
220 |
gr.Markdown(description)
|
221 |
|
|
|
179 |
downloadFile = gr.File(interactive=True)
|
180 |
|
181 |
with gr.Tab(label="高级"):
|
|
|
182 |
gr.Markdown("# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置")
|
183 |
+
default_btn = gr.Button("🔙 恢复默认设置")
|
184 |
|
185 |
with gr.Accordion("参数", open=False):
|
186 |
top_p = gr.Slider(
|
|
|
200 |
label="Temperature",
|
201 |
)
|
202 |
|
203 |
+
with gr.Accordion("网络设置", open=False):
|
204 |
+
apiurlTxt = gr.Textbox(
|
205 |
+
show_label=True,
|
206 |
+
placeholder=f"在这里输入API地址...",
|
207 |
+
label="API地址",
|
208 |
+
value="https://api.openai.com/v1/chat/completions",
|
209 |
+
lines=2,
|
210 |
+
)
|
211 |
+
changeAPIURLBtn = gr.Button("🔄 切换API地址")
|
212 |
+
proxyTxt = gr.Textbox(
|
213 |
+
show_label=True,
|
214 |
+
placeholder=f"在这里输入代理地址...",
|
215 |
+
label="代理地址(示例:http://127.0.0.1:10809)",
|
216 |
+
value="",
|
217 |
+
lines=2,
|
218 |
+
)
|
219 |
+
changeProxyBtn = gr.Button("🔄 设置代理地址")
|
220 |
|
221 |
gr.Markdown(description)
|
222 |
|
modules/chat_func.py
CHANGED
@@ -71,7 +71,7 @@ def get_response(
|
|
71 |
logging.info(f"使用 HTTPS 代理: {https_proxy}")
|
72 |
proxies["https"] = https_proxy
|
73 |
|
74 |
-
#
|
75 |
if shared.state.api_url != API_URL:
|
76 |
logging.info(f"使用自定义API URL: {shared.state.api_url}")
|
77 |
if proxies:
|
|
|
71 |
logging.info(f"使用 HTTPS 代理: {https_proxy}")
|
72 |
proxies["https"] = https_proxy
|
73 |
|
74 |
+
# 如果有自定义的api-url,使用自定义url发送请求,否则使用默认设置发送请求
|
75 |
if shared.state.api_url != API_URL:
|
76 |
logging.info(f"使用自定义API URL: {shared.state.api_url}")
|
77 |
if proxies:
|
modules/utils.py
CHANGED
@@ -316,7 +316,7 @@ def reset_textbox():
|
|
316 |
|
317 |
|
318 |
def reset_default():
|
319 |
-
newurl = shared.state.
|
320 |
os.environ.pop("HTTPS_PROXY", None)
|
321 |
os.environ.pop("https_proxy", None)
|
322 |
return gr.update(value=newurl), gr.update(value=""), "API URL 和代理已重置"
|
|
|
316 |
|
317 |
|
318 |
def reset_default():
|
319 |
+
newurl = shared.state.reset_api_url()
|
320 |
os.environ.pop("HTTPS_PROXY", None)
|
321 |
os.environ.pop("https_proxy", None)
|
322 |
return gr.update(value=newurl), gr.update(value=""), "API URL 和代理已重置"
|