From 66e5e9c1ce69e273f83b460f35515bc271b03f27 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Fri, 13 Dec 2024 12:33:14 -0800 Subject: [PATCH] feat: Add percentage column to model token usage summary --- scripts/my_models.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/my_models.py b/scripts/my_models.py index e93484944..7e38b3d19 100755 --- a/scripts/my_models.py +++ b/scripts/my_models.py @@ -30,14 +30,18 @@ with open(analytics_path) as f: except json.JSONDecodeError: continue +# Calculate total for percentages +total_tokens = sum(model_stats.values()) + # Print results print("\nModel Token Usage Summary:") -print("-" * 60) -print(f"{'Model Name':<40} {'Total Tokens':>15}") -print("-" * 60) +print("-" * 80) +print(f"{'Model Name':<40} {'Total Tokens':>15} {'Percent':>10}") +print("-" * 80) for model, tokens in sorted(model_stats.items(), key=lambda x: x[1], reverse=True): - print(f"{model:<40} {tokens:>15,}") + percentage = (tokens / total_tokens) * 100 if total_tokens > 0 else 0 + print(f"{model:<40} {tokens:>15,} {percentage:>9.1f}%") -print("-" * 60) -print(f"{'TOTAL':<40} {sum(model_stats.values()):>15,}") +print("-" * 80) +print(f"{'TOTAL':<40} {total_tokens:>15,} {100:>9.1f}%")