hashbrown

useDecision

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

The decision runtime is recreated only when the serialized schema, or the system, debounceTime, retries or optionOrder options change. A changed transport (including a new inline function each render) applies from the next request and never recreates the runtime. Input changes trigger a new decision.

API

export declare function useDecision<
  S extends  DecidableSchema ,
>(
  options:  UseDecisionOptions <S>,
):  UseDecisionResult <S>;
useDecision
@paramoptions:

The decision options.

@typeS
DecidableSchema

Examples

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