ActiveEmbedderParams class
The runtime knobs a caller passes to getActiveEmbedder, captured so a
second call can tell whether the cached singleton still satisfies it.
Its own record rather than ActiveModelParams, which carries ten inference
knobs and no identity at all: maxTokens is required there and compared
first, and normalized() would apply vision and audio defaults to a model
that has no encoders. (The maxTokens: 0 filler in the web shell is on
RuntimeConfig, not on that class — no shell builds an ActiveModelParams
for an embedder.)
The empirical reason, which is the same one that justified the neighbour: the reuse check was written three times and disagreed. Mobile compared the spec NAME, so reinstalling a same-named embedder to a new path was invisible; web kept its own record with both paths nullable; desktop compared the name too. All three call this now.
Only three values decide what an embedder IS. Everything else a caller can
vary is per-call — taskType is an argument to generateEmbedding, not a
property of the model.
- Annotations
Constructors
- ActiveEmbedderParams({required String modelPath, String? tokenizerPath, PreferredBackend? preferredBackend})
- The requested backend is normalised HERE rather than in a method a caller has to remember, so activeBackend always means "the backend this embedder was built for" and there is no way to compare un-normalised values by accident.
Properties
- activeBackend → PreferredBackend
-
What the embedder actually runs on, which is CPU whatever was asked — ON
NATIVE. The web shell builds this object too, and there it still holds
cpuwhileEmbeddingModel.activeBackendis null and the runtime may be on WebGPU. That is harmless because this field is a cache KEY: it is a constant, so it can never trigger a rebuild. Read the model's ownactiveBackendfor the answer; do not read this one.final - hashCode → int
-
The same three fields firstDifference compares, because
==delegates to it — so a fourth field goes in BOTH places, not "both" of==and firstDifference. And if firstDifference ever normalises its inputs, as ActiveModelParams.firstDifference does, hash the normalised values too, or two objects would compare equal with different hashes and break everyMapandSetholding them. This one is safe today only because it normalises in the constructor instead.no setteroverride - modelPath → String
-
The file the compiled model opens. Compared instead of the spec NAME,
which is what the shells compared before: reinstalling a same-named model
to a new path was invisible to them.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tokenizerPath → String?
-
Resolved by core and baked into the embedding worker at spawn.
final
Methods
-
firstDifference(
ActiveEmbedderParams other) → String? -
Name of the first field that differs from
other, or null when the cached embedder can be reused. No normalisation step to forget: the constructor already did it. -
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 -
Delegates to firstDifference rather than repeating its three
comparisons: two copies of one rule is how the copies stop agreeing, and a
fourth field would otherwise have to be remembered in both.
override
Static Methods
-
isIgnoredBackend(
PreferredBackend? requested) → bool -
True when
requestedasks for something other than what an embedder actually uses, so a caller can be told once that it changed nothing.