yym68686 commited on
Commit
36471d2
·
1 Parent(s): b54a508

Fix the bug where an error is reported when loading the configuration file without api.yaml.

Browse files
Files changed (1) hide show
  1. main.py +5 -5
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("配置文件 'config.yaml' 未找到。请确保文件存在于正确的位置。")
55
- return []
56
  except yaml.YAMLError:
57
- print("配置文件 'config.yaml' 格式不正确。请检查YAML格式。")
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