From e8ffebc006402023aa046478e7bc7c380257ba85 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Fri, 11 Apr 2025 15:01:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=E4=B8=AD=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E7=A9=BA=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/provider/entities.py | 2 +- astrbot/core/provider/sources/openai_source.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/entities.py b/astrbot/core/provider/entities.py index 99824fd0e..ffa20029e 100644 --- a/astrbot/core/provider/entities.py +++ b/astrbot/core/provider/entities.py @@ -155,7 +155,7 @@ class ProviderRequest: if self.image_urls: user_content = { "role": "user", - "content": [{"type": "text", "text": self.prompt}], + "content": [{"type": "text", "text": self.prompt if self.prompt else "[图片]"}], } for image_url in self.image_urls: if image_url.startswith("http"): diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 8023d18d1..e945dea3e 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -497,7 +497,7 @@ class ProviderOpenAIOfficial(Provider): async def assemble_context(self, text: str, image_urls: List[str] = None) -> dict: """组装成符合 OpenAI 格式的 role 为 user 的消息段""" if image_urls: - user_content = {"role": "user", "content": [{"type": "text", "text": text}]} + user_content = {"role": "user", "content": [{"type": "text", "text": text if text else "[图片]"}]} for image_url in image_urls: if image_url.startswith("http"): image_path = await download_image_by_url(image_url)