Usage's cost shows comped runs at what they cost the provider, not $0
A run charged nothing at all (a comped workspace's) has no charge or covered amount in the ledger, only its provider cost, so flagon-io's panel read $0.00. Such runs now count at their provider cost.
2 files+8−60/2 viewed
| 92 | 92 | <> | |
| 93 | 93 | <dl className="mt-4 grid grid-cols-2 gap-2"> | |
| 94 | 94 | <Tile label="Tokens" value={compactTokens(usage.totalTokens)} /> | |
| 95 | − | <Tile label="Cost" value={usd(usage.costMicros / 1e6)} title="What these runs were charged" /> | |
| 95 | + | <Tile label="Cost" value={usd(usage.costMicros / 1e6)} title="What these runs cost, whoever paid" /> | |
| 96 | 96 | <Tile label="Active days" value={String(usage.activeDays)} hint={`of ${usage.days}`} /> | |
| 97 | 97 | <Tile label="From cache" value={share == null ? "—" : `${Math.round(share * 100)}%`} title="Prompt tokens read from the model's cache" /> | |
| 98 | 98 | </dl> |
| 170 | 170 | .await? | |
| 171 | 171 | .results::<DayRow>() | |
| 172 | 172 | }; | |
| 173 | − | // What the window's runs cost at g1t's price, whoever paid: what was | |
| 173 | + | // What the window's runs cost, whoever paid: at g1t's price, what was | |
| 174 | 174 | // left to pay plus what included usage, credit, the trial, the | |
| 175 | − | // open-source pool or a comp covered, so a comped workspace's runs | |
| 176 | − | // still show their cost. While g1t charges nothing, the provider's | |
| 177 | − | // cost. For one person, the runs whose sessions counted their tokens. | |
| 175 | + | // open-source pool or a comp covered; a run charged nothing at all | |
| 176 | + | // (comped, or while g1t charges nothing) at the provider's cost. | |
| 177 | + | // For one person, the runs whose sessions counted their tokens. | |
| 178 | 178 | let measure = if self.free { | |
| 179 | 179 | "COALESCE(l.cost_micros, 0)" | |
| 180 | 180 | } else { | |
| 181 | − | "(-l.amount_micros + l.credit_micros + l.trial_micros + l.oss_micros + l.given_micros)" | |
| 181 | + | "CASE WHEN (-l.amount_micros + l.credit_micros + l.trial_micros + l.oss_micros + l.given_micros) > 0 | |
| 182 | + | THEN (-l.amount_micros + l.credit_micros + l.trial_micros + l.oss_micros + l.given_micros) | |
| 183 | + | ELSE COALESCE(l.cost_micros, 0) END" | |
| 182 | 184 | }; | |
| 183 | 185 | let sessions = if person.is_some() { | |
| 184 | 186 | " AND r.session_id IN (SELECT session FROM token_usage WHERE workspace = ?1 AND person = ?3 AND day >= ?2)" |