#[non_exhaustive]pub struct Receipt {
pub model: Option<String>,
pub usage: Usage,
pub cached: bool,
pub latency: Duration,
pub request_id: Option<String>,
}Expand description
The facts of one request: the model, the tokens, the cache, the time, and the request ID.
ask_with_receipt returns it next to the answers. An answer from the cache has the model of
the stored response, zero tokens, zero latency, and no request ID.
§Examples
use system2::prelude::*;
use system2::Usage;
let urgent = noul!("Is the ticket urgent?");
let (answer, receipt) = urgent.ask_with_receipt("The site is down.").await?;
let Usage { input_tokens, output_tokens, .. } = receipt.usage;
println!("{input_tokens} in, {output_tokens} out, {:?}", receipt.latency);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.model: Option<String>The version of the model that answered. A set with no questions has no model.
usage: UsageThe tokens of the request.
cached: booltrue if the answer came from the cache.
latency: DurationThe time from the first send to the last response, with the retries and their waits.
A wait for the limit of Client::max_concurrent_requests is not in it.
request_id: Option<String>The ID of the request, for TypeSafe support. Through OpenRouter, it is the generation ID.
Trait Implementations§
impl Eq for Receipt
impl StructuralPartialEq for Receipt
Auto Trait Implementations§
impl Forget for Receipt
impl Freeze for Receipt
impl Move for Receipt
impl RefUnwindSafe for Receipt
impl Send for Receipt
impl Sync for Receipt
impl Unpin for Receipt
impl UnsafeUnpin for Receipt
impl UnwindSafe for Receipt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more