MultiSessionMobileInferenceModelSession class

A concurrent MediaPipe .task session opened via MobileInferenceModel.openSession. Independent of the legacy singleton MobileInferenceModelSession: it routes every call through the session-scoped *ForSession pigeon methods keyed by sessionId, so N of these can be live at once (MediaPipe holds N real LlmInferenceSession).

Generation is serialized across all sessions by the model's shared _generationMutex — concurrent contexts, serialized inference, identical to the .litertlm FFI path. Because only one session generates at a time, the single flutter_gemma_stream EventChannel is unambiguous; this session demuxes by filtering events whose sessionId matches its own.

Inheritance

Constructors

MultiSessionMobileInferenceModelSession({required int sessionId, required ModelType modelType, required ModelFileType fileType, required bool supportImage, required bool supportAudio, required Mutex generationMutex, required VoidCallback onClose, String? systemInstruction})

Properties

fileType ModelFileType
final
generationMutex → Mutex
final
hashCode int
The hash code for this object.
no setterinherited
modelType ModelType
final
onClose VoidCallback
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionId int
final
supportAudio bool
final
supportImage bool
final
systemInstruction String?
final

Methods

addQueryChunk(Message message) Future<void>
override
close() Future<void>
override
getResponse({Message? message}) Future<String>
override
getResponseAsync({Message? message}) Stream<String>
override
getSessionMetrics() SessionMetrics
Get session metrics including token usage and performance stats.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sizeInTokens(String text) Future<int>
override
stopGeneration() Future<void>
override
toString() String
A string representation of this object.
inherited

Operators

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