Skip to content

Commit 812544a

Browse files
author
ochafik
committed
server: check that content is null when we get tool_calls
1 parent d43e4f6 commit 812544a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

examples/server/tests/unit/test_tool_call.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def do_test_completion_with_required_tool_tiny(template_name: str, tool: dict, a
9292
tool_calls = choice["message"].get("tool_calls")
9393
assert tool_calls and len(tool_calls) == 1, f'Expected 1 tool call in {choice["message"]}'
9494
tool_call = tool_calls[0]
95+
assert choice["message"].get("content") is None, f'Expected no content in {choice["message"]}'
9596
expected_function_name = "python" if tool["type"] == "code_interpreter" else tool["function"]["name"]
9697
assert expected_function_name == tool_call["function"]["name"]
9798
actual_arguments = tool_call["function"]["arguments"]
@@ -214,6 +215,7 @@ def test_completion_with_required_tool_real_model(tool: dict, argument_key: str
214215
tool_calls = choice["message"].get("tool_calls")
215216
assert tool_calls and len(tool_calls) == 1, f'Expected 1 tool call in {choice["message"]}'
216217
tool_call = tool_calls[0]
218+
assert choice["message"].get("content") is None, f'Expected no content in {choice["message"]}'
217219
expected_function_name = "python" if tool["type"] == "code_interpreter" else tool["function"]["name"]
218220
assert expected_function_name == tool_call["function"]["name"]
219221
actual_arguments = tool_call["function"]["arguments"]
@@ -332,6 +334,7 @@ def test_weather_tool_call(hf_repo: str, template_override: str | Tuple[str, str
332334
tool_calls = choice["message"].get("tool_calls")
333335
assert tool_calls and len(tool_calls) == 1, f'Expected 1 tool call in {choice["message"]}'
334336
tool_call = tool_calls[0]
337+
assert choice["message"].get("content") is None, f'Expected no content in {choice["message"]}'
335338
assert tool_call["function"]["name"] == WEATHER_TOOL["function"]["name"]
336339
actual_arguments = json.loads(tool_call["function"]["arguments"])
337340
assert 'location' in actual_arguments, f"location not found in {json.dumps(actual_arguments)}"
@@ -499,6 +502,7 @@ def test_hello_world_tool_call(expected_arguments_override: str | None, hf_repo:
499502
tool_calls = choice["message"].get("tool_calls")
500503
assert tool_calls and len(tool_calls) == 1, f'Expected 1 tool call in {choice["message"]}'
501504
tool_call = tool_calls[0]
505+
assert choice["message"].get("content") is None, f'Expected no content in {choice["message"]}'
502506
assert tool_call["function"]["name"] == PYTHON_TOOL["function"]["name"]
503507
actual_arguments = tool_call["function"]["arguments"]
504508
if expected_arguments_override is not None:

0 commit comments

Comments
 (0)