Skip to content

Commit 37b4a3a

Browse files
author
ochafik
committed
fix test-chat.cpp
1 parent 42cb16f commit 37b4a3a

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

tests/test-chat.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,24 @@ static common_chat_msg simple_assist_msg(const std::string & content, const std:
403403
}
404404
const common_chat_msg message_assist = simple_assist_msg("Hello, world!\nWhat's up?");
405405
const common_chat_msg message_assist_empty = simple_assist_msg("");
406-
const common_chat_msg message_assist_thoughts_unparsed_deepseek = simple_assist_msg("<think>I'm thinking</think>Hello, world!\nWhat's up?");
407-
const common_chat_msg message_assist_thoughts_unparsed_r7b = simple_assist_msg("<|START_THINKING|>I'm thinking<|END_THINKING|>Hello, world!\nWhat's up?");
408-
const common_chat_msg message_assist_thoughts = simple_assist_msg("Hello, world!\nWhat's up?", "I'm thinking");
409-
const common_chat_msg message_assist_thoughts_unopened_unparsed = simple_assist_msg("I'm thinking</think>Hello, world!\nWhat's up?");
406+
const common_chat_msg message_assist_thoughts_unparsed_deepseek = simple_assist_msg("<think>I'm\nthinking</think>Hello, world!\nWhat's up?");
407+
const common_chat_msg message_assist_thoughts_unparsed_r7b = simple_assist_msg("<|START_THINKING|>I'm\nthinking<|END_THINKING|>Hello, world!\nWhat's up?");
408+
const common_chat_msg message_assist_thoughts = simple_assist_msg("Hello, world!\nWhat's up?", "I'm\nthinking");
409+
const common_chat_msg message_assist_thoughts_unopened_unparsed = simple_assist_msg("I'm\nthinking</think>Hello, world!\nWhat's up?");
410410
const common_chat_msg message_assist_thoughts_no_content = simple_assist_msg("", "I'm\nthinking");
411-
const common_chat_msg message_assist_call = simple_assist_msg("", "", "python", "{\"code\": \"print('hey')\"}");
412-
const common_chat_msg message_assist_call_content = simple_assist_msg("Hello, world!\nWhat's up?", "", "special_function", "{\"arg1\": 1}");
413-
const common_chat_msg message_assist_call_empty_args = simple_assist_msg("", "", "special_function", "{}");
414-
const common_chat_msg message_assist_call_cutoff_args = simple_assist_msg("python", "{\"arg");
415-
const common_chat_msg message_assist_call_thoughts = simple_assist_msg("", "I'm\nthinking", "special_function", "{\"arg1\": 1}");
411+
const common_chat_msg message_assist_call = simple_assist_msg("", "", "special_function", "{\"arg1\": 1}");
412+
const common_chat_msg message_assist_call_content = simple_assist_msg("Hello, world!\nWhat's up?", "", "special_function", "{\"arg1\":1}");
413+
const common_chat_msg message_assist_call_empty_args = simple_assist_msg("", "", "special_function");
414+
const common_chat_msg message_assist_call_cutoff_args = simple_assist_msg("", "", "special_function", "{\"arg");
415+
const common_chat_msg message_assist_call_thoughts = simple_assist_msg("", "I'm\nthinking", "special_function", "{\"arg1\":1}");
416416
const common_chat_msg message_assist_call_thoughts_unparsed = simple_assist_msg("<think>I'm\nthinking</think>\n\n", "", "special_function", "{\"arg1\": 1}");
417-
const common_chat_msg message_assist_call_id = simple_assist_msg("", "", "special_function", "{\"arg1\": 1}", /* .id = */ "123456789");
418-
const common_chat_msg message_assist_call_idx = simple_assist_msg("", "", "special_function", "{\"arg1\": 1}", /* .id = */ "0");
419-
const common_chat_msg message_assist_thoughts_call_idx = simple_assist_msg("", "I'm thinking", "special_function", "{\"arg1\": 1}", /* id = */ "0");
420-
const common_chat_msg message_assist_call_python = simple_assist_msg("", "", "python", "{\"code\": \"print('hey')\"}");
421-
const common_chat_msg message_assist_call_python_lines = simple_assist_msg("", "", "python", "# This is a program:\nprint('hey')\n");
417+
const common_chat_msg message_assist_call_id = simple_assist_msg("", "", "special_function", "{\"arg1\":1}", /* .id = */ "123456789");
418+
const common_chat_msg message_assist_call_idx = simple_assist_msg("", "", "special_function", "{\"arg1\":1}", /* .id = */ "0");
419+
const common_chat_msg message_assist_thoughts_call_idx = simple_assist_msg("", "I'm\nthinking", "special_function", "{\"arg1\": 1}", /* id = */ "0");
420+
const common_chat_msg message_assist_call_python = simple_assist_msg("", "", "python", "{\"code\":\"print('hey')\"}");
421+
const common_chat_msg message_assist_call_python_lines = simple_assist_msg("", "", "python", "{\"code\":\"# This is a program:\\nprint('hey')\"}");
422422
const common_chat_msg message_assist_call_python_lines_unclosed = simple_assist_msg("", "", "python", "{\"code\":\"# This is a program:\\nprint('hey')");
423-
const common_chat_msg message_assist_call_code_interpreter = simple_assist_msg("", "", "code_interpreter", "{\"code\": \"print('hey')\"}");
423+
const common_chat_msg message_assist_call_code_interpreter = simple_assist_msg("", "", "code_interpreter", "{\"code\":\"print('hey')\"}");
424424

425425
static void test_msgs_oaicompat_json_conversion() {
426426
printf("[%s]\n", __func__);
@@ -473,7 +473,7 @@ static void test_msgs_oaicompat_json_conversion() {
473473
" \"type\": \"function\",\n"
474474
" \"function\": {\n"
475475
" \"name\": \"python\",\n"
476-
" \"arguments\": \"{\\\"code\\\": \\\"print('hey')\\\"}\"\n"
476+
" \"arguments\": \"{\\\"code\\\":\\\"print('hey')\\\"}\"\n"
477477
" }\n"
478478
" }\n"
479479
" ]\n"
@@ -584,7 +584,7 @@ static void test_template_output_parsers() {
584584
{COMMON_CHAT_FORMAT_COMMAND_R7B}));
585585
assert_msg_equals(message_assist_thoughts,
586586
common_chat_parse(
587-
"<|START_THINKING|>I'm thinking<|END_THINKING|>"
587+
"<|START_THINKING|>I'm\nthinking<|END_THINKING|>"
588588
"<|START_RESPONSE|>Hello, world!\nWhat's up?<|END_RESPONSE|>",
589589
/* is_partial= */ false,
590590
{
@@ -595,7 +595,7 @@ static void test_template_output_parsers() {
595595
}));
596596
assert_msg_equals(message_assist_thoughts_unparsed_deepseek,
597597
common_chat_parse(
598-
"<|START_THINKING|>I'm thinking<|END_THINKING|>"
598+
"<|START_THINKING|>I'm\nthinking<|END_THINKING|>"
599599
"<|START_RESPONSE|>Hello, world!\nWhat's up?<|END_RESPONSE|>",
600600
/* is_partial= */ false,
601601
{
@@ -606,13 +606,13 @@ static void test_template_output_parsers() {
606606
}));
607607
assert_msg_equals(message_assist_thoughts_unparsed_r7b,
608608
common_chat_parse(
609-
"<|START_THINKING|>I'm thinking<|END_THINKING|>"
609+
"<|START_THINKING|>I'm\nthinking<|END_THINKING|>"
610610
"<|START_RESPONSE|>Hello, world!\nWhat's up?<|END_RESPONSE|>",
611611
/* is_partial= */ false,
612612
{COMMON_CHAT_FORMAT_COMMAND_R7B}));
613613
assert_msg_equals(message_assist_thoughts,
614614
common_chat_parse(
615-
"<|START_THINKING|>I'm thinking<|END_THINKING|>"
615+
"<|START_THINKING|>I'm\nthinking<|END_THINKING|>"
616616
"<|START_RESPONSE|>Hello, world!\nWhat's up?<|END_RESPONSE|>",
617617
/* is_partial= */ false,
618618
{
@@ -944,16 +944,16 @@ static void test_template_output_parsers() {
944944
{COMMON_CHAT_FORMAT_HERMES_2_PRO}));
945945
assert_msg_equals(message_assist_thoughts_unparsed_deepseek,
946946
common_chat_parse(
947-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
947+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
948948
/* is_partial= */ false,
949949
{COMMON_CHAT_FORMAT_HERMES_2_PRO}));
950950
// assert_msg_equals(message_assist_thoughts_unparsed_deepseek,
951951
// common_chat_parse(
952-
// "I'm thinking</think>Hello, world!\nWhat's up?",
952+
// "I'm\nthinking</think>Hello, world!\nWhat's up?",
953953
// COMMON_CHAT_FORMAT_HERMES_2_PRO));
954954
assert_msg_equals(message_assist_thoughts,
955955
common_chat_parse(
956-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
956+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
957957
/* is_partial= */ false,
958958
{
959959
/* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
@@ -963,7 +963,7 @@ static void test_template_output_parsers() {
963963
}));
964964
assert_msg_equals(message_assist_thoughts_unopened_unparsed,
965965
common_chat_parse(
966-
"I'm thinking</think>Hello, world!\nWhat's up?",
966+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
967967
/* is_partial= */ false,
968968
{
969969
/* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
@@ -973,7 +973,7 @@ static void test_template_output_parsers() {
973973
}));
974974
assert_msg_equals(message_assist_thoughts,
975975
common_chat_parse(
976-
"I'm thinking</think>Hello, world!\nWhat's up?",
976+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
977977
/* is_partial= */ false,
978978
{
979979
/* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
@@ -989,7 +989,7 @@ static void test_template_output_parsers() {
989989
"</tool_call>");
990990
test_templates(tmpls.get(), end_tokens, message_assist_call_python_lines, tools,
991991
"<tool_call>\n"
992-
"{\"name\": \"python\", \"arguments\": {\"code\": \"# This is a program:\\nprint('hey')\"}}\n"
992+
"{\"name\": \"python\", \"arguments\": {\"code\":\"# This is a program:\\nprint('hey')\"}}\n"
993993
"</tool_call>");
994994
}
995995
{
@@ -1131,9 +1131,9 @@ static void test_template_output_parsers() {
11311131
test_templates(tmpls.get(), end_tokens, message_assist, tools, "Hello, world!\nWhat's up?", /* expect_grammar_triggered= */ false);
11321132
test_templates(tmpls.get(), end_tokens, message_assist_thoughts, tools, "Hello, world!\nWhat's up?", /* expect_grammar_triggered= */ false);
11331133
assert_msg_equals(
1134-
simple_assist_msg("Hello, world!\nWhat's up?", "<think>I'm thinking"),
1134+
simple_assist_msg("Hello, world!\nWhat's up?", "<think>I'm\nthinking"),
11351135
common_chat_parse(
1136-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
1136+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
11371137
/* is_partial= */ false,
11381138
{
11391139
COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1154,7 +1154,7 @@ static void test_template_output_parsers() {
11541154
}));
11551155
assert_msg_equals(message_assist_thoughts,
11561156
common_chat_parse(
1157-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
1157+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
11581158
/* is_partial= */ false,
11591159
{
11601160
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1164,7 +1164,7 @@ static void test_template_output_parsers() {
11641164
}));
11651165
assert_msg_equals(message_assist_thoughts_unopened_unparsed,
11661166
common_chat_parse(
1167-
"I'm thinking</think>Hello, world!\nWhat's up?",
1167+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
11681168
/* is_partial= */ false,
11691169
{
11701170
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1174,7 +1174,7 @@ static void test_template_output_parsers() {
11741174
}));
11751175
assert_msg_equals(message_assist_thoughts,
11761176
common_chat_parse(
1177-
"I'm thinking</think>Hello, world!\nWhat's up?",
1177+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
11781178
/* is_partial= */ false,
11791179
{
11801180
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1185,7 +1185,7 @@ static void test_template_output_parsers() {
11851185
assert_msg_equals(message_assist_thoughts,
11861186
// Latest template update (ast of 20250209) adds a trailing <think>\n if add_generation_prompt is true.
11871187
common_chat_parse(
1188-
"I'm thinking</think>Hello, world!\nWhat's up?",
1188+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
11891189
/* is_partial= */ false,
11901190
{
11911191
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1213,12 +1213,12 @@ static void test_template_output_parsers() {
12131213
test_templates(tmpls.get(), end_tokens, message_assist_thoughts, tools, "Hello, world!\nWhat's up?", /* expect_grammar_triggered= */ false);
12141214
assert_msg_equals(message_assist_thoughts_unparsed_deepseek,
12151215
common_chat_parse(
1216-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
1216+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
12171217
/* is_partial= */ false,
12181218
{COMMON_CHAT_FORMAT_DEEPSEEK_R1}));
12191219
assert_msg_equals(message_assist_thoughts,
12201220
common_chat_parse(
1221-
"<think>I'm thinking</think>Hello, world!\nWhat's up?",
1221+
"<think>I'm\nthinking</think>Hello, world!\nWhat's up?",
12221222
/* is_partial= */ false,
12231223
{
12241224
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
@@ -1228,7 +1228,7 @@ static void test_template_output_parsers() {
12281228
}));
12291229
assert_msg_equals(message_assist_thoughts,
12301230
common_chat_parse(
1231-
"I'm thinking</think>Hello, world!\nWhat's up?",
1231+
"I'm\nthinking</think>Hello, world!\nWhat's up?",
12321232
/* is_partial= */ false,
12331233
{
12341234
/* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,

0 commit comments

Comments
 (0)