Spaces:
Build error
Build error
fulyaec
commited on
Commit
•
cec4480
1
Parent(s):
a88a427
refactor and enhance
Browse files- main.py +2 -3
- toolbox.py +3 -6
main.py
CHANGED
@@ -10,7 +10,7 @@ proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = \
|
|
10 |
|
11 |
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
12 |
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
13 |
-
|
14 |
|
15 |
initial_prompt = "Serve me as a writing and programming assistant."
|
16 |
title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
|
@@ -105,8 +105,7 @@ def auto_opentab_delay():
|
|
105 |
def open():
|
106 |
time.sleep(2)
|
107 |
webbrowser.open_new_tab(f'http://localhost:{PORT}')
|
108 |
-
|
109 |
-
t.daemon = True; t.start()
|
110 |
|
111 |
auto_opentab_delay()
|
112 |
demo.title = "ChatGPT 学术优化"
|
|
|
10 |
|
11 |
# 如果WEB_PORT是-1, 则随机选取WEB端口
|
12 |
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
|
13 |
+
if not AUTHENTICATION: AUTHENTICATION = None
|
14 |
|
15 |
initial_prompt = "Serve me as a writing and programming assistant."
|
16 |
title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
|
|
|
105 |
def open():
|
106 |
time.sleep(2)
|
107 |
webbrowser.open_new_tab(f'http://localhost:{PORT}')
|
108 |
+
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
|
|
109 |
|
110 |
auto_opentab_delay()
|
111 |
demo.title = "ChatGPT 学术优化"
|
toolbox.py
CHANGED
@@ -226,13 +226,10 @@ def get_conf(*args):
|
|
226 |
except: r = getattr(importlib.import_module('config'), arg)
|
227 |
res.append(r)
|
228 |
# 在读取API_KEY时,检查一下是不是忘了改config
|
229 |
-
|
230 |
-
assert False, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
|
231 |
"(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
|
232 |
return res
|
233 |
|
234 |
def clear_line_break(txt):
|
235 |
-
|
236 |
-
|
237 |
-
txt = txt.replace(' ', ' ')
|
238 |
-
return txt
|
|
|
226 |
except: r = getattr(importlib.import_module('config'), arg)
|
227 |
res.append(r)
|
228 |
# 在读取API_KEY时,检查一下是不是忘了改config
|
229 |
+
assert arg != 'API_KEY' or len(r) == 51, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" \
|
|
|
230 |
"(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
|
231 |
return res
|
232 |
|
233 |
def clear_line_break(txt):
|
234 |
+
import re
|
235 |
+
return re.sub(r"\s+", " ", txt)
|
|
|
|