@@ -289,7 +289,7 @@ static void test_template(const common_chat_template & tmpl, const std::vector<s
289
289
static void test_template_output_parsers () {
290
290
json text_message {
291
291
{ " role" , " assistant" },
292
- { " content" , " Hello, world!" },
292
+ { " content" , " Hello, world!\n What's up? " },
293
293
};
294
294
json tool_calls = json::array ({{
295
295
{ " type" , " function" },
@@ -379,7 +379,7 @@ static void test_template_output_parsers() {
379
379
380
380
common_chat_inputs inputs_no_tools;
381
381
inputs_no_tools.messages = {
382
- { { " role" , " user" }, { " content" , " Hey" } }
382
+ { { " role" , " user" }, { " content" , " Hey\n There " } }
383
383
};
384
384
385
385
common_chat_inputs inputs_tools = inputs_no_tools;
@@ -408,7 +408,8 @@ static void test_template_output_parsers() {
408
408
" {\" tool_call_id\" : \" 0\" , \" tool_name\" : \" special_function\" , \" parameters\" : {\" arg1\" : 1}}\n "
409
409
" ]<|END_ACTION|>" );
410
410
test_template (tmpl, end_tokens, text_message, tools,
411
- " <|START_RESPONSE|>Hello, world!<|END_RESPONSE|>" ,
411
+ " <|START_RESPONSE|>Hello, world!\n "
412
+ " What's up?<|END_RESPONSE|>" ,
412
413
/* expect_grammar_triggered= */ false );
413
414
}
414
415
{
@@ -428,7 +429,7 @@ static void test_template_output_parsers() {
428
429
429
430
assert_msg_equals (msg_from_json (text_message),
430
431
common_chat_parse (" {\n "
431
- " \" response\" : \" Hello, world!\"\n "
432
+ " \" response\" : \" Hello, world!\\ nWhat's up? \ "\n"
432
433
" }" ,
433
434
common_chat_params_init (tmpl, inputs_tools).format ));
434
435
test_template (tmpl, end_tokens, tool_call_message_with_id, tools,
@@ -451,7 +452,7 @@ static void test_template_output_parsers() {
451
452
452
453
assert_equals (COMMON_CHAT_FORMAT_MISTRAL_NEMO, common_chat_params_init (tmpl, inputs_tools).format );
453
454
454
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
455
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
455
456
test_template (
456
457
tmpl, end_tokens, tool_call_message_with_id, tools,
457
458
" [TOOL_CALLS][{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}, \" id\" : \" 123456789\" }]" );
@@ -476,7 +477,7 @@ static void test_template_output_parsers() {
476
477
inputs_tools)
477
478
.format );
478
479
479
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
480
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
480
481
test_template (tmpl, end_tokens, tool_call_message, tools,
481
482
" <tool_call>\n "
482
483
" {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}\n "
@@ -516,7 +517,7 @@ static void test_template_output_parsers() {
516
517
517
518
assert_equals (COMMON_CHAT_FORMAT_LLAMA_3_X, common_chat_params_init (tmpl, inputs_tools).format );
518
519
519
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
520
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
520
521
test_template (tmpl, end_tokens, tool_call_message, tools,
521
522
" {\" name\" : \" special_function\" , \" parameters\" : {\" arg1\" : 1}}" );
522
523
}
@@ -528,7 +529,7 @@ static void test_template_output_parsers() {
528
529
assert_equals (COMMON_CHAT_FORMAT_FUNCTIONARY_V3_1_LLAMA_3_1,
529
530
common_chat_params_init (tmpl, inputs_tools).format );
530
531
531
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
532
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
532
533
test_template (tmpl, end_tokens, tool_call_message, tools,
533
534
" <function=special_function>{\" arg1\" : 1}</function>" );
534
535
}
@@ -542,7 +543,8 @@ static void test_template_output_parsers() {
542
543
543
544
test_template (tmpl, end_tokens, text_message, {},
544
545
" all\n "
545
- " Hello, world!" ,
546
+ " Hello, world!\n "
547
+ " What's up?" ,
546
548
/* expect_grammar_triggered= */ false );
547
549
test_template (tmpl, end_tokens, tool_call_message, tools,
548
550
" special_function\n "
@@ -555,7 +557,7 @@ static void test_template_output_parsers() {
555
557
556
558
assert_equals (COMMON_CHAT_FORMAT_FIREFUNCTION_V2, common_chat_params_init (tmpl, inputs_tools).format );
557
559
558
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
560
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
559
561
test_template (tmpl, end_tokens, tool_call_message, tools,
560
562
" functools[{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}]" );
561
563
}
@@ -566,7 +568,7 @@ static void test_template_output_parsers() {
566
568
567
569
assert_equals (COMMON_CHAT_FORMAT_DEEPSEEK_R1, common_chat_params_init (tmpl, inputs_tools).format );
568
570
569
- test_template (tmpl, end_tokens, text_message, tools, " Hello, world!" , /* expect_grammar_triggered= */ false );
571
+ test_template (tmpl, end_tokens, text_message, tools, " Hello, world!\n What's up? " , /* expect_grammar_triggered= */ false );
570
572
test_template (tmpl, end_tokens, tool_call_message, tools,
571
573
" <|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>special_function\n "
572
574
" ```json\n "
0 commit comments