File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,13 +175,17 @@ impl LLM {
175175 // Use the model's embedded chat template when llama.cpp can detect it.
176176 // Falls back to hardcoded Gemma format when detection fails (e.g. Gemma 4
177177 // until llama-cpp-sys picks up the upstream Gemma 4 template detection fix).
178- let llm_input = self . model
178+ let llm_input = match self . model
179179 . chat_template ( None )
180180 . ok ( )
181181 . and_then ( |tmpl| self . model . apply_chat_template ( & tmpl, & messages, true ) . ok ( ) )
182- . unwrap_or_else ( || format ! (
183- "<start_of_turn>user\n {system}\n \n {user}<end_of_turn>\n <start_of_turn>model\n "
184- ) ) ;
182+ {
183+ Some ( s) => s,
184+ None => {
185+ eprintln ! ( "ltengine: apply_chat_template failed: using hardcoded Gemma format" ) ;
186+ format ! ( "<start_of_turn>user\n {system}\n \n {user}<end_of_turn>\n <start_of_turn>model\n " )
187+ }
188+ } ;
185189
186190 // BOS is not added by apply_chat_template — str_to_token handles it.
187191 let tokens_list = self . model
You can’t perform that action at this time.
0 commit comments