fix: 修复消息处理流程中可能出现的空消息

This commit is contained in:
Raven95676
2025-04-11 15:01:20 +08:00
parent 2ca95eaa9f
commit e8ffebc006
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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"):
@@ -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)