diff --git a/app.py b/app.py index 5d5fa59..3ed421b 100644 --- a/app.py +++ b/app.py @@ -813,20 +813,35 @@ def update_api_keys(): def load_api_keys(): """从配置文件加载API密钥""" try: - if os.path.exists(API_KEYS_FILE): - with open(API_KEYS_FILE, 'r', encoding='utf-8') as f: - return json.load(f) - else: - # 如果文件不存在,创建默认配置 - default_keys = { + default_keys = { "AnthropicApiKey": "", "OpenaiApiKey": "", "DeepseekApiKey": "", "AlibabaApiKey": "", "MathpixAppId": "", "MathpixAppKey": "", - "GoogleApiKey": "" - } + "GoogleApiKey": "", + "DoubaoApiKey": "", + "BaiduApiKey": "", + "BaiduSecretKey": "" + } + if os.path.exists(API_KEYS_FILE): + with open(API_KEYS_FILE, 'r', encoding='utf-8') as f: + api_keys = json.load(f) + + # 确保新增的密钥占位符能自动补充 + missing_key_added = False + for key, default_value in default_keys.items(): + if key not in api_keys: + api_keys[key] = default_value + missing_key_added = True + + if missing_key_added: + save_api_keys(api_keys) + + return api_keys + else: + # 如果文件不存在,创建默认配置 save_api_keys(default_keys) return default_keys except Exception as e: diff --git a/config/proxy_api.json b/config/proxy_api.json index 9ce4843..2f10cd1 100644 --- a/config/proxy_api.json +++ b/config/proxy_api.json @@ -1,11 +1,11 @@ { "apis": { "alibaba": "", - "anthropic": "https://api.nuwaapi.com/v1", + "anthropic": "", "deepseek": "", "doubao": "", - "google": "https://api.nuwaapi.com/v1", - "openai": "https://api.nuwaapi.com/v1" + "google": "", + "openai": "" }, "enabled": true } \ No newline at end of file