common : better align to the updated official gemma4 template (#21704)

This commit is contained in:
Aldehir Rojas
2026-04-10 16:12:53 -05:00
committed by GitHub
parent 05b3caaa48
commit 3fc65063d9
3 changed files with 136 additions and 50 deletions
+6 -1
View File
@@ -1916,7 +1916,12 @@ std::optional<common_chat_params> common_chat_try_specialized_template(
// Gemma4 format detection
if (src.find("'<|tool_call>call:'") != std::string::npos) {
workaround::convert_tool_responses_gemma4(params.messages);
if (src.find("{#- OpenAI Chat Completions:") == std::string::npos) {
// apply workarounds if using the older gemma4 templates
LOG_WRN("%s: detected an outdated gemma4 chat template, applying compatibility workarounds. "
"Consider updating to the official template.\n", __func__);
workaround::convert_tool_responses_gemma4(params.messages);
}
return common_chat_params_init_gemma4(tmpl, params);
}