mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
Merge e17c2ac016 into b781d157d7
This commit is contained in:
commit
e2cf92bd6e
6 changed files with 75 additions and 7 deletions
|
|
@ -144,7 +144,6 @@ class CohereChatConfig(BaseConfig):
|
|||
"stop",
|
||||
"n",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"seed",
|
||||
"extra_headers",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ class CohereV2ChatConfig(OpenAIGPTConfig):
|
|||
"stop",
|
||||
"n",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"seed",
|
||||
"extra_headers",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -91,11 +91,6 @@ class ReplicateConfig(BaseConfig):
|
|||
"max_tokens",
|
||||
"top_p",
|
||||
"stop",
|
||||
"seed",
|
||||
"tools",
|
||||
"tool_choice",
|
||||
"functions",
|
||||
"function_call",
|
||||
]
|
||||
|
||||
def map_openai_params(
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
0
tests/unit/llms/replicate/chat/__init__.py
Normal file
0
tests/unit/llms/replicate/chat/__init__.py
Normal 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"]
|
||||
Loading…
Add table
Reference in a new issue