cli : Don't clear system prompt when using '/clear' (#20067)

* Enhance /clear command to include system prompt

Add system prompt to messages when clearing chat history.

* Use lambda
This commit is contained in:
Roj234
2026-03-06 06:41:11 +01:00
committed by GitHub
parent 6c97bffd65
commit f7db3f3789
+11 -6
View File
@@ -382,12 +382,15 @@ int main(int argc, char ** argv) {
modalities += ", audio"; modalities += ", audio";
} }
if (!params.system_prompt.empty()) { auto add_system_prompt = [&]() {
ctx_cli.messages.push_back({ if (!params.system_prompt.empty()) {
{"role", "system"}, ctx_cli.messages.push_back({
{"content", params.system_prompt} {"role", "system"},
}); {"content", params.system_prompt}
} });
}
};
add_system_prompt();
console::log("\n"); console::log("\n");
console::log("%s\n", LLAMA_ASCII_LOGO); console::log("%s\n", LLAMA_ASCII_LOGO);
@@ -477,6 +480,8 @@ int main(int argc, char ** argv) {
} }
} else if (string_starts_with(buffer, "/clear")) { } else if (string_starts_with(buffer, "/clear")) {
ctx_cli.messages.clear(); ctx_cli.messages.clear();
add_system_prompt();
ctx_cli.input_files.clear(); ctx_cli.input_files.clear();
console::log("Chat history cleared.\n"); console::log("Chat history cleared.\n");
continue; continue;