Skip to main content

//clika-runtime/io.clika.runtime/Tokenizer/applyChatTemplate

applyChatTemplate

[common]
fun applyChatTemplate(messages: String, addGenerationPrompt: Boolean = true): String

Render chat messages (a JSON array of {"role", "content"} turns, as text) into a prompt with the model's chat template; addGenerationPrompt appends the assistant-turn priming. A tokenizer with no template, malformed messages or a render error fails typed.

[common]
fun applyChatTemplate(inputs: ChatTemplateInputs, options: ChatTemplateOptions? = null): String

Render with the full input set and, when given, per-render options.