pub enum Unit {
Tokens,
Usd,
Wall,
Calls,
}Expand description
Which of a budget’s four limits is being talked about.
Variants§
Tokens
Tokens, prompt plus completion.
Usd
Spend, in micro-dollars.
Wall
Wall-clock time, in milliseconds.
Calls
Model calls.
Implementations§
Source§impl Unit
impl Unit
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The name BoundGraphError::BudgetExceeded
reports. These strings are API.
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
The unit a name refers to.
The inverse of name, so a unit that crossed a process boundary as a
string arrives back as the same unit.
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
This unit’s position in ALL.
Public because the runtime stores an amount per unit in a fixed array and needs the same ordering this crate uses — two orderings would be one too many.
Sourcepub fn render(self, amount: u64) -> String
pub fn render(self, amount: u64) -> String
How an amount in this unit should be written for a person.
The inverse of the normalisation Budget::amount applies, so a
diagnostic reports $0.50 rather than 500000 usd.
Money is shown to at least two places and never fewer, because $0.5
reads as a typo where $0.50 reads as an amount. Sub-cent precision is
kept where it exists — per-million token rates are quoted in millionths,
and rounding them away in a diagnostic about cost would be the wrong
place to lose them.