Skip to content

Commit 568a4f5

Browse files
author
ochafik
committed
fix command r7b normal response regex + add to server test
1 parent bfcce4d commit 568a4f5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

common/chat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ static common_chat_params common_chat_params_init_command_r7b(const common_chat_
365365
return data;
366366
}
367367
static common_chat_msg common_chat_parse_command_r7b(const std::string & input) {
368-
static std::regex response_regex("<\\|START_RESPONSE\\|>(.*?)<\\|END_RESPONSE\\|>");
369-
static std::regex thought_action_regex("<\\|START_THINKING\\|>([\\s\\S\\n\\r]*?)<\\|END_THINKING\\|><\\|START_ACTION\\|>([\\s\\S\\n\\r]*?)<\\|END_ACTION\\|>");
368+
static std::regex response_regex("<\\|START_RESPONSE\\|>([\\s\\S\\n\\r]*?)<\\|END_RESPONSE\\|>");
369+
static std::regex thought_action_regex("<\\|START_THINKING\\|>([\\s\\S\\n\\r]*)<\\|END_THINKING\\|><\\|START_ACTION\\|>([\\s\\S\\n\\r]*?)<\\|END_ACTION\\|>");
370370
std::smatch match;
371371

372372
common_chat_msg result;

examples/server/tests/unit/test_tool_call.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def test_completion_without_tool_call_slow(template_name: str, n_predict: int, t
251251

252252
@pytest.mark.slow
253253
@pytest.mark.parametrize("hf_repo,template_override", [
254+
("bartowski/c4ai-command-r7b-12-2024-GGUF:Q4_K_M", ("CohereForAI/c4ai-command-r7b-12-2024", "tool_use")),
254255
("bartowski/Meta-Llama-3.1-8B-Instruct-GGUF:Q4_K_M", None),
255256
("bartowski/gemma-2-2b-it-GGUF:Q4_K_M", None),
256257
("bartowski/Phi-3.5-mini-instruct-GGUF:Q4_K_M", None),
@@ -263,12 +264,13 @@ def test_completion_without_tool_call_slow(template_name: str, n_predict: int, t
263264
# ("bartowski/Llama-3.2-1B-Instruct-GGUF:Q4_K_M", ("meta-llama/Llama-3.2-3B-Instruct", None)),
264265
# ("bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF:Q4_K_M", None),
265266
])
266-
def test_weather_tool_call(hf_repo: str, template_override: Tuple[str, str | None] | None):
267+
def test_weather(hf_repo: str, template_override: Tuple[str, str | None] | None):
267268
global server
269+
n_predict = 512
268270
server.n_slots = 1
269271
server.jinja = True
270272
server.n_ctx = 8192
271-
server.n_predict = 512
273+
server.n_predict = n_predict
272274
server.model_hf_repo = hf_repo
273275
server.model_hf_file = None
274276
if template_override:
@@ -277,7 +279,7 @@ def test_weather_tool_call(hf_repo: str, template_override: Tuple[str, str | Non
277279
assert os.path.exists(server.chat_template_file), f"Template file {server.chat_template_file} does not exist. Run `python scripts/get_chat_template.py {template_hf_repo} {template_variant} > {server.chat_template_file}` to download the template."
278280
server.start(timeout_seconds=TIMEOUT_SERVER_START)
279281
res = server.make_request("POST", "/chat/completions", data={
280-
"max_tokens": 256,
282+
"max_tokens": n_predict,
281283
"messages": [
282284
{"role": "user", "content": "What is the weather in Istanbul?"},
283285
],

0 commit comments

Comments
 (0)