Picks one of its options for an input — or abstains when none fits.
Get one from a model: EmbeddingModel.createDecider (every embedding
backend) or InferenceModel.createDecider (an engine that scores options;
none does in this release). A decider BORROWS its model and never closes
it.
abstract base: outside core it can be extended (by a base, final or
sealed class) but not implemented, so a member added here in a later
release reaches every subclass through this class instead of breaking it.
Extend it for a decider of your own or a test fake — final class FakeDecider extends Decider implementing capabilities, options,
isClosed, decide and close.
choose is core's (@nonVirtual): it checks the request against
capabilities and the cancel token, then calls decide. So every decider
refuses what it does not take the same way, and an option added to
choose later reaches decide as a new field of DeciderRequest instead
of breaking every subclass.
Experimental: the members may change in a minor release while the API settles.
- Annotations
-
- @experimental
Constructors
- Decider()
-
For subclasses.
const
Properties
- capabilities → DeciderCapabilities
-
What this decider can do. choose refuses a request that asks for
more, before decide runs.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether choose can no longer answer: close was called, or — for an
embedding decider — its model is closed and core serves none in its
place (a model
getActiveEmbedderdid not build). A decider on a model core replaced is not closed: its next choose takes the replacement.no setter -
options
→ List<
DeciderOption> -
The options, in the order they were given. Unmodifiable.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
choose(
DeciderInput input, {Iterable< String> ? among, int topK = 5, CancelToken? cancelToken}) → Future<DeciderAnswer> -
The option for
input, or an abstention. -
close(
) → Future< void> -
Marks this decider closed; choose fails afterwards, and a choose
still running fails with
DeciderCancelledException. Idempotent. The model the decider was created from stays open: it is borrowed. -
decide(
DeciderRequest request) → Future< DeciderAnswer> -
Answers
request, which choose has checked against capabilities: its candidates are known option ids, its input carries only modalities this decider takes, and its context andamongonly what it supports. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toArtifact(
) → Map< String, Object?> -
The fitted decider as a JSON-encodable map, to be stored and restored
later by the kind of model that created it (
EmbeddingModel.loadDeciderfor an embedding decider) instead of fitting again. Versioned; the format is documented at https://flutteredge.ai/docs/decisions. Throws StateError when an option's metadata is not JSON-encodable. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
chooseAll(
DeciderInput input, List< Decider> deciders, {int topK = 5, CancelToken? cancelToken}) → Future<List< DeciderAnswer> > -
Answers every one of
decidersfor the sameinput, in their order.