| 1428 | } |
| 1429 | |
| 1430 | int main(int argc, char ** argv) { |
| 1431 | // try { |
| 1432 | #ifndef _WIN32 |
| 1433 | if (argc > 1) { |
| 1434 | common_chat_templates_inputs inputs; |
| 1435 | common_chat_msg msg; |
| 1436 | msg.role = "user"; |
| 1437 | msg.content = "Hey"; |
| 1438 | inputs.messages = {msg}; |
| 1439 | inputs.tools = { special_function_tool }; |
| 1440 | |
| 1441 | std::cout << "| Template | Format |\n"; |
| 1442 | std::cout << "|----------|--------|\n"; |
| 1443 | |
| 1444 | for (int i = 1; i < argc; i++) { |
| 1445 | try { |
| 1446 | std::string path = argv[i]; |
| 1447 | if (path.rfind(".jinja") != path.size() - 6) { |
| 1448 | std::cerr << "Skipping non-jinja file: " << path << '\n'; |
| 1449 | continue; |
| 1450 | } |
| 1451 | auto tmpls = read_templates(path); |
| 1452 | auto parts = string_split(path, "/"); |
| 1453 | auto name = parts[parts.size() - 1]; |
| 1454 | auto format = common_chat_format_name(common_chat_templates_apply(tmpls.get(), inputs).format); |
| 1455 | std::cout << "| " << name << " | " << format << " |\n"; |
| 1456 | } catch (const std::exception & e) { |
| 1457 | std::cerr << "Failed to process " << argv[i] << ": " << e.what() << '\n'; |
| 1458 | } |
| 1459 | } |
| 1460 | } else |
| 1461 | #endif |
| 1462 | { |
| 1463 | test_msg_diffs_compute(); |
| 1464 | test_msgs_oaicompat_json_conversion(); |
| 1465 | test_tools_oaicompat_json_conversion(); |
| 1466 | test_template_output_parsers(); |
| 1467 | std::cout << "\n[chat] All tests passed!" << '\n'; |
| 1468 | } |
| 1469 | return 0; |
| 1470 | // } catch (const std::exception & e) { |
| 1471 | // std::cerr << "Error: " << e.what() << '\n'; |
| 1472 | // return 1; |
| 1473 | // } |
| 1474 | } |
nothing calls this directly
no test coverage detected