| 360 | } |
| 361 | |
| 362 | static void assert_msg_equals(const common_chat_msg & expected, |
| 363 | const common_chat_msg & actual, |
| 364 | bool ignore_whitespace_differences = false) { |
| 365 | assert_equals(expected.role, actual.role); |
| 366 | if (ignore_whitespace_differences) { |
| 367 | assert_equals(string_strip(expected.content), string_strip(actual.content)); |
| 368 | } else { |
| 369 | assert_equals(expected.content, actual.content); |
| 370 | } |
| 371 | assert_equals(expected.content_parts.size(), actual.content_parts.size()); |
| 372 | for (size_t i = 0; i < expected.content_parts.size(); i++) { |
| 373 | const auto & expected_part = expected.content_parts[i]; |
| 374 | const auto & actual_part = actual.content_parts[i]; |
| 375 | assert_equals(expected_part.type, actual_part.type); |
| 376 | if (ignore_whitespace_differences) { |
| 377 | assert_equals(string_strip(expected_part.text), string_strip(actual_part.text)); |
| 378 | } else { |
| 379 | assert_equals(expected_part.text, actual_part.text); |
| 380 | } |
| 381 | } |
| 382 | if (ignore_whitespace_differences) { |
| 383 | assert_equals(string_strip(expected.reasoning_content), string_strip(actual.reasoning_content)); |
| 384 | } else { |
| 385 | assert_equals(expected.reasoning_content, actual.reasoning_content); |
| 386 | } |
| 387 | assert_equals(expected.tool_calls.size(), actual.tool_calls.size()); |
| 388 | for (size_t i = 0; i < expected.tool_calls.size(); i++) { |
| 389 | const auto & expected_tool_call = expected.tool_calls[i]; |
| 390 | const auto & actual_tool_call = actual.tool_calls[i]; |
| 391 | assert_equals(expected_tool_call.name, actual_tool_call.name); |
| 392 | assert_equals(renormalize_json(expected_tool_call.arguments), renormalize_json(actual_tool_call.arguments)); |
| 393 | assert_equals(expected_tool_call.id, actual_tool_call.id); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | static common_chat_tool special_function_tool{ |
| 398 | /* .name = */ "special_function", |
no test coverage detected