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