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: