From ce2d7bf9e683dbe159cae0dc24f293d74889a8d5 Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Tue, 4 Mar 2025 21:19:50 -0800 Subject: [PATCH] =?UTF-8?q?fix(common=5Futils.py):=20handle=20$id=20in=20r?= =?UTF-8?q?esponse=20schema=20when=20calling=20vert=E2=80=A6=20(#8991)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(common_utils.py): handle $id in response schema when calling vertex ai Fixes issue where `$id` present in response_schema was not accepted by vertex ai * test(test_vertex.py): add unit test to ensure $id stripped out of vertex schema --- litellm/llms/vertex_ai/common_utils.py | 3 +++ litellm/proxy/proxy_server.py | 3 +++ tests/llm_translation/test_vertex.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py index a412a1f0db..f7149c349a 100644 --- a/litellm/llms/vertex_ai/common_utils.py +++ b/litellm/llms/vertex_ai/common_utils.py @@ -170,6 +170,9 @@ def _build_vertex_schema(parameters: dict): strip_field( parameters, field_name="$schema" ) # 5. Remove $schema - json schema value, not supported by OpenAPI - causes vertex errors. + strip_field( + parameters, field_name="$id" + ) # 6. Remove id - json schema value, not supported by OpenAPI - causes vertex errors. return parameters diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 19d0ebe9ea..28aceb7519 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7059,6 +7059,9 @@ async def delete_model(model_info: ModelInfoDelete): ) except Exception as e: + verbose_proxy_logger.exception( + f"Failed to delete model. Due to error - {str(e)}" + ) if isinstance(e, HTTPException): raise ProxyException( message=getattr(e, "detail", f"Authentication Error({str(e)})"), diff --git a/tests/llm_translation/test_vertex.py b/tests/llm_translation/test_vertex.py index db867e5202..08ea45cb20 100644 --- a/tests/llm_translation/test_vertex.py +++ b/tests/llm_translation/test_vertex.py @@ -108,6 +108,7 @@ def test_build_vertex_schema(): schema = { "type": "object", + "$id": "my-special-id", "properties": { "recipes": { "type": "array", @@ -126,6 +127,7 @@ def test_build_vertex_schema(): assert new_schema["type"] == schema["type"] assert new_schema["properties"] == schema["properties"] assert "required" in new_schema and new_schema["required"] == schema["required"] + assert "$id" not in new_schema @pytest.mark.parametrize(