add warn on bad template

This commit is contained in:
Xuan Son Nguyen 2025-01-13 13:54:53 +01:00
parent 9d7d5f21f8
commit 5b1f710865

View file

@ -207,14 +207,17 @@ int main(int argc, char ** argv) {
}
// auto enable conversation mode if chat template is available
if (
params.conversation_mode == COMMON_CONVERSATION_MODE_AUTO
&& (!common_get_builtin_chat_template(model).empty() || !params.chat_template.empty())
) {
const bool has_chat_template = !common_get_builtin_chat_template(model).empty() || !params.chat_template.empty();
if (params.conversation_mode == COMMON_CONVERSATION_MODE_AUTO && has_chat_template) {
LOG_INF("%s: chat template is available, enabling conversation mode (disable it with -no-cnv)\n", __func__);
params.conversation_mode = COMMON_CONVERSATION_MODE_ENABLED;
}
// in case user force-activate conversation mode (via -cnv) without proper chat template, we show a warning
if (params.conversation_mode && !has_chat_template) {
LOG_WRN("%s: chat template is not available or is not supported. This may cause the model to output suboptimal responses\n", __func__);
}
// print chat template example in conversation mode
if (params.conversation_mode) {
if (params.enable_chat_template) {