diff --git a/common/common.cpp b/common/common.cpp index a757faf5f..7c5b810ec 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1512,7 +1512,18 @@ std::string llama_detokenize(llama_context * ctx, const std::vector bool llama_chat_verify_template(const std::string & tmpl, bool use_jinja) { llama_chat_message chat[] = {{"user", "test"}}; - int res = llama_chat_apply_template(nullptr, tmpl.c_str(), chat, 1, true, nullptr, 0, use_jinja); + int res = llama_chat_apply_template( + nullptr, + tmpl.c_str(), + chat, + 1, + /* add_ass= */ true, + /* buffer= */ nullptr, + /* length= */ 0, + use_jinja, + /* tools= */ nullptr, + "", + ""); return res >= 0; } diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 872dec790..16bcdeda4 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -659,10 +659,10 @@ struct server_context { return true; } - bool validate_model_chat_template() const { + bool validate_model_chat_template(bool use_jinja) const { llama_chat_message chat[] = {{"user", "test"}}; - const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0); + const int res = llama_chat_apply_template(model, nullptr, chat, 1, true, nullptr, 0, use_jinja); return res > 0; } @@ -3183,7 +3183,7 @@ int main(int argc, char ** argv) { // if a custom chat template is not supplied, we will use the one that comes with the model (if any) if (params.chat_template.empty()) { - if (!ctx_server.validate_model_chat_template()) { + if (!ctx_server.validate_model_chat_template(params.use_jinja)) { LOG_WRN("%s: The chat template that comes with this model is not yet supported, falling back to chatml. This may cause the model to output suboptimal responses\n", __func__); params.chat_template = "chatml"; }