Fix the bug where an error is reported when loading the configuration file without api.yaml.
Browse files
main.py
CHANGED
@@ -35,7 +35,7 @@ security = HTTPBearer()
|
|
35 |
# 读取YAML配置文件
|
36 |
def load_config():
|
37 |
try:
|
38 |
-
with open('api.yaml', 'r') as f:
|
39 |
conf = yaml.safe_load(f)
|
40 |
for index, provider in enumerate(conf['providers']):
|
41 |
model_dict = {}
|
@@ -51,11 +51,11 @@ def load_config():
|
|
51 |
# print(json.dumps(conf, indent=4, ensure_ascii=False))
|
52 |
return conf, api_keys_db, api_list
|
53 |
except FileNotFoundError:
|
54 |
-
print("配置文件 '
|
55 |
-
return []
|
56 |
except yaml.YAMLError:
|
57 |
-
print("配置文件 '
|
58 |
-
return []
|
59 |
|
60 |
config, api_keys_db, api_list = load_config()
|
61 |
|
|
|
35 |
# 读取YAML配置文件
|
36 |
def load_config():
|
37 |
try:
|
38 |
+
with open('./api.yaml', 'r') as f:
|
39 |
conf = yaml.safe_load(f)
|
40 |
for index, provider in enumerate(conf['providers']):
|
41 |
model_dict = {}
|
|
|
51 |
# print(json.dumps(conf, indent=4, ensure_ascii=False))
|
52 |
return conf, api_keys_db, api_list
|
53 |
except FileNotFoundError:
|
54 |
+
print("配置文件 'api.yaml' 未找到。请确保文件存在于正确的位置。")
|
55 |
+
return [], [], []
|
56 |
except yaml.YAMLError:
|
57 |
+
print("配置文件 'api.yaml' 格式不正确。请检查 YAML 格式。")
|
58 |
+
return [], [], []
|
59 |
|
60 |
config, api_keys_db, api_list = load_config()
|
61 |
|