Skip to content

Commit 4b42937

Browse files
committed
mtmd-cli : allow using --jinja
1 parent 19a5a3e commit 4b42937

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

common/arg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
34353435
[](common_params & params) {
34363436
params.use_jinja = true;
34373437
}
3438-
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_MAIN}).set_env("LLAMA_ARG_JINJA"));
3438+
).set_examples({LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_MAIN, LLAMA_EXAMPLE_MTMD}).set_env("LLAMA_ARG_JINJA"));
34393439
add_opt(common_arg(
34403440
{"--reasoning-format"}, "FORMAT",
34413441
"controls whether thought tags are allowed and/or extracted from the response, and in which format they're returned; one of:\n"

tools/mtmd/mtmd-cli.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ struct mtmd_cli_context {
8585

8686
int n_threads = 1;
8787
llama_pos n_past = 0;
88+
bool use_jinja = false;
8889

8990
mtmd_cli_context(common_params & params) : llama_init(common_init_from_params(params)) {
9091
model = llama_init.model.get();
@@ -108,6 +109,7 @@ struct mtmd_cli_context {
108109
}
109110

110111
tmpls = common_chat_templates_init(model, params.chat_template);
112+
use_jinja = params.use_jinja;
111113
LOG_INF("%s: chat template example:\n%s\n", __func__, common_chat_format_example(tmpls.get(), params.use_jinja, params.default_template_kwargs).c_str());
112114

113115
init_vision_context(params);
@@ -200,7 +202,7 @@ static int eval_message(mtmd_cli_context & ctx, common_chat_msg & msg, bool add_
200202
common_chat_templates_inputs tmpl_inputs;
201203
tmpl_inputs.messages = {msg};
202204
tmpl_inputs.add_generation_prompt = true;
203-
tmpl_inputs.use_jinja = false; // jinja is buggy here
205+
tmpl_inputs.use_jinja = ctx.use_jinja;
204206
auto formatted_chat = common_chat_templates_apply(ctx.tmpls.get(), tmpl_inputs);
205207
LOG_DBG("formatted_chat.prompt: %s\n", formatted_chat.prompt.c_str());
206208

0 commit comments

Comments
 (0)