fix: 修复HTTP代理删除后不生效 #319

This commit is contained in:
Soulter
2025-02-03 14:11:50 +08:00
parent 541ba64032
commit 68ad48ff55
2 changed files with 8 additions and 4 deletions
+2 -3
View File
@@ -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)
@@ -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: