mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
fix: use toolConfig instead of tool_choice in cached content request body
Per Google AI API docs, CachedContent schema uses "toolConfig" not "tool_choice". Also only set the field when tool_choice is not None, matching the pattern used in gemini transformation.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cee00d61e5
commit
e7cece2dc3
2 changed files with 10 additions and 10 deletions
|
|
@ -402,7 +402,8 @@ class ContextCachingEndpoints(VertexBase):
|
|||
)
|
||||
|
||||
cached_content_request_body["tools"] = tools
|
||||
cached_content_request_body["tool_choice"] = tool_choice
|
||||
if tool_choice is not None:
|
||||
cached_content_request_body["toolConfig"] = tool_choice
|
||||
|
||||
## LOGGING
|
||||
logging_obj.pre_call(
|
||||
|
|
@ -550,7 +551,8 @@ class ContextCachingEndpoints(VertexBase):
|
|||
)
|
||||
|
||||
cached_content_request_body["tools"] = tools
|
||||
cached_content_request_body["tool_choice"] = tool_choice
|
||||
if tool_choice is not None:
|
||||
cached_content_request_body["toolConfig"] = tool_choice
|
||||
|
||||
## LOGGING
|
||||
logging_obj.pre_call(
|
||||
|
|
|
|||
|
|
@ -280,8 +280,7 @@ class TestContextCachingEndpoints:
|
|||
call_args = self.mock_client.post.call_args
|
||||
assert "tools" in call_args.kwargs["json"]
|
||||
assert call_args.kwargs["json"]["tools"] == self.sample_tools
|
||||
assert "tool_choice" in call_args.kwargs["json"]
|
||||
assert call_args.kwargs["json"]["tool_choice"] is None
|
||||
assert "toolConfig" not in call_args.kwargs["json"]
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"custom_llm_provider", ["gemini", "vertex_ai", "vertex_ai_beta"]
|
||||
|
|
@ -560,8 +559,7 @@ class TestContextCachingEndpoints:
|
|||
call_args = self.mock_async_client.post.call_args
|
||||
assert "tools" in call_args.kwargs["json"]
|
||||
assert call_args.kwargs["json"]["tools"] == self.sample_tools
|
||||
assert "tool_choice" in call_args.kwargs["json"]
|
||||
assert call_args.kwargs["json"]["tool_choice"] is None
|
||||
assert "toolConfig" not in call_args.kwargs["json"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -983,9 +981,9 @@ class TestContextCachingEndpoints:
|
|||
model="gemini-1.5-pro",
|
||||
)
|
||||
|
||||
# tool_choice should be in the request body
|
||||
# tool_choice should be mapped to toolConfig in the request body
|
||||
call_args = self.mock_client.post.call_args
|
||||
assert call_args.kwargs["json"]["tool_choice"] == tool_choice_value
|
||||
assert call_args.kwargs["json"]["toolConfig"] == tool_choice_value
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -1065,9 +1063,9 @@ class TestContextCachingEndpoints:
|
|||
model="gemini-1.5-pro",
|
||||
)
|
||||
|
||||
# tool_choice should be in the request body
|
||||
# tool_choice should be mapped to toolConfig in the request body
|
||||
call_args = self.mock_async_client.post.call_args
|
||||
assert call_args.kwargs["json"]["tool_choice"] == tool_choice_value
|
||||
assert call_args.kwargs["json"]["toolConfig"] == tool_choice_value
|
||||
|
||||
|
||||
class TestCheckCachePagination:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue