| 4014 | } |
| 4015 | |
| 4016 | int main(int argc, char ** argv) { |
| 4017 | common_log_set_verbosity_thold(999); |
| 4018 | |
| 4019 | // try { |
| 4020 | #ifndef _WIN32 |
| 4021 | if (argc > 1) { |
| 4022 | common_chat_templates_inputs inputs; |
| 4023 | common_chat_msg msg; |
| 4024 | msg.role = "user"; |
| 4025 | msg.content = "Hey"; |
| 4026 | inputs.messages = {msg}; |
| 4027 | inputs.tools = { special_function_tool }; |
| 4028 | |
| 4029 | std::cout << "| Template | Format |\n"; |
| 4030 | std::cout << "|----------|--------|\n"; |
| 4031 | |
| 4032 | for (int i = 1; i < argc; i++) { |
| 4033 | try { |
| 4034 | std::string path = argv[i]; |
| 4035 | if (path.rfind(".jinja") != path.size() - 6) { |
| 4036 | std::cerr << "Skipping non-jinja file: " << path << '\n'; |
| 4037 | continue; |
| 4038 | } |
| 4039 | auto tmpls = read_templates(path); |
| 4040 | auto parts = string_split(path, "/"); |
| 4041 | auto name = parts[parts.size() - 1]; |
| 4042 | auto format = common_chat_format_name(common_chat_templates_apply(tmpls.get(), inputs).format); |
| 4043 | std::cout << "| " << name << " | " << format << " |\n"; |
| 4044 | } catch (const std::exception & e) { |
| 4045 | std::cerr << "Failed to process " << argv[i] << ": " << e.what() << '\n'; |
| 4046 | } |
| 4047 | } |
| 4048 | } else |
| 4049 | #endif |
| 4050 | { |
| 4051 | test_msg_diffs_compute(); |
| 4052 | test_msgs_oaicompat_json_conversion(); |
| 4053 | test_tools_oaicompat_json_conversion(); |
| 4054 | test_template_output_parsers(); |
| 4055 | test_template_output_peg_parsers(); |
| 4056 | std::cout << "\n[chat] All tests passed!" << '\n'; |
| 4057 | } |
| 4058 | return 0; |
| 4059 | // } catch (const std::exception & e) { |
| 4060 | // std::cerr << "Error: " << e.what() << '\n'; |
| 4061 | // return 1; |
| 4062 | // } |
| 4063 | } |
nothing calls this directly
no test coverage detected