Lfm2StreamDecoder class

Turns the Stream<String> from LlamaCppFlutter.generate into a stream of ChatResponseUpdates for an M.E.AI chat client.

LFM2 has no reasoning channel, so output is two kinds of content:

  • Prose — ordinary answer text, emitted as TextContent.
  • Tool calls — the first <|tool_call_start|> marker flips the decoder into buffering mode: everything from the marker onward is accumulated and, when the stream ends, parsed into FunctionCallContent via Lfm2ChatTemplate.parse.

Text and tool calls are emitted in separate updates on purpose: FunctionInvokingChatClient suppresses any update that carries a function call, so combining them in one update would drop the prose.

Constructors

Lfm2StreamDecoder([Lfm2ChatTemplate template = const Lfm2ChatTemplate()])
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
template Lfm2ChatTemplate
final

Methods

decode(Stream<String> tokens) Stream<ChatResponseUpdate>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited