diff --git a/astrbot/core/core_lifecycle.py b/astrbot/core/core_lifecycle.py index dd49c6957..8f9e9b3d7 100644 --- a/astrbot/core/core_lifecycle.py +++ b/astrbot/core/core_lifecycle.py @@ -25,9 +25,8 @@ class AstrBotCoreLifecycle: self.astrbot_config = astrbot_config self.db = db - if self.astrbot_config['http_proxy']: - os.environ['https_proxy'] = self.astrbot_config['http_proxy'] - os.environ['http_proxy'] = self.astrbot_config['http_proxy'] + os.environ['https_proxy'] = self.astrbot_config['http_proxy'] + os.environ['http_proxy'] = self.astrbot_config['http_proxy'] async def initialize(self): logger.info("AstrBot v"+ VERSION) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index edea41946..5f25abeb7 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -1,6 +1,6 @@ import base64 import json -import re +import os from openai import AsyncOpenAI, NOT_GIVEN from openai.types.chat.chat_completion import ChatCompletion @@ -195,6 +195,11 @@ class ProviderOpenAIOfficial(Provider): if 'tool' in str(e).lower() and 'support' in str(e).lower(): logger.error(f"疑似该模型不支持函数调用工具调用。请输入 /tool off_all") + if 'Connection error.' in str(e): + proxy = os.environ.get("http_proxy", None) + if proxy: + logger.error(f"可能为代理原因,请检查代理是否正常。当前代理: {proxy}") + raise e if kwargs.get("persist", True) and llm_response: