From 6858b8c555d7f209830f22ca64d65b2f9d53ff6a Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Fri, 7 Feb 2025 23:57:11 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=BD=93=E5=9B=BE=E7=89=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=BA=E7=A9=BA=E6=97=B6=E4=B8=8D=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=20#379?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/sources/gemini_source.py | 3 +++ astrbot/core/provider/sources/openai_source.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 3eb5a5dc9..6ff93bcb7 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -231,6 +231,9 @@ class ProviderGoogleGenAI(Provider): image_data = await self.encode_image_bs64(image_path) else: image_data = await self.encode_image_bs64(image_url) + if not image_data: + logger.warning(f"图片 {image_url} 得到的结果为空,将忽略。") + continue user_content["content"].append({"type": "image_url", "image_url": {"url": image_data}}) return user_content else: diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 0f0d5359d..cabd40849 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -243,6 +243,9 @@ class ProviderOpenAIOfficial(Provider): image_data = await self.encode_image_bs64(image_path) else: image_data = await self.encode_image_bs64(image_url) + if not image_data: + logger.warning(f"图片 {image_url} 得到的结果为空,将忽略。") + continue user_content["content"].append({"type": "image_url", "image_url": {"url": image_data}}) return user_content else: