@@ -1402,6 +1402,12 @@ static void test_template_output_parsers() {
1402
1402
" Hello, world!\n What's up?" ,
1403
1403
/* is_partial= */ false ,
1404
1404
{COMMON_CHAT_FORMAT_GRANITE}));
1405
+ assert_msg_equals (
1406
+ message_assist,
1407
+ common_chat_parse (
1408
+ " Hello, world!\n What's up?" ,
1409
+ /* is_partial= */ true ,
1410
+ {COMMON_CHAT_FORMAT_GRANITE}));
1405
1411
1406
1412
// Test parsing content with thinking
1407
1413
assert_msg_equals (message_assist_thoughts,
@@ -1412,13 +1418,98 @@ static void test_template_output_parsers() {
1412
1418
/* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1413
1419
/* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1414
1420
}));
1421
+ assert_msg_equals (message_assist_thoughts_unparsed_deepseek,
1422
+ common_chat_parse (
1423
+ " <think>I'm\n thinking</think>Hello, world!\n What's up?" ,
1424
+ /* is_partial= */ false ,
1425
+ {COMMON_CHAT_FORMAT_GRANITE}));
1426
+ assert_msg_equals (message_assist_thoughts,
1427
+ common_chat_parse (
1428
+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?" ,
1429
+ /* is_partial= */ true ,
1430
+ {
1431
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1432
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1433
+ }));
1434
+ assert_msg_equals (message_assist_thoughts,
1435
+ common_chat_parse (
1436
+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ,
1437
+ /* is_partial= */ false ,
1438
+ {
1439
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1440
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1441
+ }));
1442
+ assert_msg_equals (simple_assist_msg (" <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ),
1443
+ common_chat_parse (
1444
+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ,
1445
+ /* is_partial= */ false ,
1446
+ {COMMON_CHAT_FORMAT_GRANITE}));
1447
+ assert_msg_equals (message_assist_empty,
1448
+ common_chat_parse (
1449
+ " <think" ,
1450
+ /* is_partial= */ true ,
1451
+ {
1452
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1453
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1454
+ }));
1455
+ assert_msg_equals (message_assist_empty,
1456
+ common_chat_parse (
1457
+ " <think" ,
1458
+ /* is_partial= */ true ,
1459
+ {COMMON_CHAT_FORMAT_GRANITE}));
1460
+ assert_msg_equals (message_assist_thoughts_no_content,
1461
+ common_chat_parse (
1462
+ " <think>I'm\n thinking" ,
1463
+ /* is_partial= */ true ,
1464
+ {
1465
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1466
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1467
+ }));
1468
+ assert_msg_equals (
1469
+ message_assist_empty,
1470
+ common_chat_parse (
1471
+ " <think>I'm\n thinking</think><response" ,
1472
+ /* is_partial= */ true ,
1473
+ {COMMON_CHAT_FORMAT_GRANITE}));
1415
1474
1416
1475
// Test parsing tool calls
1417
1476
assert_msg_equals (message_assist_call,
1418
1477
common_chat_parse (
1419
1478
" <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}]" ,
1420
1479
/* is_partial= */ false ,
1421
1480
{COMMON_CHAT_FORMAT_GRANITE}));
1481
+ assert_msg_equals (
1482
+ message_assist_call_empty_args,
1483
+ common_chat_parse (
1484
+ " <|tool_call|>[{\" name\" : \" special_function\" " ,
1485
+ /* is_partial= */ true ,
1486
+ {COMMON_CHAT_FORMAT_GRANITE}));
1487
+ assert_msg_equals (
1488
+ message_assist_call_cutoff_args,
1489
+ common_chat_parse (
1490
+ " <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg" ,
1491
+ /* is_partial= */ true ,
1492
+ {COMMON_CHAT_FORMAT_GRANITE}));
1493
+ assert_msg_equals (
1494
+ message_assist_call_cutoff_args,
1495
+ common_chat_parse (
1496
+ " <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg" ,
1497
+ /* is_partial= */ true ,
1498
+ {
1499
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1500
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1501
+ }));
1502
+
1503
+ // Test parsing tool calls with thinking
1504
+ assert_msg_equals (
1505
+ message_assist_call_thoughts,
1506
+ common_chat_parse (
1507
+ " <think>I'm\n thinking</think><|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}, {" ,
1508
+ /* is_partial= */ true ,
1509
+ {
1510
+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1511
+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1512
+ }));
1422
1513
1423
1514
// Test template generation for regular content
1424
1515
test_templates (tmpls.get (), end_tokens, message_assist, tools,
0 commit comments