fix condition

This commit is contained in:
Xuan Son Nguyen 2024-12-31 15:00:21 +01:00
parent c6bd7a7aef
commit 450e47b2fb

View file

@ -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<char> 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) {