| 48 | # ============================================================ |
| 49 | |
| 50 | class TokenUsage(BaseModel): |
| 51 | input_tokens: int = 0 |
| 52 | output_tokens: int = 0 |
| 53 | cache_creation_input_tokens: int = 0 |
| 54 | cache_read_input_tokens: int = 0 |
| 55 | |
| 56 | def total_tokens(self) -> int: |
| 57 | """源码: usage.rs:81-86""" |
| 58 | return ( |
| 59 | self.input_tokens |
| 60 | + self.output_tokens |
| 61 | + self.cache_creation_input_tokens |
| 62 | + self.cache_read_input_tokens |
| 63 | ) |
| 64 | |
| 65 | |
| 66 | # ============================================================ |