XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Update models.py to create models directory when its not present

It will create a models directory in current folder if it can't find the directory due to previous way where it tries to return models directory where its not present which in turns returns None causing os.path to fail Fix #2030

cb2776a5
Zed <33319711+Zedai00@users.noreply.github.com>
提交于

代码差异

1 个文件 +5 -3
Modified g4f/locals/models.py +5 -3
@@ -37,8 +37,10 @@ def get_model_dir() -> str:
37 37 local_dir = os.path.dirname(os.path.abspath(__file__))
38 38 project_dir = os.path.dirname(os.path.dirname(local_dir))
39 39 model_dir = os.path.join(project_dir, "models")
40 if os.path.exists(model_dir):
41 return model_dir
40 if not os.path.exists(model_dir):
41 os.mkdir(model_dir)
42 return model_dir
43
42 44
43 45 def get_models() -> dict[str, dict]:
44 46 model_dir = get_model_dir()
@@ -48,4 +50,4 @@ def get_models() -> dict[str, dict]:
48 50 else:
49 51 models = load_models()
50 52 save_models(file_path, models)
51 return models
53 return models