This commit is contained in:
kawayiYokami
2025-12-25 13:33:40 +08:00
parent c5a2827def
commit 9449ff668b
4 changed files with 25 additions and 7 deletions
@@ -448,8 +448,14 @@ class ProviderAnthropic(Provider):
},
)
# 如果只有一个文本且没有图片,返回简单格式以保持向后兼容
if len(content) == 1 and content[0]["type"] == "text":
# 如果只有文本且没有额外内容块和图片,返回简单格式以保持向后兼容
if (
text
and not extra_content_blocks
and not image_urls
and len(content) == 1
and content[0]["type"] == "text"
):
return {"role": "user", "content": content[0]["text"]}
# 否则返回多模态格式
@@ -839,8 +839,14 @@ class ProviderGoogleGenAI(Provider):
},
)
# 如果只有文本且没有额外内容块,返回简单格式以保持向后兼容
if len(content_blocks) == 1 and content_blocks[0]["type"] == "text":
# 如果只有文本且没有额外内容块和图片,返回简单格式以保持向后兼容
if (
text
and not extra_content_blocks
and not image_urls
and len(content_blocks) == 1
and content_blocks[0]["type"] == "text"
):
return {"role": "user", "content": content_blocks[0]["text"]}
# 否则返回多模态格式
@@ -662,8 +662,14 @@ class ProviderOpenAIOfficial(Provider):
},
)
# 如果只有文本且没有额外内容块,返回简单格式以保持向后兼容
if len(content_blocks) == 1 and content_blocks[0]["type"] == "text":
# 如果只有文本且没有额外内容块和图片,返回简单格式以保持向后兼容
if (
text
and not extra_content_blocks
and not image_urls
and len(content_blocks) == 1
and content_blocks[0]["type"] == "text"
):
return {"role": "user", "content": content_blocks[0]["text"]}
# 否则返回多模态格式
+1 -1
View File
@@ -242,6 +242,6 @@ class ProcessLLMRequest:
# 统一包裹所有系统提醒
if system_parts:
system_content = (
"<system_reminder>" + "".join(system_parts) + "</system_reminder>"
"<system_reminder>" + "\n".join(system_parts) + "</system_reminder>"
)
req.extra_content_blocks.append({"type": "text", "text": system_content})