Record Class ChoiceAnswer
java.lang.Object
java.lang.Record
org.springframework.ai.systemone.api.response.ChoiceAnswer
- Record Components:
value- the selected option labelprobabilities- the probability of each option, keyed by labelconfidence- how concentrated the distribution is, between0and1
- All Implemented Interfaces:
Answer
public record ChoiceAnswer(String value, Map<String,Double> probabilities, double confidence)
extends Record
implements Answer
The answer to a
Choice: the selected label, the probability of every option and
a confidence statistic computed from how concentrated that distribution is. A flat
distribution means the options were not well separated for this state.- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Constructor Summary
ConstructorsConstructorDescriptionChoiceAnswer(String value, Map<String, Double> probabilities, double confidence) Creates an instance of aChoiceAnswerrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theconfidencerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.optionsAbove(double threshold) Returns the options whose probability is at leastthreshold, most likely first.Returns the value of theprobabilitiesrecord component.doubleprobabilityOf(String option) final StringtoString()Returns a string representation of this record class.type()value()Returns the value of thevaluerecord component.
-
Constructor Details
-
ChoiceAnswer
Creates an instance of aChoiceAnswerrecord class.- Parameters:
value- the value for thevaluerecord componentprobabilities- the value for theprobabilitiesrecord componentconfidence- the value for theconfidencerecord component
-
-
Method Details
-
type
-
probabilityOf
- Parameters:
option- the option label- Returns:
- the probability assigned to the option, or
0when it is not present
-
optionsAbove
Returns the options whose probability is at leastthreshold, most likely first. Useful for the fan-out pattern, where a close split is explored along several branches instead of committing to the top option.- Parameters:
threshold- the inclusive lower probability bound- Returns:
- the matching option labels, ordered by descending probability
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
probabilities
Returns the value of theprobabilitiesrecord component.- Returns:
- the value of the
probabilitiesrecord component
-
confidence
public double confidence()Returns the value of theconfidencerecord component.- Returns:
- the value of the
confidencerecord component
-