hashbrown

decisionResource

Decides about an input by asking a model closed questions defined by a decidable schema, and exposes the typed answer with its metadata as signals.

Requires provideHashbrown; creating the resource without it throws.

The decision runtime is recreated when the system option changes: the old request is aborted and value and meta reset to null before the new decision arrives. Input changes trigger a new decision. Must be called in an injection context; the in-flight request is aborted when the context is destroyed, after which the signals keep their last values (so isLoading() may stay true) and never update again.

API

declare function decisionResource<
  S extends  DecidableSchema ,
>(
  options:  DecisionResourceOptions <S>,
):  DecisionResourceRef <S>;
decisionResource
@paramoptions:

The decision options.

@typeS
DecidableSchema

Examples

const decision = decisionResource({
  schema: s.object('Decision', {
    intent: s.enumeration('Intent', ['filter', 'chat']),
  }),
  input: query,
});