ChatDecisionModel
A DecisionModel that asks a ChatModel, so that choose, isYes, score and decisionEdge work with the model an app already has: Claude, OpenAI, Gemini, Ollama, or any other.
val decider = ChatDecisionModel(AnthropicChatModel(client, apiKey = key, model = "claude-haiku-5-5"))
decisionEdge(from = START, model = decider, instructions = "What does the customer want?", routes = routes, minConfidence = 0.6, fallback = escalate) { it.body }Each call to decide is one call to the chat model, however many questions the request has. The model is asked how likely it finds each option, and the option it finds most likely is the answer.
The probabilities are the model's own estimate. A chat model is not built to measure them, so they are rougher than those of a decision model such as Jev (
telar-typesafe), and aconfidenceof 0.9 is a guess, not a measurement. Try limits such asminConfidenceon your own data before you rely on them.confidenceis computed as Jev computes it: how far the probability of the most likely option is above an even split,(highest - 1/n) / (1 - 1/n)fornoptions. It is 0 when every option is as likely and 1 when the model is sure, so a limit means the same with both models.A small, fast model is usually enough. Picking an option is easier than writing an answer.
A failed call to the chat model, an answer cut off at its output limit, and an answer that is not the JSON it was asked for throw a DecisionModelException; for a failed call, the ChatModelException is its cause.
Parameters
the chat model that decides.
Functions
Asks which constant of the enum Option fits state. The model sees the names of the constants, and for each one the text that describe returns. Read the constant from the answer with value.
Returns an answer for each question of request, under the name the question has there.
Asks a yes/no question about state. Read Answer.YesNo.isYes, or compare Answer.YesNo.probability with a line of your own.