File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -283,15 +283,23 @@ int main(int argc, char ** argv) {
283283
284284 if (!prompt.empty ()) {
285285 // format the system prompt (will use template default if empty)
286- prompt = chat_add_and_format (" system" , prompt);
286+ chat_add_and_format (" system" , prompt);
287287 }
288288
289289 if (!params.prompt .empty ()) {
290290 // format and append the user prompt
291- prompt += chat_add_and_format (" user" , params.prompt );
291+ chat_add_and_format (" user" , params.prompt );
292292 } else {
293293 waiting_for_first_input = true ;
294294 }
295+
296+ if (!prompt.empty () || !params.prompt .empty ()) {
297+ common_chat_templates_inputs inputs;
298+ inputs.messages = chat_msgs;
299+ inputs.add_generation_prompt = !params.prompt .empty ();
300+
301+ prompt = common_chat_templates_apply (chat_templates.get (), inputs).prompt ;
302+ }
295303 } else {
296304 // otherwise use the prompt as is
297305 prompt = params.prompt ;
You can’t perform that action at this time.
0 commit comments