AshAi.Evaluate.Choice (ash_ai v1.1.0)

Copy Markdown View Source

An evaluation answer selecting one option from a defined set.

The options come from one of two places:

  • the of constraint: an Ash.Type.Enum, or :atom with a one_of constraint. value is cast to that type and enum value descriptions become the criteria sent to the model.
  • criteria supplied per question through the questions option of AshAi.Actions.Evaluate. Without of, value is a string. With of, the runtime criteria must be a subset of its options, which is how options can depend on earlier answers (for example, the children of a taxonomy node).

Fields

  • value - the selected option
  • probabilities - every option mapped to its probability
  • confidence - how concentrated the distribution is, from 0 to 1

Example

action :department, AshAi.Evaluate.Choice do
  description "Which team should handle `ticket`?"
  constraints of: MyApp.Department
  argument :ticket, :string, allow_nil?: false

  run evaluate("typesafe:jev-latest")
end

Summary

Types

t()

@type t() :: %AshAi.Evaluate.Choice{
  confidence: float(),
  probabilities: %{required(term()) => float()},
  value: term()
}

Functions

handle_change?()

prepare_change?()