From 424b970469c2533a46aaf2415b5b20bae8e999b4 Mon Sep 17 00:00:00 2001 From: Rock Chin <1010553892@qq.com> Date: Sun, 5 Mar 2023 11:58:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=86=E4=BE=9D=E8=B5=96=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=9B=B4=E6=94=B9=E5=88=B0main=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/main.py b/main.py index c4ff6abf..e52a1ce1 100644 --- a/main.py +++ b/main.py @@ -107,11 +107,18 @@ def reset_logging(): def main(first_time_init=False): global known_exception_caught - # 检查并创建plugins、prompts目录 - check_path = ["plugins", "prompts"] - for path in check_path: - if not os.path.exists(path): - os.mkdir(path) + import config + # 更新openai库到最新版本 + if not hasattr(config, 'upgrade_dependencies') or config.upgrade_dependencies: + print("正在更新依赖库,请等待...") + if not hasattr(config, 'upgrade_dependencies'): + print("这个操作不是必须的,如果不想更新,请在config.py中添加upgrade_dependencies=False") + else: + print("这个操作不是必须的,如果不想更新,请在config.py中将upgrade_dependencies设置为False") + try: + ensure_dependencies() + except Exception as e: + print("更新openai库失败:{}, 请忽略或自行更新".format(e)) known_exception_caught = False try: @@ -322,6 +329,12 @@ if __name__ == '__main__': if not os.path.exists("temp/"): os.mkdir("temp/") + # 检查并创建plugins、prompts目录 + check_path = ["plugins", "prompts"] + for path in check_path: + if not os.path.exists(path): + os.mkdir(path) + if len(sys.argv) > 1 and sys.argv[1] == 'init_db': init_db() sys.exit(0) @@ -347,17 +360,4 @@ if __name__ == '__main__': # pkg.utils.configmgr.set_config_and_reload("quote_origin", False) requests.packages.urllib3.disable_warnings(InsecureRequestWarning) - import config - # 更新openai库到最新版本 - if not hasattr(config, 'upgrade_dependencies') or config.upgrade_dependencies: - print("正在更新依赖库,请等待...") - if not hasattr(config, 'upgrade_dependencies'): - print("这个操作不是必须的,如果不想更新,请在config.py中添加upgrade_dependencies=False") - else: - print("这个操作不是必须的,如果不想更新,请在config.py中将upgrade_dependencies设置为False") - try: - ensure_dependencies() - except Exception as e: - print("更新openai库失败:{}, 请忽略或自行更新".format(e)) - main(True)