FIX
This commit is contained in:
@@ -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"]}
|
||||
|
||||
# 否则返回多模态格式
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user