diff --git a/examples/server/utils.hpp b/examples/server/utils.hpp index c47ed3e47..335ec79f6 100644 --- a/examples/server/utils.hpp +++ b/examples/server/utils.hpp @@ -341,9 +341,9 @@ static std::string llama_get_chat_template(const struct llama_model * model) { if (res < 0) { return ""; } else { - std::vector model_template(res, 0); + std::vector model_template(res + 1, 0); llama_model_meta_val_str(model, template_key.c_str(), model_template.data(), model_template.size()); - return std::string(model_template.data(), model_template.size()); + return std::string(model_template.data(), model_template.size() - 1); } }