Skip to main content

Answers

Struct Answers 

Source
pub struct Answers { /* private fields */ }
Expand description

The answers to one request, with accessors that fail loudly on the wrong id or type.

Reaching for noul("team") when team was a choice is a programming mistake, not a runtime condition, and the error says which id and which types rather than handing back a default.

Implementations§

Source§

impl Answers

Source

pub fn model(&self) -> &str

The model that answered, after alias resolution.

Source

pub fn usage(&self) -> Usage

Source

pub fn timing_ms(&self) -> u64

Source

pub fn get(&self, id: &str) -> Result<&Answer, Error>

The raw answer for id.

Source

pub fn noul(&self, id: &str) -> Result<f64, Error>

Probability that the answer to id is yes.

Source

pub fn choice(&self, id: &str) -> Result<&str, Error>

The winning option for id.

Source

pub fn index(&self, id: &str) -> Result<usize, Error>

The winning option’s position in the request’s options, 0-based.

Source

pub fn score(&self, id: &str) -> Result<u8, Error>

The winning level for id, 1-based.

Source

pub fn expected_score(&self, id: &str) -> Result<f64, Error>

The probability-weighted mean level for id.

Source

pub fn legend(&self, id: &str) -> Result<&str, Error>

The legend entry the winning level carries.

Source

pub fn confidence(&self, id: &str) -> Result<f64, Error>

How peaked the distribution behind id was, in 0.0..=1.0. A noul has none, as in JEV: its probability is already the whole answer.

Source

pub fn truncated(&self, id: &str) -> Result<bool, Error>

Whether some label for id fell outside the host’s reporting window, which makes its probability an upper bound rather than an observation.

Source

pub fn label_mass(&self, id: &str) -> Result<f64, Error>

How much of the model’s first-token probability fell on the offered labels for id, in 0.0..=1.0. The probabilities are normalised over the labels alone, so this is what tells an answer the model gave from one read off letters it was not going to write.

Source

pub fn truncated_labels(&self, id: &str) -> Result<&[String], Error>

The labels for id whose logprob is an upper bound rather than an observation. Empty unless Answers::truncated.

Source

pub fn ids(&self) -> impl Iterator<Item = &str>

Source

pub fn into_inner(self) -> SystemOneResponse

Trait Implementations§

Source§

impl Clone for Answers

Source§

fn clone(&self) -> Answers

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Answers

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<SystemOneResponse> for Answers

Wrap a response that was obtained some other way — read from a file, replayed from a log, or parsed by a caller doing its own transport. The accessors are the useful part of this type, and they should not be reachable only by going over the network.

Source§

fn from(response: SystemOneResponse) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more