From 5b1f71086589e2e1c3d18e2c0bf0faf09974c52d Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Mon, 13 Jan 2025 13:54:53 +0100 Subject: [PATCH] add warn on bad template --- examples/main/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 7148e3fc3..fb5d6bcb1 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -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) {