Merge branch 'enhance-chataca' of https://github.com/fulyaec/chatgpt_academic into fulyaec-enhance-chataca

This commit is contained in:
Your Name 2023-03-31 19:45:23 +08:00
commit b655feedde
2 changed files with 5 additions and 9 deletions

View File

@ -10,7 +10,7 @@ proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = \
# 如果WEB_PORT是-1, 则随机选取WEB端口
PORT = find_free_port() if WEB_PORT <= 0 else WEB_PORT
AUTHENTICATION = None if AUTHENTICATION == [] else AUTHENTICATION
if not AUTHENTICATION: AUTHENTICATION = None
initial_prompt = "Serve me as a writing and programming assistant."
title_html = """<h1 align="center">ChatGPT 学术优化</h1>"""
@ -105,8 +105,7 @@ def auto_opentab_delay():
def open():
time.sleep(2)
webbrowser.open_new_tab(f'http://localhost:{PORT}')
t = threading.Thread(target=open)
t.daemon = True; t.start()
threading.Thread(target=open, name="open-browser", daemon=True).start()
auto_opentab_delay()
demo.title = "ChatGPT 学术优化"

View File

@ -237,13 +237,10 @@ def get_conf(*args):
except: r = getattr(importlib.import_module('config'), arg)
res.append(r)
# 在读取API_KEY时检查一下是不是忘了改config
if arg=='API_KEY' and len(r) != 51:
assert False, "正确的API_KEY密钥是51位请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
assert arg != 'API_KEY' or len(r) == 51, "正确的API_KEY密钥是51位请在config文件中修改API密钥, 添加海外代理之后再运行。" \
"如果您刚更新过代码请确保旧版config_private文件中没有遗留任何新增键值"
return res
def clear_line_break(txt):
txt = txt.replace('\n', ' ')
txt = txt.replace(' ', ' ')
txt = txt.replace(' ', ' ')
return txt
import re
return re.sub(r"\s+", " ", txt)