@@ -401,9 +401,12 @@ static common_chat_msg simple_assist_msg(const std::string & content, const std:
401401 }
402402 return msg;
403403}
404- const common_chat_msg message_assist = simple_assist_msg(" Hello, world!\n What's up?" );
405- 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\n thinking</think>Hello, world!\n What's up?" );
404+ const common_chat_msg message_assist = simple_assist_msg(" Hello, world!\n What's up?" );
405+ 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\n thinking</think>Hello, world!\n What's up?" );
407+ const common_chat_msg message_assist_thoughts_unparsed_md = simple_assist_msg(" <think>I'm\n thinking</think>Hello, world!\n What's up?\n ```json\n {}```" );
408+ const common_chat_msg message_assist_thoughts_unparsed_md_partial = simple_assist_msg(" <think>I'm\n thinking</think>Hello, world!\n What's up?\n ```json\n {}" );
409+
407410const common_chat_msg message_assist_thoughts_unparsed_r7b = simple_assist_msg(" <|START_THINKING|>I'm\n thinking<|END_THINKING|>Hello, world!\n What's up?" );
408411const common_chat_msg message_assist_thoughts = simple_assist_msg(" Hello, world!\n What's up?" , " I'm\n thinking" );
409412const common_chat_msg message_assist_thoughts_unopened_unparsed = simple_assist_msg(" I'm\n thinking</think>Hello, world!\n What's up?" );
@@ -591,8 +594,6 @@ static void test_template_output_parsers() {
591594 {
592595 /* .format = */ COMMON_CHAT_FORMAT_COMMAND_R7B,
593596 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
594- /* .reasoning_in_content = */ false ,
595- /* .thinking_forced_open = */ false ,
596597 }));
597598 assert_msg_equals (message_assist_thoughts_unparsed_deepseek,
598599 common_chat_parse (
@@ -619,8 +620,6 @@ static void test_template_output_parsers() {
619620 {
620621 /* .format = */ COMMON_CHAT_FORMAT_COMMAND_R7B,
621622 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
622- /* .reasoning_in_content = */ false ,
623- /* .thinking_forced_open = */ false ,
624623 }));
625624 assert_msg_equals (message_assist_thoughts_call_idx,
626625 common_chat_parse (
@@ -632,8 +631,6 @@ static void test_template_output_parsers() {
632631 {
633632 /* .format = */ COMMON_CHAT_FORMAT_COMMAND_R7B,
634633 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
635- /* .reasoning_in_content = */ false ,
636- /* .thinking_forced_open = */ false ,
637634 }));
638635 assert_msg_equals (message_assist_thoughts_no_content,
639636 common_chat_parse (
@@ -644,8 +641,6 @@ static void test_template_output_parsers() {
644641 {
645642 /* .format = */ COMMON_CHAT_FORMAT_COMMAND_R7B,
646643 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
647- /* .reasoning_in_content = */ false ,
648- /* .thinking_forced_open = */ false ,
649644 }));
650645
651646 test_templates (tmpls.get (), end_tokens, message_assist_call_idx, tools,
@@ -675,6 +670,18 @@ static void test_template_output_parsers() {
675670
676671 // Generic tool calls doesn't generate / parse content-only messages symmetrically.
677672
673+ assert_equals (
674+ simple_assist_msg (" { \" tool_call\" : { \" name\" : \" t" ),
675+ common_chat_parse (
676+ " { \" tool_call\" : { \" name\" : \" t" ,
677+ /* is_partial= */ true ,
678+ {
679+ /* .format = */ COMMON_CHAT_FORMAT_GENERIC,
680+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
681+ /* .reasoning_in_content = */ false ,
682+ /* .thinking_forced_open = */ true ,
683+ /* .parse_tool_calls = */ false ,
684+ }));
678685 assert_equals (
679686 message_assist_empty,
680687 common_chat_parse (
@@ -776,8 +783,6 @@ static void test_template_output_parsers() {
776783 {
777784 /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
778785 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
779- /* .reasoning_in_content = */ false ,
780- /* .thinking_forced_open = */ false ,
781786 }));
782787 assert_msg_equals (
783788 simple_assist_msg (" Let's call something\n " ),
@@ -788,8 +793,6 @@ static void test_template_output_parsers() {
788793 {
789794 /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
790795 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
791- /* .reasoning_in_content = */ false ,
792- /* .thinking_forced_open = */ false ,
793796 }));
794797 assert_msg_equals (message_assist_call_thoughts,
795798 common_chat_parse (
@@ -979,7 +982,34 @@ static void test_template_output_parsers() {
979982 {
980983 /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
981984 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
982- /* .reasoning_in_content = */ false ,
985+ }));
986+ assert_msg_equals (message_assist_thoughts,
987+ common_chat_parse (
988+ " <think>I'm\n thinking</think>Hello, world!\n What's up?" ,
989+ /* is_partial= */ true ,
990+ {
991+ /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
992+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
993+ }));
994+ assert_msg_equals (message_assist_thoughts_unparsed_md,
995+ common_chat_parse (
996+ " <think>I'm\n thinking</think>Hello, world!\n What's up?\n ```json\n {}```" ,
997+ /* is_partial= */ false ,
998+ {
999+ /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
1000+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1001+ /* .reasoning_in_content = */ true ,
1002+ /* .thinking_forced_open = */ false ,
1003+ /* .parse_tool_calls = */ false ,
1004+ }));
1005+ assert_msg_equals (message_assist_thoughts_unparsed_md_partial,
1006+ common_chat_parse (
1007+ " <think>I'm\n thinking</think>Hello, world!\n What's up?\n ```json\n {}```" ,
1008+ /* is_partial= */ true ,
1009+ {
1010+ /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
1011+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1012+ /* .reasoning_in_content = */ true ,
9831013 /* .thinking_forced_open = */ false ,
9841014 }));
9851015 assert_msg_equals (message_assist_thoughts_unopened_unparsed,
@@ -989,8 +1019,6 @@ static void test_template_output_parsers() {
9891019 {
9901020 /* .format = */ COMMON_CHAT_FORMAT_HERMES_2_PRO,
9911021 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
992- /* .reasoning_in_content = */ false ,
993- /* .thinking_forced_open = */ false ,
9941022 }));
9951023 assert_msg_equals (message_assist_thoughts,
9961024 common_chat_parse (
@@ -1187,8 +1215,6 @@ static void test_template_output_parsers() {
11871215 {
11881216 /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
11891217 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1190- /* .reasoning_in_content = */ false ,
1191- /* .thinking_forced_open = */ false ,
11921218 }));
11931219 assert_msg_equals (message_assist_thoughts_unopened_unparsed,
11941220 common_chat_parse (
@@ -1197,8 +1223,6 @@ static void test_template_output_parsers() {
11971223 {
11981224 /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
11991225 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1200- /* .reasoning_in_content = */ false ,
1201- /* .thinking_forced_open = */ false ,
12021226 }));
12031227 assert_msg_equals (message_assist_thoughts,
12041228 common_chat_parse (
@@ -1252,8 +1276,6 @@ static void test_template_output_parsers() {
12521276 {
12531277 /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
12541278 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1255- /* .reasoning_in_content = */ false ,
1256- /* .thinking_forced_open = */ false ,
12571279 }));
12581280 assert_msg_equals (message_assist_thoughts,
12591281 common_chat_parse (
@@ -1295,8 +1317,6 @@ static void test_template_output_parsers() {
12951317 {
12961318 /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_R1,
12971319 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1298- /* .reasoning_in_content = */ false ,
1299- /* .thinking_forced_open = */ false ,
13001320 }));
13011321 test_templates (tmpls.get (), end_tokens, message_assist_call, tools,
13021322 " <|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>special_function\n "
0 commit comments