MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / common_chat_verify_template

Function common_chat_verify_template

smallthinker/common/chat.cpp:412–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412bool 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
436std::string common_chat_format_single(
437 const struct common_chat_templates * tmpls,

Callers 1

common_params_parse_exFunction · 0.85

Calls 6

getMethod · 0.45
whatMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected