mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
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
This commit is contained in:
parent
ae404d720d
commit
cb2776a549
1 changed files with 5 additions and 3 deletions
|
|
@ -37,9 +37,11 @@ def get_model_dir() -> str:
|
||||||
local_dir = os.path.dirname(os.path.abspath(__file__))
|
local_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
project_dir = os.path.dirname(os.path.dirname(local_dir))
|
project_dir = os.path.dirname(os.path.dirname(local_dir))
|
||||||
model_dir = os.path.join(project_dir, "models")
|
model_dir = os.path.join(project_dir, "models")
|
||||||
if os.path.exists(model_dir):
|
if not os.path.exists(model_dir):
|
||||||
|
os.mkdir(model_dir)
|
||||||
return model_dir
|
return model_dir
|
||||||
|
|
||||||
|
|
||||||
def get_models() -> dict[str, dict]:
|
def get_models() -> dict[str, dict]:
|
||||||
model_dir = get_model_dir()
|
model_dir = get_model_dir()
|
||||||
file_path = os.path.join(model_dir, "models.json")
|
file_path = os.path.join(model_dir, "models.json")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue