diff --git a/common/common.cpp b/common/common.cpp index ba596923d..fe923fce6 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1618,13 +1618,12 @@ std::string common_get_builtin_chat_template(const struct llama_model * model) { static const char * template_key = "tokenizer.chat_template"; // call with NULL buffer to get the total size of the string int32_t res = llama_model_meta_val_str(model, template_key, NULL, 0); - if (res < 2) { - return ""; - } else { + if (res > 0) { std::vector model_template(res + 1, 0); llama_model_meta_val_str(model, template_key, model_template.data(), model_template.size()); return std::string(model_template.data(), model_template.size() - 1); } + return ""; } bool common_chat_verify_template(const std::string & tmpl) {