[Bugfix][Frontend] Reject Cohere REQUIRED tool choice without tools (#61825)
Signed-off-by: Kevin <jia__kuan@163.com>
This commit is contained in:
@@ -95,6 +95,27 @@ class TestCohereChatV2Request:
|
||||
tool_choice="ANY", # not REQUIRED/NONE
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("tool_fields", [{}, {"tools": None}, {"tools": []}])
|
||||
def test_required_tool_choice_requires_tools(self, tool_fields):
|
||||
with pytest.raises(VLLMValidationError, match="REQUIRED.*tools") as exc_info:
|
||||
CohereChatV2Request(
|
||||
model="m",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
tool_choice="REQUIRED",
|
||||
**tool_fields,
|
||||
)
|
||||
assert exc_info.value.parameter == "tool_choice"
|
||||
|
||||
@pytest.mark.parametrize("tool_choice", [None, "NONE"])
|
||||
def test_nonrequired_tool_choice_allows_empty_tools(self, tool_choice):
|
||||
request = CohereChatV2Request(
|
||||
model="m",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
tool_choice=tool_choice,
|
||||
tools=[],
|
||||
)
|
||||
assert request.tool_choice == tool_choice
|
||||
|
||||
def test_stop_sequences_bounded_by_env_limit(self):
|
||||
messages = [{"role": "user", "content": "hi"}]
|
||||
limit = envs.VLLM_MAX_STOP_STRINGS
|
||||
|
||||
Reference in New Issue
Block a user