(r: RouteRecord)
| 247 | |
| 248 | |
| 249 | def _cache_savings(r: RouteRecord) -> float: |
| 250 | pricing = _get_stats_pricing().get(r.model) |
| 251 | if pricing is None: |
| 252 | return 0.0 |
| 253 | cached_input_price = pricing.cached_input_price if pricing.cached_input_price is not None else pricing.input_price |
| 254 | cache_write_price = pricing.cache_write_price if pricing.cache_write_price is not None else pricing.input_price |
| 255 | read_delta = ((pricing.input_price - cached_input_price) * r.cache_read_input_tokens) / 1_000_000 |
| 256 | write_delta = ((pricing.input_price - cache_write_price) * r.cache_write_input_tokens) / 1_000_000 |
| 257 | return read_delta + write_delta |
| 258 | |
| 259 | |
| 260 | def _compaction_savings(r: RouteRecord) -> float: |
no test coverage detected