renderOmniChat function
Renders the official LFM3-Omni template for messages whose content parts
may be {'type': 'image'}, {'type': 'audio'} (also input_audio and
audio_url) and {'type': 'video'}, each as one span-wrapped
placeholder. A video's soundtrack is not a separate part here: it is
declared in the video's OmniVideoLayout. The reply opens with
<think></think>, then the mode's marker: none for text,
<|audio_start|> for speech and <|mixed_start|> for interleaved.
Implementation
String renderOmniChat(
List<Map<String, Object?>> messages, {
AudioReplyMode mode = AudioReplyMode.text,
List<Map<String, Object?>>? tools,
}) =>
renderChat(
[
for (final message in messages)
{
...message,
if (message.containsKey('content'))
'content': _content(
message['content'],
toolItems: message['role'] == 'tool',
),
},
],
tools: tools,
enableThinking: false,
) +
switch (mode) {
AudioReplyMode.text => '',
AudioReplyMode.audio => '<|audio_start|>',
AudioReplyMode.mixed => '<|mixed_start|>',
};