Skip to content
1 min read · 209 words

Interface: LiteRtStreamAccumulator

Defined in: src/batteries/llm/litert_lm/helpers.ts:643

A streaming accumulator over LiteRT ReadableStream<Message> chunks.

Remarks

Each chunk is a partial LiteRtMessage. The @litert-lm/core v0.13.1 JS runtime is text-in / text-out: it emits content only and does NOT populate tool_calls or channels on output (those wire fields exist for feeding history back IN). Tool calls and reasoning come out as raw text inside content, in the model family's own format — the adapter parses them out after the stream drains via the shared tool-call / reasoning parser layer.

So the accumulator collects assistant content text only, handling BOTH delivery conventions — incremental deltas (append) and full-accumulated snapshots (replace) — by detecting whether the incoming value extends the running buffer (startsWith) or is a fresh fragment. It also tolerates content arriving as a MessageContentItem[] by concatenating the text items.

Methods

content()

ts
content(): string;

Defined in: src/batteries/llm/litert_lm/helpers.ts:647

Final assembled content text.

Returns

string


feed()

ts
feed(chunk: Message): {
  contentDelta: string;
};

Defined in: src/batteries/llm/litert_lm/helpers.ts:645

Feed one chunk; returns the newly-appended content text (for incremental reporting).

Parameters

ParameterType
chunkMessage

Returns

ts
{
  contentDelta: string;
}
NameTypeDefined in
contentDeltastringsrc/batteries/llm/litert_lm/helpers.ts:645