Merge branch 'dev' of github.com:binary-husky/chatgpt_academic into dev

This commit is contained in:
Your Name 2023-03-31 20:04:11 +08:00
commit a3952be1cb

View File

@ -1,6 +1,7 @@
import markdown, mdtex2html, threading, importlib, traceback, importlib, inspect
from show_math import convert as convert_math
from functools import wraps
import re
def predict_no_ui_but_counting_down(i_say, i_say_show_user, chatbot, top_p, temperature, history=[], sys_prompt=''):
"""
@ -237,9 +238,14 @@ 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密钥, 添加海外代理之后再运行。" + \
"如果您刚更新过代码请确保旧版config_private文件中没有遗留任何新增键值"
if arg=='API_KEY':
# 正确的 API_KEY 是 "sk-" + 48 位大小写字母数字的组合
API_MATCH = re.match(r"sk-[a-zA-Z0-9]{48}$", r)
if API_MATCH:
print("您的 API_KEY 是: ", r, "\nAPI_KEY 导入成功")
else:
assert False, "正确的 API_KEY 是 'sk-' + '48 位大小写字母数字' 的组合请在config文件中修改API密钥, 添加海外代理之后再运行。" + \
"如果您刚更新过代码请确保旧版config_private文件中没有遗留任何新增键值"
return res
def clear_line_break(txt):