Skip to content

Commit 5b1f710

Browse files
committed
add warn on bad template
1 parent 9d7d5f2 commit 5b1f710

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

examples/main/main.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,17 @@ int main(int argc, char ** argv) {
207207
}
208208

209209
// auto enable conversation mode if chat template is available
210-
if (
211-
params.conversation_mode == COMMON_CONVERSATION_MODE_AUTO
212-
&& (!common_get_builtin_chat_template(model).empty() || !params.chat_template.empty())
213-
) {
210+
const bool has_chat_template = !common_get_builtin_chat_template(model).empty() || !params.chat_template.empty();
211+
if (params.conversation_mode == COMMON_CONVERSATION_MODE_AUTO && has_chat_template) {
214212
LOG_INF("%s: chat template is available, enabling conversation mode (disable it with -no-cnv)\n", __func__);
215213
params.conversation_mode = COMMON_CONVERSATION_MODE_ENABLED;
216214
}
217215

216+
// in case user force-activate conversation mode (via -cnv) without proper chat template, we show a warning
217+
if (params.conversation_mode && !has_chat_template) {
218+
LOG_WRN("%s: chat template is not available or is not supported. This may cause the model to output suboptimal responses\n", __func__);
219+
}
220+
218221
// print chat template example in conversation mode
219222
if (params.conversation_mode) {
220223
if (params.enable_chat_template) {

0 commit comments

Comments
 (0)