mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(cerebras): include max_retries in supported OpenAI params allowlist
``max_retries`` is a standard parameter exposed by both the OpenAI Python client and LiteLLM's ``litellm.completion()`` API. The Cerebras inference endpoint accepts it without issue, but ``CerebrasConfig.get_supported_openai_params`` was omitting it from the allowlist, so LiteLLM was silently stripping the value before forwarding the call. Callers passing ``max_retries=N`` on Cerebras requests therefore had no way to override the default retry behaviour — the request flowed through unchanged but the override was dropped without warning. Adding ``"max_retries"`` to the allowlist lets the value reach the underlying HTTP client and lets per-call retry overrides work as documented. Tests (tests/test_litellm/llms/cerebras/test_cerebras_chat_transformation.py): - test_max_retries_in_supported_params — guards against future regressions removing the entry. - test_core_openai_params_still_supported — regression guard ensuring no existing allowlist entries are accidentally dropped by the change.
This commit is contained in:
parent
38edf241a4
commit
e244b63231
2 changed files with 54 additions and 0 deletions
|
|
@ -68,6 +68,7 @@ class CerebrasConfig(OpenAIGPTConfig):
|
|||
"tool_choice",
|
||||
"tools",
|
||||
"user",
|
||||
"max_retries",
|
||||
]
|
||||
|
||||
# Only add reasoning_effort for models that support it
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
"""
|
||||
Unit tests for Cerebras chat configuration.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(
|
||||
0, os.path.abspath("../../../../..")
|
||||
) # project root for ``litellm`` import
|
||||
|
||||
from litellm.llms.cerebras.chat import CerebrasConfig
|
||||
|
||||
|
||||
class TestCerebrasGetSupportedOpenAIParams:
|
||||
"""Validates the OpenAI-param allowlist exposed by ``CerebrasConfig``."""
|
||||
|
||||
def test_max_retries_in_supported_params(self):
|
||||
"""``max_retries`` is a standard OpenAI client parameter that Cerebras
|
||||
accepts. It must appear in the supported-param allowlist so callers
|
||||
can override the default retry count per request without LiteLLM
|
||||
stripping the value silently.
|
||||
"""
|
||||
config = CerebrasConfig()
|
||||
params = config.get_supported_openai_params(model="llama3.1-8b")
|
||||
assert "max_retries" in params, (
|
||||
f"max_retries should be in the Cerebras supported_params allowlist; "
|
||||
f"got: {params!r}"
|
||||
)
|
||||
|
||||
def test_core_openai_params_still_supported(self):
|
||||
"""Regression guard: the standard OpenAI params Cerebras has always
|
||||
accepted must remain in the allowlist after the ``max_retries``
|
||||
addition (no accidental removals)."""
|
||||
config = CerebrasConfig()
|
||||
params = config.get_supported_openai_params(model="llama3.1-8b")
|
||||
for expected in (
|
||||
"max_tokens",
|
||||
"max_completion_tokens",
|
||||
"response_format",
|
||||
"seed",
|
||||
"stop",
|
||||
"stream",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"tool_choice",
|
||||
"tools",
|
||||
"user",
|
||||
):
|
||||
assert expected in params, (
|
||||
f"{expected!r} unexpectedly missing from Cerebras supported_params: "
|
||||
f"{params!r}"
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue