LlamaBridgeSession class

A loaded model session, returned by LlamaCppFlutter.loadModel.

Properties

hashCode int
The hash code for this object.
no setterinherited
id int
Native session identifier.
final
maxSequences int
Number of independent KV-cache sequences this session was loaded with (n_seq_max). 1 is the classic single-conversation session.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel() Future<void>
Requests cancellation of any in-flight generation for this session.
clearSequence(int sequenceId) Future<void>
Erases one sequence's KV cache and prompt ledger.
dispose() Future<void>
Frees the native model and context for this session.
dropStashedState(String key) Future<int>
Drops the stash entry under key; resolves to the bytes freed (0 when no entry existed).
generate(String prompt, {int maxTokens = 256, double temperature = 0.8, int? topK, double? topP, int? seed, List<String> stopSequences = const <String>[], List<Uint8List>? images, int sequenceId = 0, void onStats(LlamaGenerationStats)?}) Stream<String>
Generates text for prompt, yielding decoded tokens as they arrive.
loadState(String path, {int sequenceId = 0}) Future<int>
Restores KV-cache state previously written by saveState into sequenceId, replacing that sequence's current cache.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
restoreStashedState(String key, {int sequenceId = 0}) Future<int>
Restores stashed state saved under key into sequenceId, replacing that sequence's cache. The stash entry is kept until dropStashedState.
saveState(String path, {int sequenceId = 0}) Future<int>
Saves the session's KV-cache state to path.
setImageTokenBudget(int? imageTokenBudget) Future<void>
Changes the per-image vision token budget for subsequent image turns (see LlamaCppFlutter.loadModel's imageTokenBudget); null restores the model's metadata default.
stashState(String key, {int sequenceId = 0}) Future<({int bytes, int tokens})>
Copies one sequence's KV state into a native, in-memory stash under key — the fast path for swapping conversations: no disk write and no bytes crossing the platform channel.
stateSizeBytes({int sequenceId = 0}) Future<int>
Measures the byte size of one sequence's current state (KV cache plus bookkeeping) without writing it anywhere.
toString() String
A string representation of this object.
inherited

Operators

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