mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Merge d6824173b1 into d392e7faae
This commit is contained in:
commit
9395f68a36
2 changed files with 34 additions and 5 deletions
|
|
@ -124,14 +124,16 @@ class GigaChatConfig(BaseConfig):
|
|||
return headers
|
||||
|
||||
def get_supported_openai_params(self, model: str) -> list[str]:
|
||||
"""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",
|
||||
|
|
@ -160,9 +162,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
|
||||
optional_params["functions"] = self._convert_tools_to_functions(value)
|
||||
|
|
|
|||
|
|
@ -359,6 +359,36 @@ class TestGigaChatSupportedParams:
|
|||
assert "response_format" in supported
|
||||
assert "stream" in supported
|
||||
|
||||
def test_stop_not_supported(self, config):
|
||||
"""GigaChat has no stop sequences, so it must not claim `stop`.
|
||||
|
||||
Claiming it suppresses the UnsupportedParamsError users rely on and the
|
||||
sequences are dropped without any warning.
|
||||
"""
|
||||
assert "stop" not in config.get_supported_openai_params("GigaChat")
|
||||
|
||||
def test_stop_raises_instead_of_being_dropped(self, config):
|
||||
"""Passing stop should surface an error, not vanish."""
|
||||
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_still_droppable(self, config):
|
||||
"""With drop_params on, stop is dropped quietly - the documented escape."""
|
||||
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