pub struct ChoiceAnswer<O> { /* private fields */ }Expand description
The answer to a Choice: the probability of each option.
Each method that gives probabilities gives pairs of a value and its probability. A method
that borrows gives (&O, f64), and a method that consumes the answer gives (O, f64). It
serializes as {"most_likely": name, "confidence": c, "options": [name, …], "probabilities": [p, …]}, so a value needs no Serialize.
Implementations§
Source§impl<O> ChoiceAnswer<O>
impl<O> ChoiceAnswer<O>
Sourcepub fn into_question(self) -> Choice<O>
pub fn into_question(self) -> Choice<O>
Returns the question of the answer, with its values, so that code can ask it again.
Sourcepub fn most_likely(&self) -> &O
pub fn most_likely(&self) -> &O
Returns the value of the option that the API chose.
Sourcepub fn into_most_likely(self) -> O
pub fn into_most_likely(self) -> O
Returns the value of the option that the API chose, owned.
Sourcepub fn top(&self, n: usize) -> impl Iterator<Item = (&O, f64)>
pub fn top(&self, n: usize) -> impl Iterator<Item = (&O, f64)>
Returns the n most likely options, from the highest probability.
The option that the API chose comes first, also when another option has an equal probability. The other options with equal probabilities keep the order of the question.
Sourcepub fn confidence(&self) -> f64
pub fn confidence(&self) -> f64
Returns the confidence of the API in its choice, from 0 to 1.
Sourcepub fn probabilities(&self) -> impl ExactSizeIterator<Item = (&O, f64)>
pub fn probabilities(&self) -> impl ExactSizeIterator<Item = (&O, f64)>
Returns each option and its probability, in the order of the question.
Sourcepub fn into_probabilities(self) -> Vec<(O, f64)>
pub fn into_probabilities(self) -> Vec<(O, f64)>
Returns each option and its probability, owned, in the order of the question.