mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
Merge 5320641456 into 40be7fa1a8
This commit is contained in:
commit
b238e797bc
3 changed files with 28 additions and 6 deletions
|
|
@ -147,14 +147,16 @@ class GigaChatConfig(BaseConfig):
|
|||
return headers
|
||||
|
||||
def get_supported_openai_params(self, model: str) -> list[str]: # mutable-ok: base class contract returns list
|
||||
"""Return list of supported OpenAI parameters."""
|
||||
"""Return list of supported OpenAI parameters.
|
||||
|
||||
No stop: the GigaChat request body has no stop field.
|
||||
"""
|
||||
return [
|
||||
"stream",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"max_tokens",
|
||||
"max_completion_tokens",
|
||||
"stop",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"functions",
|
||||
|
|
@ -186,9 +188,6 @@ class GigaChatConfig(BaseConfig):
|
|||
optional_params["top_p"] = value
|
||||
elif param in ("max_tokens", "max_completion_tokens"):
|
||||
optional_params["max_tokens"] = value
|
||||
elif param == "stop":
|
||||
# GigaChat doesn't support stop sequences
|
||||
pass
|
||||
elif param == "tools":
|
||||
# Convert tools to functions format
|
||||
if isinstance(value, Sequence):
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ class TestGetSupportedOpenAiParams:
|
|||
"top_p",
|
||||
"max_tokens",
|
||||
"max_completion_tokens",
|
||||
"stop",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"functions",
|
||||
|
|
|
|||
|
|
@ -367,6 +367,30 @@ class TestGigaChatSupportedParams:
|
|||
assert "response_format" in supported
|
||||
assert "stream" in supported
|
||||
|
||||
def test_stop_not_supported(self, config):
|
||||
"""Claiming stop would silence UnsupportedParamsError and drop the sequences."""
|
||||
assert "stop" not in config.get_supported_openai_params("GigaChat")
|
||||
|
||||
def test_stop_raises_instead_of_being_dropped(self, config):
|
||||
"""stop raises UnsupportedParamsError."""
|
||||
import litellm
|
||||
from litellm.utils import get_optional_params
|
||||
|
||||
with pytest.raises(litellm.UnsupportedParamsError):
|
||||
get_optional_params(model="GigaChat", custom_llm_provider="gigachat", stop=["END"])
|
||||
|
||||
def test_stop_dropped_with_drop_params(self, config):
|
||||
"""drop_params=True drops stop."""
|
||||
from litellm.utils import get_optional_params
|
||||
|
||||
params = get_optional_params(
|
||||
model="GigaChat",
|
||||
custom_llm_provider="gigachat",
|
||||
stop=["END"],
|
||||
drop_params=True,
|
||||
)
|
||||
assert "stop" not in params
|
||||
|
||||
|
||||
class TestGigaChatToolChoiceMapping:
|
||||
"""Tests for tool_choice -> function_call mapping"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue