(
stats_text: Text,
report_state: Any,
*,
live: bool = False,
)
| 274 | |
| 275 | |
| 276 | def _build_llm_usage_stats( |
| 277 | stats_text: Text, |
| 278 | report_state: Any, |
| 279 | *, |
| 280 | live: bool = False, |
| 281 | ) -> None: |
| 282 | usage = _llm_usage(report_state) |
| 283 | if not usage or _int_stat(usage, "requests") <= 0: |
| 284 | stats_text.append("\n") |
| 285 | stats_text.append("Cost ", style="dim") |
| 286 | stats_text.append("$0.0000 ", style="#fbbf24") |
| 287 | stats_text.append("· ", style="dim white") |
| 288 | stats_text.append("Tokens ", style="dim") |
| 289 | stats_text.append("0", style="white") |
| 290 | return |
| 291 | |
| 292 | input_tokens = _int_stat(usage, "input_tokens") |
| 293 | output_tokens = _int_stat(usage, "output_tokens") |
| 294 | cached_tokens = _detail_value(usage, "input_tokens_details", "cached_tokens") |
| 295 | cost = _float_stat(usage, "cost") |
| 296 | |
| 297 | stats_text.append("\n") |
| 298 | stats_text.append("Input Tokens ", style="dim") |
| 299 | stats_text.append(format_token_count(input_tokens), style="white") |
| 300 | |
| 301 | if live or cached_tokens > 0: |
| 302 | stats_text.append(" · ", style="dim white") |
| 303 | stats_text.append("Cached Tokens ", style="dim") |
| 304 | stats_text.append(format_token_count(cached_tokens), style="white") |
| 305 | |
| 306 | separator = "\n" if live else " · " |
| 307 | stats_text.append(separator, style="dim white") |
| 308 | stats_text.append("Output Tokens ", style="dim") |
| 309 | stats_text.append(format_token_count(output_tokens), style="white") |
| 310 | |
| 311 | if live or cost > 0: |
| 312 | stats_text.append(" · ", style="dim white") |
| 313 | stats_text.append("Cost ", style="dim") |
| 314 | stats_text.append(f"${cost:.4f}", style="#fbbf24") |
| 315 | |
| 316 | |
| 317 | def build_final_stats_text(report_state: Any) -> Text: |
no test coverage detected