Skip to content

Commit 247e420

Browse files
authored
fix -sys + -p
1 parent 31a3039 commit 247e420

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

examples/main/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)