mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
reuse map_openai_params from openai provider
This commit is contained in:
parent
fc0f4b4c68
commit
adf5c9cd0d
2 changed files with 0 additions and 80 deletions
|
|
@ -192,21 +192,6 @@ class GenAIHubOrchestrationConfig(OpenAIGPTConfig):
|
|||
def get_config(cls):
|
||||
return super().get_config()
|
||||
|
||||
def map_openai_params(
|
||||
self,
|
||||
non_default_params: dict, # mutable-ok: mirrors base class signature
|
||||
optional_params: dict, # mutable-ok: mirrors base class signature
|
||||
model: str,
|
||||
drop_params: bool,
|
||||
) -> dict: # mutable-ok: mirrors base class signature
|
||||
supported = self.get_supported_openai_params(model)
|
||||
optional_params.update(
|
||||
{ # mutable-ok: comprehension passed directly to update, never stored separately
|
||||
p: v for p, v in non_default_params.items() if p in supported
|
||||
}
|
||||
)
|
||||
return optional_params
|
||||
|
||||
def get_supported_openai_params(self, model):
|
||||
params: Final = [
|
||||
"frequency_penalty",
|
||||
|
|
|
|||
|
|
@ -641,71 +641,6 @@ class TestSAPTransformationIntegration:
|
|||
== "sap_document_translation"
|
||||
)
|
||||
|
||||
|
||||
class TestMapOpenaiParams:
|
||||
"""Unit tests for GenAIHubOrchestrationConfig.map_openai_params."""
|
||||
|
||||
@pytest.fixture
|
||||
def config(self):
|
||||
from litellm.llms.sap.chat.transformation import GenAIHubOrchestrationConfig
|
||||
|
||||
c = GenAIHubOrchestrationConfig.__new__(GenAIHubOrchestrationConfig)
|
||||
return c
|
||||
|
||||
def test_supported_params_pass_through(self, config):
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"temperature": 0.7, "reasoning_effort": "high", "thinking": {"type": "enabled", "budget_tokens": 2000}},
|
||||
optional_params={},
|
||||
model="anthropic--claude-4-sonnet",
|
||||
drop_params=False,
|
||||
)
|
||||
assert result["temperature"] == 0.7
|
||||
assert result["reasoning_effort"] == "high"
|
||||
assert result["thinking"] == {"type": "enabled", "budget_tokens": 2000}
|
||||
|
||||
def test_unsupported_params_are_excluded(self, config):
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"store": True, "service_tier": "auto", "modalities": ["text"]},
|
||||
optional_params={},
|
||||
model="gpt-4o",
|
||||
drop_params=False,
|
||||
)
|
||||
assert result == {}
|
||||
|
||||
def test_reasoning_effort_passes_for_all_sap_model_names(self, config):
|
||||
# SAP model names don't match OpenAI's o-series/gpt-5 patterns;
|
||||
# the override ensures they are not silently dropped by the inherited dispatcher.
|
||||
for model in ("anthropic--claude-4-sonnet", "gpt-4o", "gemini-2.5-flash", "gpt-5", "amazon--titan"):
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"reasoning_effort": "low"},
|
||||
optional_params={},
|
||||
model=model,
|
||||
drop_params=False,
|
||||
)
|
||||
assert "reasoning_effort" in result, f"reasoning_effort dropped for {model}"
|
||||
|
||||
def test_thinking_passes_for_all_sap_model_names(self, config):
|
||||
thinking = {"type": "enabled", "budget_tokens": 2000}
|
||||
for model in ("anthropic--claude-4-sonnet", "gpt-4o", "gemini-2.5-flash"):
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"thinking": thinking},
|
||||
optional_params={},
|
||||
model=model,
|
||||
drop_params=False,
|
||||
)
|
||||
assert "thinking" in result, f"thinking dropped for {model}"
|
||||
|
||||
def test_existing_optional_params_are_preserved(self, config):
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"temperature": 0.5},
|
||||
optional_params={"seed": 42},
|
||||
model="gpt-4o",
|
||||
drop_params=False,
|
||||
)
|
||||
assert result["seed"] == 42
|
||||
assert result["temperature"] == 0.5
|
||||
|
||||
|
||||
class TestGetSupportedOpenaiParams:
|
||||
"""Unit tests for GenAIHubOrchestrationConfig.get_supported_openai_params."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue