An embedding model, as returned by FlutterEdgeAi.getActiveEmbedder().
Core builds every model an app receives: it hosts the engine's pass, checks
each request before it is sent, and owns the close. Extend this class only
for test fakes — final class FakeEmbedder extends EmbeddingModel (add
with CloseNotifier from engine.dart for close listeners) implementing
dimension, isClosed, embed, addCloseListener and close.
base: outside core it can be extended (by a base, final or sealed
class) but not implemented, so implements EmbeddingModel — and therefore
a mockito/mocktail mock of it — does not compile. A member added here in a
later release then reaches every fake through its superclass instead of
breaking it.
Constructors
Properties
- activeBackend → PreferredBackend?
-
Backend this embedder actually uses, when known — the counterpart of
InferenceModel.activeBackend, and the answer togetActiveEmbedder(preferredBackend:)that survives a release build.no setter - dimension → int
-
Length of every vector this model returns. Known when the model is
returned: every engine loads eagerly.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether close has been called, or the model can no longer be used
because its worker exited. Abstract since 2.3.0 (2.2 defaulted it to
false).
no setter
- maxInputTokens → int?
-
Longest input in tokens — task prefix, BOS and EOS included — as the
loaded engine can accept it, including any configured context or batch
limit. Null when the engine cannot establish a limit. Longer inputs fail with
EmbeddingInputTooLongException; they are never truncated. Null does not mean unlimited.no setter -
modalities
→ Set<
EmbeddingModality> -
What this model accepts: the media declared at load (and confirmed by
the engine), plus text when the model has a text tower. A request
carrying anything else fails with
EmbeddingModalityNotLoadedException.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addCloseListener(
void listener()) → void - Register a callback fired once when this model is closed — by close, or because its worker exited. Core's embedder cache evicts through it.
-
close(
) → Future< void> -
Closes the model. Idempotent. Requests not yet started fail with
EmbedderClosedException; the one in flight finishes; then the engine is released. Waits as long as that takes — nothing is ever killed, since a killed worker never frees its native model. -
createDecider(
{required List< DeciderOption> options, DeciderMethod method = DeciderMethod.centroid, EmbeddingDeciderCalibration calibration = const EmbeddingDeciderCalibration.crossFit(), String? embedderId, CancelToken? cancelToken, void onProgress(int done, int total)?}) → Future<Decider> -
A decider that picks one of
optionsfor an input, or abstains. -
embed(
EmbeddingInput input, {required TaskType taskType}) → Future< List< double> > -
The vector for
input. -
embedAll(
List< EmbeddingInput> inputs, {required TaskType taskType, CancelToken? cancelToken}) → Future<List< List< >double> > -
The vectors for
inputs, in input order. -
loadDecider(
Map< String, Object?> artifact, {String? embedderId}) → Future<Decider> -
The decider stored by
Decider.toArtifact(), on this model, without embedding anything. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited