Applies the model's own chat template, as llama.cpp does for a chat
request, and returns the resulting text. With prefill, the text ends with
the beginning of the assistant's turn, which is the context
llm_continue(), llm_next_token(), and llm_score() use.
Arguments
- config
An
llm_config()for provider"llamacpp".- messages
Chat messages, as in
call_llm().- prefill
Text the assistant's turn starts with.
- thinking
For reasoning models such as Qwen3. With
FALSEthe template closes the model's reasoning block before the reply, soprefillopens the answer; withTRUEthe turn is left open andprefillis placed where the model would begin, so it can also open the reasoning (for Qwen3, start it with"<think>\n"). By default the configuration'sthinkingsetting, or elseFALSE.
Examples
if (llm_local_ready("smollm2-135m")) {
cfg <- llm_config("llamacpp", "smollm2-135m")
llm_local_start("smollm2-135m", threads = 2)
cat(llm_render_template(cfg, "Name a color.", prefill = "My answer is"))
llm_local_stop()
}