3v324v23 commited on
Commit
b655fee
2 Parent(s): 739cec9 cec4480

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

Browse files
Files changed (2) hide show
  1. main.py +2 -3
  2. 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
- AUTHENTICATION = None if AUTHENTICATION == [] else AUTHENTICATION
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
- t = threading.Thread(target=open)
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
@@ -237,13 +237,10 @@ def get_conf(*args):
237
  except: r = getattr(importlib.import_module('config'), arg)
238
  res.append(r)
239
  # 在读取API_KEY时,检查一下是不是忘了改config
240
- if arg=='API_KEY' and len(r) != 51:
241
- assert False, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
242
  "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
243
  return res
244
 
245
  def clear_line_break(txt):
246
- txt = txt.replace('\n', ' ')
247
- txt = txt.replace(' ', ' ')
248
- txt = txt.replace(' ', ' ')
249
- return txt
 
237
  except: r = getattr(importlib.import_module('config'), arg)
238
  res.append(r)
239
  # 在读取API_KEY时,检查一下是不是忘了改config
240
+ assert arg != 'API_KEY' or len(r) == 51, "正确的API_KEY密钥是51位,请在config文件中修改API密钥, 添加海外代理之后再运行。" \
 
241
  "(如果您刚更新过代码,请确保旧版config_private文件中没有遗留任何新增键值)"
242
  return res
243
 
244
  def clear_line_break(txt):
245
+ import re
246
+ return re.sub(r"\s+", " ", txt)