(sap) fix after bot review

This commit is contained in:
Vasilisa Parshikova 2026-03-23 19:45:28 +04:00 committed by Sameer Kankute
parent 43d84b1334
commit 9415f5864b
No known key found for this signature in database
2 changed files with 8 additions and 2 deletions

View file

@ -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", {})

View file

@ -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."""