Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions litellm/litellm_core_utils/prompt_templates/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,9 @@ def convert_to_anthropic_tool_result(
if cache_control_value is not None:
text_content["cache_control"] = cache_control_value
anthropic_content_list.append(text_content)
elif content["type"] == "document":
# Do NOT strip type for Anthropic; it is Required
anthropic_content_list.append(content)
elif content["type"] == "image_url":
format = (
content["image_url"].get("format")
Expand Down Expand Up @@ -3969,6 +3972,11 @@ def _convert_to_bedrock_tool_call_result(
tool_result_content_blocks.append(
BedrockToolResultContentBlock(text=content["text"])
)
elif content["type"] == "document":
doc_content = {k: v for k, v in content.items() if k != "type"}
tool_result_content_blocks.append(
BedrockToolResultContentBlock(document=doc_content)
)
elif content["type"] == "image_url":
format: Optional[str] = None
if isinstance(content["image_url"], dict):
Expand Down Expand Up @@ -4423,6 +4431,10 @@ async def _bedrock_converse_messages_pt_async( # noqa: PLR0915
guardContent={"text": {"text": element["text"]}}
)
_parts.append(_part)
elif element["type"] == "document":
doc_content = {k: v for k, v in element.items() if k != "type"}
_part = BedrockContentBlock(document=doc_content)
_parts.append(_part)
elif element["type"] == "image_url":
format: Optional[str] = None
if isinstance(element["image_url"], dict):
Expand Down Expand Up @@ -4592,6 +4604,10 @@ async def _bedrock_converse_messages_pt_async( # noqa: PLR0915
text=element["text"]
)
assistants_parts.append(assistants_part)
elif element["type"] == "document":
doc_content = {k: v for k, v in element.items() if k != "type"}
assistants_part = BedrockContentBlock(document=doc_content)
assistants_parts.append(assistants_part)
elif element["type"] == "image_url":
if isinstance(element["image_url"], dict):
image_url = element["image_url"]["url"]
Expand Down
Loading