WebConversationHandle class final
A ConversationHandle over one @litert-lm/core conversation.
- Implemented types
Constructors
-
WebConversationHandle(JsLiteRtLmConversation _conversation, {required bool enableThinking, required Map<
String, Object?> extraContext, required void onGeneration(), required Future<JsLiteRtLmConversation> rebuild(List<Object?> replay), List<Object?> preface = const [], bool vision = false, int? maxImages, int maxTokens = 0, bool audio = false, ToolCallReader toolCallsOf = nativeToolCalls, void onClose()?, LiteRtLmPageLock? pageLock})
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 setteroverride
- 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 setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toolCallsOf → ToolCallReader
-
Reads a stopped reply's tool calls (createWebEngine's
toolCallsOf).final
Methods
-
cancelGeneration(
) → void -
Marks every live turn stopped and stops the one streaming, if it was
sent. With nothing in flight the runtime is not asked: a cancel there
changes nothing (0.18.0 and 0.19.0, measured).
override
-
chat(
String text, {List< Uint8List> ? imageBytes, Uint8List? audioBytes, bool enableThinking = false}) → Stream<String> -
override
-
chatRaw(
String text, {List< Uint8List> ? imageBytes, Uint8List? audioBytes, bool enableThinking = false}) → Stream<String> -
override
-
chatRawMessage(
String messageJson, {bool enableThinking = false, SendOptions options = SendOptions.none}) → 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 roletoolfor the model to read it as the answer to its call.override -
close(
) → Future< void> -
Stops the generation in flight and every turn queued behind it, waits
for its JS stream to end, and deletes the JS conversation. A stream
that does not end within drainTimeout poisons the page lock
(LiteRtLmPageLock.poisonFor): the module may still be suspended in
it, so nothing else may enter, and the returned future fails with that
error. The conversation is then left to the page.
override
-
getNativeBenchmark(
) → NativeBenchmark? -
LiteRT-LM's benchmark record of this conversation, turn by turn; null
when native gives none.
override
-
getSessionMetrics(
) → BenchmarkInfo -
Refused on the web: the runtime reports a conversation's benchmark
only in its benchmark mode (
benchmarkEnabled), which litertlm_dart does not turn on there.override -
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. WithpartialReplynull 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).override -
tokenCount(
String text) → Future< int?> -
Null on the web: the runtime counts a conversation's tokens
(
getTokenCount()), but has no tokenizer for a text.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- drainTimeout ↔ Duration
-
How long a stopped generation may take to end before the page lock is
poisoned; a test shortens it.
getter/setter pair