applyChatTemplate abstract method
Applies the model's chat template to the given messages.
If customTemplate is provided, even empty, it will be used instead of
the model's default template; otherwise ModelParams.chatTemplate from
the load is used when non-empty on llama.cpp, and even when empty on
native LiteRT-LM.
The WebGPU backend cannot render either and throws
LlamaUnsupportedException. LiteRT-LM Web's original constructor returns
the last message's text, ignores its load template and an empty custom
override, and rejects a non-empty override with UnsupportedError.
Its explicit text-history factory accepts one user text message here and
rejects overrides with LlamaUnsupportedException; use high-level chat
for ordered structured history on that path.
LlamaEngine.chatTemplate renders both on every backend.
Returns the formatted prompt string.
Implementation
Future<String> applyChatTemplate(
int modelHandle,
List<Map<String, dynamic>> messages, {
String? customTemplate,
bool addAssistant = true,
});