mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-22 14:24:22 +00:00
fix(factory.py): don't pass cache control if not set
bedrock invoke does not support this
This commit is contained in:
@@ -1254,7 +1254,6 @@ def convert_function_to_anthropic_tool_invoke(
|
||||
id=str(uuid.uuid4()),
|
||||
name=_name,
|
||||
input=json.loads(_arguments) if _arguments else {},
|
||||
cache_control=None,
|
||||
)
|
||||
]
|
||||
return anthropic_tool_invoke
|
||||
@@ -1309,14 +1308,16 @@ def convert_to_anthropic_tool_invoke(
|
||||
|
||||
_anthropic_tool_use_param = AnthropicMessagesToolUseParam(
|
||||
type="tool_use",
|
||||
id=get_attribute_or_key(tool, "id"),
|
||||
name=get_attribute_or_key(get_attribute_or_key(tool, "function"), "name"),
|
||||
id=cast(str, get_attribute_or_key(tool, "id")),
|
||||
name=cast(
|
||||
str,
|
||||
get_attribute_or_key(get_attribute_or_key(tool, "function"), "name"),
|
||||
),
|
||||
input=json.loads(
|
||||
get_attribute_or_key(
|
||||
get_attribute_or_key(tool, "function"), "arguments"
|
||||
)
|
||||
),
|
||||
cache_control=None,
|
||||
)
|
||||
|
||||
_content_element = add_cache_control_to_content(
|
||||
|
||||
@@ -52,7 +52,7 @@ class AnthropicMessagesTextParam(TypedDict, total=False):
|
||||
cache_control: Optional[Union[dict, ChatCompletionCachedContent]]
|
||||
|
||||
|
||||
class AnthropicMessagesToolUseParam(TypedDict):
|
||||
class AnthropicMessagesToolUseParam(TypedDict, total=False):
|
||||
type: Required[Literal["tool_use"]]
|
||||
id: str
|
||||
name: str
|
||||
|
||||
@@ -345,7 +345,7 @@ def test_anthropic_cache_controls_tool_calls_pt():
|
||||
assert translated_messages[1]["role"] == "assistant"
|
||||
for content_item in translated_messages[1]["content"]:
|
||||
if content_item["type"] == "tool_use":
|
||||
assert content_item["cache_control"] is None
|
||||
assert "cache_control" not in content_item
|
||||
assert content_item["name"] == "get_weather"
|
||||
|
||||
assert translated_messages[2]["role"] == "user"
|
||||
|
||||
Reference in New Issue
Block a user