The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Fix anyof corner cases for BerriAI/litellm#11164
Eric Chen0a7c9a7231b3
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.pyindex cceac0ea794..41b2b030740 100644--- a/litellm/llms/vertex_ai/common_utils.py+++ b/litellm/llms/vertex_ai/common_utils.py@@ -238,9 +238,7 @@ def _filter_anyof_fields(schema_dict: Dict[str, Any]) -> Dict[str, Any]:item["title"] = titleif description:item["description"] = description- return {"anyOf": any_of}- else:- return schema_dict+ return {"anyOf": any_of}return schema_dictdiff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.pyindex 21395f59e5c..1a8780c6c16 100644--- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py+++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py@@ -495,6 +495,36 @@ def test_vertex_ai_map_tool_with_anyof():"anyOf": [{"type": "string", "nullable": True, "title": "Base Branch"}]}, f"Expected only anyOf field and its contents to be kept, but got {tools[0]['function_declarations'][0]['parameters']['properties']['base_branch']}"+ new_value = [+ {+ "type": "function",+ "function": {+ "name": "git_create_branch",+ "description": "Creates a new branch from an optional base branch",+ "parameters": {+ "type": "object",+ "properties": {+ "repo_path": {"title": "Repo Path", "type": "string"},+ "branch_name": {"title": "Branch Name", "type": "string"},+ "base_branch": {+ "anyOf": [{"type": "string"}, {"type": "null"}],+ "default": None,+ },+ },+ "required": ["repo_path", "branch_name"],+ "title": "GitCreateBranch",+ },+ },+ }+ ]+ new_tools = v._map_function(value=new_value)++ assert new_tools[0]["function_declarations"][0]["parameters"]["properties"][+ "base_branch"+ ] == {+ "anyOf": [{"type": "string", "nullable": True}]+ }, f"Expected only anyOf field and its contents to be kept, but got {new_tools[0]['function_declarations'][0]['parameters']['properties']['base_branch']}"+def test_vertex_ai_streaming_usage_calculation():"""