1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use Duration;
/// 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
///
/// ```no_run
/// use system2::prelude::*;
/// use system2::Usage;
///
/// # async fn run() -> system2::Result<()> {
/// 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);
/// # Ok(())
/// # }
/// ```
/// The tokens of a request, or the total of a client.
///
/// [`Client::usage`](crate::Client::usage) gives the total of a client and its clones.