Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3432,7 +3432,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
params.default_template_kwargs[item.key()] = item.value().dump();
}
}
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_CHAT_TEMPLATE_KWARGS"));
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_COMPLETION, LLAMA_EXAMPLE_CLI}).set_env("LLAMA_ARG_CHAT_TEMPLATE_KWARGS"));
add_opt(common_arg(
{"-to", "--timeout"}, "N",
string_format("server read/write timeout in seconds (default: %d)", params.timeout_read),
Expand Down
6 changes: 5 additions & 1 deletion tools/completion/completion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ int llama_completion(int argc, char ** argv) {

// note: the time for chat template initialization is not negligible:
auto chat_templates = common_chat_templates_init(model, params.chat_template);
const bool template_supports_thinking = params.use_jinja && common_chat_templates_support_enable_thinking(chat_templates.get());

@percontation percontation Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW: this template_supports_thinking logic (plus its use below for enable_reasoning) is copied directly from server-context.cpp, for consistency with how other llama.cpp tools process these args.


// start measuring performance timings from here
llama_perf_context_reset(ctx);
Expand Down Expand Up @@ -303,9 +304,12 @@ int llama_completion(int argc, char ** argv) {

if (!params.system_prompt.empty() || !params.prompt.empty()) {
common_chat_templates_inputs inputs;
inputs.use_jinja = g_params->use_jinja;
inputs.messages = chat_msgs;
inputs.add_generation_prompt = !params.prompt.empty();
inputs.use_jinja = params.use_jinja;
inputs.reasoning_format = params.reasoning_format;
inputs.enable_thinking = params.enable_reasoning != 0 && template_supports_thinking;
inputs.chat_template_kwargs = params.default_template_kwargs;
inputs.force_pure_content = params.force_pure_content_parser;

prompt = common_chat_templates_apply(chat_templates.get(), inputs).prompt;
Expand Down