This commit is contained in:
JingHao-Leon 2026-09-30 10:28:34 -04:00 • committed by GitHub
commit e2cf92bd6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 75 additions and 7 deletions

View file

@ -144,7 +144,6 @@ class CohereChatConfig(BaseConfig):
"stop",
"n",
"tools",
"tool_choice",
"seed",
"extra_headers",
]

View file

@ -128,7 +128,6 @@ class CohereV2ChatConfig(OpenAIGPTConfig):
"stop",
"n",
"tools",
"tool_choice",
"seed",
"extra_headers",
]

View file

@ -91,11 +91,6 @@ class ReplicateConfig(BaseConfig):
"max_tokens",
"top_p",
"stop",
"seed",
"tools",
"tool_choice",
"functions",
"function_call",
]
def map_openai_params(

View file

@ -0,0 +1,33 @@
import pytest
from litellm.llms.cohere.chat.transformation import CohereChatConfig
from litellm.llms.cohere.chat.v2_transformation import CohereV2ChatConfig
from litellm.utils import UnsupportedParamsError, get_optional_params
@pytest.mark.parametrize("config_cls", [CohereChatConfig, CohereV2ChatConfig])
def test_tool_choice_not_declared(config_cls):
params = config_cls().get_supported_openai_params(model="command-r")
assert "tool_choice" not in params
def test_tool_choice_raises_unsupported_params_error():
# tool_choice used to be declared but silently dropped; with drop_params=False
# (the default) litellm must surface that instead of ignoring it
with pytest.raises(UnsupportedParamsError):
get_optional_params(
model="command-r",
custom_llm_provider="cohere",
tool_choice="auto",
request_timeout=10,
num_retries=0,
)
def test_stop_still_maps_to_stop_sequences():
result = CohereChatConfig().map_openai_params(
non_default_params={"stop": ["X"]},
optional_params={},
model="command-r",
drop_params=False,
)
assert result["stop_sequences"] == ["X"]

View file

@ -0,0 +1,42 @@
import pytest
from litellm.llms.replicate.chat.transformation import ReplicateConfig
from litellm.utils import UnsupportedParamsError, get_optional_params
REMOVED_PARAMS = {
"tools": [{"type": "function", "function": {"name": "f", "parameters": {"type": "object", "properties": {}}}}],
"tool_choice": "auto",
"functions": [{"name": "f", "parameters": {}}],
"function_call": "auto",
"seed": 42,
}
def test_tool_params_not_declared():
supported = ReplicateConfig().get_supported_openai_params(model="meta/meta-llama-3-70b-instruct")
for param in REMOVED_PARAMS:
assert param not in supported
@pytest.mark.parametrize("param,value", sorted(REMOVED_PARAMS.items()))
def test_removed_params_raise_unsupported_params_error(param, value):
# these used to be declared but were silently dropped, degrading tool-calling
# requests to plain completions; with drop_params=False (the default) litellm
# must surface that instead of ignoring it
with pytest.raises(UnsupportedParamsError):
get_optional_params(
model="meta/meta-llama-3-70b-instruct",
custom_llm_provider="replicate",
**{param: value},
request_timeout=10,
num_retries=0,
)
def test_stop_still_maps_to_stop_sequences():
result = ReplicateConfig().map_openai_params(
non_default_params={"stop": ["X"]},
optional_params={},
model="meta/meta-llama-3-70b-instruct",
drop_params=False,
)
assert result["stop_sequences"] == ["X"]