Skip to content

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]

Rebase 3

Nicholas Grabar06a45706b295
diff --git a/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
index 9412cc6d812..77fa0661977 100644
--- a/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
+++ b/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
@@ -153,3 +153,71 @@ async def test_get_supports_system_message():
model="random-model-name", custom_llm_provider="vertex_ai"
)
assert result == False
+def test_basic_anyof_conversion():
+ """Test basic conversion of anyOf with 'null'."""
+ schema = {
+ "type": "object",
+ "properties": {
+ "example": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "null"}
+ ]
+ }
+ }
+ }
+
+ convert_anyof_null_to_nullable(schema)
+
+ expected = {
+ "type": "object",
+ "properties": {
+ "example": {
+ "anyOf": [
+ {"type": "string", "nullable": True}
+ ]
+ }
+ }
+ }
+ assert schema == expected
+
+
+def test_nested_anyof_conversion():
+ """Test nested conversion with 'anyOf' inside properties."""
+ schema = {
+ "type": "object",
+ "properties": {
+ "outer": {
+ "type": "object",
+ "properties": {
+ "inner": {
+ "anyOf": [
+ {"type": "array", "items": {"type": "string"}},
+ {"type": "string"},
+ {"type": "null"}
+ ]
+ }
+ }
+ }
+ }
+ }
+
+ convert_anyof_null_to_nullable(schema)
+
+ expected = {
+ "type": "object",
+ "properties": {
+ "outer": {
+ "type": "object",
+ "properties": {
+ "inner": {
+ "anyOf": [
+ {"type": "array", "items": {"type": "string"}, "nullable": True},
+ {"type": "string", "nullable": True}
+ ]
+ }
+ }
+ }
+ }
+ }
+ assert schema == expected