Skip to content

Commit 8409bf1

Browse files
author
ochafik
committed
fix test_calc_result & test_thoughts
1 parent ea2f41e commit 8409bf1

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

examples/server/tests/unit/test_tool_call.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,20 @@ def test_weather(hf_repo: str, template_override: str | Tuple[str, str | None] |
348348

349349
@pytest.mark.slow
350350
@pytest.mark.parametrize("result_override,n_predict,hf_repo,template_override", [
351-
(None, 128, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", "chatml"),
352-
(None, 128, "bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M", None),
353-
(None, 128, "bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M", "chatml"),
354-
(None, 128, "bartowski/Hermes-2-Pro-Llama-3-8B-GGUF:Q4_K_M", ("NousResearch/Hermes-2-Pro-Llama-3-8B", "tool_use")),
355-
(None, 128, "bartowski/Hermes-3-Llama-3.1-8B-GGUF:Q4_K_M", ("NousResearch/Hermes-3-Llama-3.1-8B", "tool_use")),
356-
(None, 128, "bartowski/functionary-small-v3.2-GGUF:Q8_0", ("meetkai/functionary-medium-v3.2", None)),
357-
(None, 128, "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF:Q4_K_M", None),
358-
(None, 128, "bartowski/Mistral-Nemo-Instruct-2407-GGUF:Q4_K_M", None),
359-
("^> 0.56$", 128, "bartowski/Mistral-Nemo-Instruct-2407-GGUF:Q4_K_M", "chatml"),
351+
(None, 128, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", "chatml"),
352+
(None, 128, "bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M", None),
353+
(None, 128, "bartowski/Qwen2.5-7B-Instruct-GGUF:Q4_K_M", "chatml"),
354+
(None, 128, "bartowski/Hermes-2-Pro-Llama-3-8B-GGUF:Q4_K_M", ("NousResearch/Hermes-2-Pro-Llama-3-8B", "tool_use")),
355+
(None, 128, "bartowski/Hermes-3-Llama-3.1-8B-GGUF:Q4_K_M", ("NousResearch/Hermes-3-Llama-3.1-8B", "tool_use")),
356+
(None, 128, "bartowski/functionary-small-v3.2-GGUF:Q8_0", ("meetkai/functionary-medium-v3.2", None)),
357+
(None, 128, "bartowski/Meta-Llama-3.1-8B-Instruct-GGUF:Q4_K_M", None),
358+
(None, 128, "bartowski/Mistral-Nemo-Instruct-2407-GGUF:Q4_K_M", None),
359+
("^> 0.56$", 128, "bartowski/Mistral-Nemo-Instruct-2407-GGUF:Q4_K_M", "chatml"),
360+
(None, 128, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
360361
361362
# TODO: fix these (wrong results, either didn't respect decimal instruction or got wrong value)
362-
("[\\s\\S\\r\\n]*?\\b0\\.55644242476$", 128, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
363-
("[\\s\\S\\r\\n]*?which equals 0\\.5\\.", 8192, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
364-
("[\\s\\S\\r\\n]*?\\*\\*Answer:\\*\\* 0\\.25\\b", 8192, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", ("llama-cpp-deepseek-r1", None)),
363+
("^The y-coordinate [\\s\\S]*?\\*\\*0.5\\*\\*", 8192, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
364+
("[\\s\\S]*?\\*\\*0\\.5\\*\\*", 8192, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", ("llama-cpp-deepseek-r1", None)),
365365
])
366366
def test_calc_result(result_override: str | None, n_predict: int, hf_repo: str, template_override: str | Tuple[str, str | None] | None):
367367
global server
@@ -382,7 +382,7 @@ def test_calc_result(result_override: str | None, n_predict: int, hf_repo: str,
382382
res = server.make_request("POST", "/chat/completions", data={
383383
"max_tokens": n_predict,
384384
"messages": [
385-
{"role": "system", "content": "You are a chatbot that uses tools/functions. Dont overthink things, and provide very concise answers. Do not explain your reasoning to the user. Provide any numerical values back to the user with two decimals."},
385+
{"role": "system", "content": "You are a chatbot that uses tools/functions. Dont overthink things, and provide very concise answers. Do not explain your reasoning to the user. Provide any numerical values back to the user with at most two decimals."},
386386
{"role": "user", "content": "What's the y coordinate of a point on the unit sphere at angle 30 degrees?"},
387387
{
388388
"role": "assistant",
@@ -402,7 +402,7 @@ def test_calc_result(result_override: str | None, n_predict: int, hf_repo: str,
402402
"role": "tool",
403403
"name": "calculate",
404404
"content": 0.55644242476,
405-
"tool_call_id": "call_6789",
405+
"tool_call_id": "call_6789"
406406
}
407407
],
408408
"tools": [
@@ -434,19 +434,19 @@ def test_calc_result(result_override: str | None, n_predict: int, hf_repo: str,
434434
if result_override is not None:
435435
assert re.match(result_override, content), f'Expected {result_override}, got {content}'
436436
else:
437-
assert re.match('^[\\s\\S\\r\\n]*?The (y[ -])?coordinate [\\s\\S\\r\\n]*?is (approximately )?0\\.56\\b|^0\\.56$', content), \
437+
assert re.match('^[\\s\\S]*?The (y[ -])?coordinate [\\s\\S]*?is (approximately )?0\\.56\\b|^0\\.56$', content), \
438438
f'Expected something like "The y coordinate is 0.56.", got {content}'
439439

440440

441441
@pytest.mark.slow
442442
@pytest.mark.parametrize("n_predict,reasoning_format,expect_content,expect_reasoning_content,hf_repo,template_override", [
443-
(1024, 'deepseek', "^The sum of 102 and 7 is 109.*", None, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
443+
(128, 'deepseek', "^The sum of 102 and 7 is 109.*", None, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
444444
(128, None, "^The sum of 102 and 7 is 109.*", None, "bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
445445
446-
(1024, 'deepseek', "To find the sum of.*", "I need to calculate the sum of 102 and 7.*", "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
447-
(1024, 'none', "<think>\nI need[\\s\\S\\r\\n]*?</think>\nTo find.*", None, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
446+
(1024, 'deepseek', "To find the sum of.*", "I need to calculate the sum of 102 and 7.*", "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
447+
(1024, 'none', "<think>\n?I need[\\s\\S]*?</think>\n?To find.*", None, "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
448448
449-
(1024, 'deepseek', "To find the sum of.*", "First, I need to add the tens place.*", "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", ("llama-cpp-deepseek-r1", None)),
449+
(1024, 'deepseek', "To find the sum of.*", "First, I [\\s\\S]*", "bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", ("llama-cpp-deepseek-r1", None)),
450450
])
451451
def test_thoughts(n_predict: int, reasoning_format: Literal['deepseek', 'none'] | None, expect_content: str | None, expect_reasoning_content: str | None, hf_repo: str, template_override: str | Tuple[str, str | None] | None):
452452
global server

examples/server/tests/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ def start(self, timeout_seconds: int | None = DEFAULT_HTTP_TIMEOUT) -> None:
173173
server_args.append("--no-webui")
174174
if self.jinja:
175175
server_args.append("--jinja")
176-
if self.reasoning_format:
177-
server_args.append("--reasoning-format")
176+
if self.reasoning_format is not None:
177+
server_args.extend(("--reasoning-format", self.reasoning_format))
178178
if self.chat_template:
179179
server_args.extend(["--chat-template", self.chat_template])
180180
if self.chat_template_file:

0 commit comments

Comments
 (0)