ConversationHandle class abstract

Per-conversation operations a session needs from the FFI layer.

LiteRtLmConversationHandle is the real implementation backed by a native LiteRtLmConversation*. Tests inject a fake implementing this interface so FfiInferenceModelSession orchestration (query buffering, raw-response capture, Gemma 4 tool-call extraction) can be exercised on the host VM with no native engine.

Implementers

Constructors

ConversationHandle()

Properties

hashCode → int
The hash code for this object.
no setterinherited
lastTurnCode → int?
The absl status code native's last send ended with (§23's record): non-zero only for NativeLastTurnEnd.failed and NativeLastTurnEnd.contextFull; null when lastTurnEnd is.
no setter
lastTurnEnd → NativeLastTurnEnd?
How native's last send on this conversation ended (§23's record, read when the send ended), or null before one has ended here.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelGeneration() → void
chat(String text, {List<Uint8List>? imageBytes, Uint8List? audioBytes, bool enableThinking}) → Stream<String>
chatRaw(String text, {List<Uint8List>? imageBytes, Uint8List? audioBytes, bool enableThinking}) → Stream<String>
chatRawMessage(String messageJson, {bool enableThinking, SendOptions options}) → Stream<String>
Streams raw SDK JSON for a prebuilt message. This is how tool results go back: chatRaw always sends role user, and a tool result has to be role tool for the model to read it as the answer to its call.
close() → void
getSessionMetrics() → BenchmarkInfo
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rewindStoppedTurn(Map<String, Object?>? partialReply) → Future<StoppedTurnRewind>
Makes the conversation answer again after cancelGeneration stopped its last turn: rewinds to before that turn, then puts the turn back — the message exactly as it was sent, media included, followed by partialReply — without generating, so the model keeps the exchange. With partialReply null the turn is taken out instead: rewound to before its message, with nothing put back (a turn stopped before it produced anything, or one whose input did not fit).
tokenCount(String text) → Future<int?>
Token count for text from the model's own tokenizer, or null when it cannot be obtained (no engine, native call failed). Callers must handle null rather than assume a number — this feeds context budgeting, and the four-chars-per-token estimate it replaced undercounts Chinese by more than half (measured 0.44x on gemma-4-E2B-it) while looking authoritative.
toString() → String
A string representation of this object.
inherited

Operators

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