| 410 | } |
| 411 | |
| 412 | bool common_chat_verify_template(const std::string & tmpl, bool use_jinja) { |
| 413 | if (use_jinja) { |
| 414 | try { |
| 415 | common_chat_msg msg; |
| 416 | msg.role = "user"; |
| 417 | msg.content = "test"; |
| 418 | |
| 419 | auto tmpls = common_chat_templates_init(/* model= */ nullptr, tmpl); |
| 420 | |
| 421 | common_chat_templates_inputs inputs; |
| 422 | inputs.messages = {msg}; |
| 423 | |
| 424 | common_chat_templates_apply(tmpls.get(), inputs); |
| 425 | return true; |
| 426 | } catch (const std::exception & e) { |
| 427 | LOG_ERR("%s: failed to apply template: %s\n", __func__, e.what()); |
| 428 | return false; |
| 429 | } |
| 430 | } |
| 431 | llama_chat_message chat[] = {{"user", "test"}}; |
| 432 | const int res = llama_chat_apply_template(tmpl.c_str(), chat, 1, true, nullptr, 0); |
| 433 | return res >= 0; |
| 434 | } |
| 435 | |
| 436 | std::string common_chat_format_single( |
| 437 | const struct common_chat_templates * tmpls, |
no test coverage detected