Interface DecisionModel
- All Known Implementing Classes:
TypeSafeDecisionModel
Typical uses are classification, routing, gating and grading: for example, deciding which team should handle a support ticket, whether a message is spam, or how urgent an incident is. All questions of a request are answered against the same input in a single call.
The supported question types are YesNoQuestion (a yes/no
judgment answered with a probability), ChoiceQuestion (one option
out of a named set) and ScaleQuestion (a position on an ordered
scale). Implementations may support additional question types.
Probabilities in the answers must be derived from the model's output distribution, since thresholds and
escalation logic in applications rely on them. An implementation that cannot provide them for choice or scale
answers leaves probabilities() empty instead of inventing values.
- Since:
- 1.21.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault DecisionResponsedecide(DecisionRequest request) Answers the questions of the given request.default CompletableFuture<DecisionResponse> decideAsync(DecisionRequest request) Non-blocking counterpart ofdecide(DecisionRequest).default DecisionRequestParametersThe model's default per-call parameters, applied to every request and overridden by any parameters set on the request itself.doDecide(DecisionRequest request) The provider hook behinddecide(DecisionRequest).default CompletableFuture<DecisionResponse> doDecideAsync(DecisionRequest request) The provider hook behinddecideAsync(DecisionRequest).default List<DecisionModelListener> The listeners notified of every request, response and error of this model.default StringThe name of the model used when a request does not specify one, ornullif there is none.default ModelProviderprovider()The provider of this model.
-
Method Details
-
decide
Answers the questions of the given request.This applies the model's
default parameters, notifies thelistenersand dispatches todoDecide(DecisionRequest). The response is checked against the request: a missing answer, an answer of the wrong type, a choice of an option that was not offered or a scale answer outside the levels throws anInvalidDecisionResponseException.- Parameters:
request- the input, the questions and the per-call parameters.- Returns:
- one answer per question, keyed by question name.
-
doDecide
The provider hook behinddecide(DecisionRequest).- Parameters:
request- the request, with the default parameters already applied.- Returns:
- one answer per question, keyed by question name.
-
decideAsync
Non-blocking counterpart ofdecide(DecisionRequest).This applies the model's
default parameters, notifies thelistenersand dispatches todoDecideAsync(DecisionRequest). The response is checked against the request, as indecide(DecisionRequest).- Parameters:
request- the input, the questions and the per-call parameters.- Returns:
- a
CompletableFutureof the answers, keyed by question name.
-
doDecideAsync
The provider hook behinddecideAsync(DecisionRequest). The default returns a failed future: a model that is not genuinely asynchronous does not pretend to be.- Parameters:
request- the request, with the default parameters already applied.- Returns:
- a
CompletableFutureof the answers, keyed by question name.
-
defaultRequestParameters
The model's default per-call parameters, applied to every request and overridden by any parameters set on the request itself. The default isDecisionRequestParameters.EMPTY. -
listeners
The listeners notified of every request, response and error of this model. -
provider
The provider of this model. -
modelName
The name of the model used when a request does not specify one, ornullif there is none.
-