diff --git a/litellm/llms/sap/chat/transformation.py b/litellm/llms/sap/chat/transformation.py index 361e0297d23..90d985daecf 100755 --- a/litellm/llms/sap/chat/transformation.py +++ b/litellm/llms/sap/chat/transformation.py @@ -30,7 +30,7 @@ else: LiteLLMLoggingObj = Any from ..credentials import get_token_creator -from .models import ResponseFormatJSONSchema, ResponseFormat, OrchestrationRequest +from .models import ResponseFormatJSONSchema, ResponseFormat, OrchestrationRequest, ChatCompletionTool from .handler import ( GenAIHubOrchestrationError, AsyncSAPStreamIterator, @@ -220,12 +220,13 @@ class GenAIHubOrchestrationConfig(OpenAIGPTConfig): # Filter strict for GPT models only - SAP AI Core doesn't accept it as a model param # LangChain agents pass strict=true at top level, which fails for GPT models # Anthropic models accept strict, so preserve it for them - if model.startswith("gpt") and "strict" in params: + if model_name.startswith("gpt") and "strict" in params: params.pop("strict") model_version = params.pop("model_version", "latest") tools_ = params.pop("tools", []) + tools_ = [validate_dict(tool, ChatCompletionTool) for tool in tools_] tools = {"tools": tools_} if tools_ else {} response_format = params.pop("response_format", {}) diff --git a/tests/test_litellm/llms/sap/chat/test_sap_transformation.py b/tests/test_litellm/llms/sap/chat/test_sap_transformation.py index 5759f4a0e29..2af73a8d3d0 100644 --- a/tests/test_litellm/llms/sap/chat/test_sap_transformation.py +++ b/tests/test_litellm/llms/sap/chat/test_sap_transformation.py @@ -48,6 +48,11 @@ class TestSAPTransformationIntegration: prompt = result["config"]["modules"]["prompt_templating"]["prompt"] if "tools" in prompt: assert isinstance(prompt["tools"], list) + for tool in prompt["tools"]: + assert tool["function"]["parameters"]["type"] == "object", ( + "SAP API requires parameters.type == 'object'" + ) + assert "properties" in tool["function"]["parameters"] def test_transform_request_parameter_handling_robustness(self, mock_config): """Test transform_request method handles various parameter combinations correctly."""