LiteRtLmWebSession class

Session-side accumulator + async iterator pump for @litert-lm/core.

Mirrors FfiInferenceModelSession (lib/core/ffi/ffi_inference_model.dart) 1:1 — same buffering of query chunks, same Gemma 4 raw-JSON-accumulating branch, same with RawSdkResponseSession mixin so InferenceChat reads lastRawResponse and extracts tool_calls via the shared SdkResponseParser. The only platform-specific bit is that here the JS AsyncIterator is driven manually via LiteRtLmAsyncIter.next rather than a Dart Stream from native FFI.

Inheritance
Mixed-in types

Constructors

LiteRtLmWebSession({required LiteRtLmConversation conversation, required ModelType modelType, required ModelFileType fileType, required bool supportImage, required bool supportAudio, required Mutex generationMutex, required VoidCallback onClose})

Properties

conversation → LiteRtLmConversation
final
fileType → ModelFileType
final
generationMutex → Mutex
Shared across all sessions of the owning model — serializes generation (concurrent contexts, serialized inference). Acquired for the whole duration of a getResponse(Async) call.
final
hashCode → int
The hash code for this object.
no setterinherited
lastRawResponse → String?
Most recent raw SDK JSON. Null until first generation completes.
no setteroverride
modelType → ModelType
final
onClose → VoidCallback
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportAudio → bool
final
supportImage → bool
final

Methods

addQueryChunk(Message message) → Future<void>
override
close() → Future<void>
override
getResponse() → Future<String>
override
getResponseAsync() → Stream<String>
override
getSessionMetrics() → SessionMetrics
LiteRT-LM web does not surface benchmark info; return empty metrics.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sizeInTokens(String text) → Future<int>
Approximate token count — matches FfiInferenceModelSession.sizeInTokens. The @litert-lm/core early-preview API does not expose a tokenizer.
override
stopGeneration() → Future<void>
Stops the in-flight generation both locally (closes the Dart stream) and upstream (calls conversation.cancel() per the @litert-lm/core JS API). The cancel call is wrapped in try/catch because the early-preview API may throw if no generation is in flight.
override
toString() → String
A string representation of this object.
inherited

Operators

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