Class ChoiceAnswer

java.lang.Object
org.springframework.ai.decision.answer.ChoiceAnswer
All Implemented Interfaces:
DecisionAnswer

public final class ChoiceAnswer extends Object implements DecisionAnswer
The answer to a ChoiceQuestion: the selected option, the probability of each option when the provider reports them, and the provider's confidence when it reports one. Probabilities are what the model assigned to each option. Confidence is the provider's own estimate and is not a probability of correctness.
Since:
2.1.0
Author:
Thomas Vitale, Christian Tzolov
  • Method Details

    • builder

      public static ChoiceAnswer.Builder builder()
    • getValue

      public String getValue()
      The selected option.
    • getProbability

      public @Nullable Double getProbability()
      The probability of the selected option, or null when not reported.
    • getProbability

      public @Nullable Double getProbability(String option)
      The probability of the given option, or null when not reported.
    • getProbabilities

      public Map<String,Double> getProbabilities()
      The probability of each option, or an empty map when the provider doesn't report them.
    • getRankedOptions

      public List<String> getRankedOptions()
      The options from the most to the least likely, or an empty list when probabilities weren't reported. Ties keep the reported order.
    • getConfidence

      public @Nullable Double getConfidence()
      The provider's confidence in the selected option, or null when the provider doesn't report one.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object