TypeSafe.Answer.Choice (typesafe_ai v0.1.1)

Copy Markdown View Source

The answer to a question built with TypeSafe.choice/2.

  • :choice is the selected string label from the question's criteria.
  • :probabilities maps every criterion label to a number from 0 to 1.
  • :confidence is a number from 0 to 1 supplied by the service and derived from the distribution. It is distinct from the selected label's probability.

These values are model outputs, not a measured guarantee of correctness. Choose routing thresholds using examples from your application.

Given a response containing a question named "team":

%TypeSafe.Answer.Choice{choice: team, probabilities: probabilities} =
  response.answers["team"]

selected_probability = Map.fetch!(probabilities, team)

Summary

Types

t()

A string label and its complete probability distribution and confidence.

Types

t()

@type t() :: %TypeSafe.Answer.Choice{
  choice: String.t(),
  confidence: number(),
  probabilities: %{required(String.t()) => number()}
}

A string label and its complete probability distribution and confidence.