From 8eb81b520203954963cd0863287ac58f4bd35956 Mon Sep 17 00:00:00 2001 From: Vasilisa Parshikova Date: Mon, 23 Mar 2026 17:57:15 +0400 Subject: [PATCH] (sap) fix after bot review --- litellm/llms/sap/chat/models.py | 7 ++++++- .../test_litellm/llms/sap/chat/test_sap_tool_parameters.py | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/litellm/llms/sap/chat/models.py b/litellm/llms/sap/chat/models.py index c83e6631bbd..4cb22adfddb 100644 --- a/litellm/llms/sap/chat/models.py +++ b/litellm/llms/sap/chat/models.py @@ -1,8 +1,9 @@ -from typing import Union, Literal, Optional +from typing import Union, Literal, Optional, Any, Self from enum import Enum import warnings from pydantic import BaseModel, Field, field_validator, model_validator +from pydantic.config import ExtraValues def validate_different_content(v: Union[str, dict, list]) -> str: @@ -67,6 +68,10 @@ class ChatCompletionTool(BaseModel): type_: Literal["function"] = Field(default="function", alias="type") function: FunctionTool + def model_dump(self, **kwargs) -> Self: + kwargs["exclude_unset"] = False + return super().model_dump(**kwargs) + class MessageToolCall(BaseModel): id: str diff --git a/tests/test_litellm/llms/sap/chat/test_sap_tool_parameters.py b/tests/test_litellm/llms/sap/chat/test_sap_tool_parameters.py index e4e639d03c9..a5a3fa40d98 100644 --- a/tests/test_litellm/llms/sap/chat/test_sap_tool_parameters.py +++ b/tests/test_litellm/llms/sap/chat/test_sap_tool_parameters.py @@ -128,7 +128,9 @@ class TestToolTransformationIntegration: validated_tool = validate_dict(openai_tool, ChatCompletionTool) - assert validated_tool["function"]["name"] == "web_search" + # After validation, parameters should have type='object' + assert validated_tool["function"]["parameters"]["type"] == "object" + assert "properties" in validated_tool["function"]["parameters"] def test_should_transform_tool_with_existing_parameters(self):