DecisionScript

The script of a ScriptedDecisionModel: each call adds the decision for one request, in order.

ScriptedDecisionModel {
chooses("refund") // picks an option
chooses("technical", confidence = 0.3) // picks one, and is not sure
yes()
no()
scores(2.0) // rates on a scale
fails("API error 429: slow down") // a call that throws
decides { request -> DecisionResponse(request.questions.mapValues { Answer.YesNo(1.0) }) }
}

Functions

Link copied to clipboard
fun chooses(option: String, confidence: Double = 1.0, usage: TokenUsage? = null)

The model picks option.

Link copied to clipboard
fun decides(decision: suspend (DecisionRequest) -> DecisionResponse)

The model answers with what decision returns for the request, for a request with several questions or a decision that depends on what was asked.

Link copied to clipboard
fun fails(message: String)

The call to the model fails with a DecisionModelException that has message.

fun fails(failure: Throwable)

The call to the model throws failure.

Link copied to clipboard
fun no(probability: Double = 0.0, usage: TokenUsage? = null)

The model answers no.

Link copied to clipboard
fun scores(score: Double, confidence: Double = 1.0, usage: TokenUsage? = null)

The model rates the state with score. Levels are counted from 0, the lowest.

Link copied to clipboard
fun yes(probability: Double = 1.0, usage: TokenUsage? = null)

The model answers yes.