diff --git a/backend/igny8_core/templates/admin/reports/ai_cost_analysis.html b/backend/igny8_core/templates/admin/reports/ai_cost_analysis.html new file mode 100644 index 00000000..62980e45 --- /dev/null +++ b/backend/igny8_core/templates/admin/reports/ai_cost_analysis.html @@ -0,0 +1,349 @@ +{% extends "admin/base_site.html" %} +{% load static %} + +{% block content %} +
Comprehensive cost breakdown with model pricing and predictions
+${{ total_cost|floatformat:2 }}
+{{ total_calls }} API calls
+${{ avg_cost_per_call|floatformat:4 }}
+${{ projected_monthly|floatformat:2 }}
+Based on last 7 days
+{{ efficiency_score }}%
+Successful cost ratio
+${{ failed_cost|floatformat:2 }}
+{{ wasted_percentage|floatformat:1 }}% of total
+| Model | +Total Cost | +% of Total | +API Calls | +Avg Cost | +Total Tokens | +Cost/1K Tokens | +
|---|---|---|---|---|---|---|
| + + {{ model.model|default:"Unknown" }} + + | ++ ${{ model.total_cost|floatformat:2 }} + | +
+ {{ model.cost_percentage|floatformat:1 }}%
+
+
+
+ |
+ + {{ model.call_count }} + | ++ ${{ model.avg_cost|floatformat:4 }} + | ++ {{ model.total_tokens|floatformat:0 }} + | ++ ${{ model.cost_per_1k_tokens|floatformat:4 }} + | +
| Account | +Cost | +Calls | +
|---|---|---|
| + + {{ account.account__name|default:"Unknown" }} + + | ++ ${{ account.total_cost|floatformat:2 }} + | ++ {{ account.call_count }} + | +
| Function | +Cost | +Calls | +
|---|---|---|
| + {{ func.function|default:"Unknown" }} + | ++ ${{ func.total_cost|floatformat:2 }} + | ++ {{ func.call_count }} + | +
The following API calls had unusually high costs (>3x average):
+| Model | +Function | +Account | +Cost | +Tokens | +Date | +
|---|---|---|---|---|---|
| {{ anomaly.model }} | +{{ anomaly.function }} | +{{ anomaly.account__name }} | +${{ anomaly.cost|floatformat:2 }} | +{{ anomaly.tokens|floatformat:0 }} | +{{ anomaly.created_at|date:"M d, H:i" }} | +
| Hour of Day | +Total Cost | +API Calls | +Activity Level | +
|---|---|---|---|
| + {{ hour.hour|floatformat:0 }}:00 - {{ hour.hour|add:1|floatformat:0 }}:00 + | ++ ${{ hour.total_cost|floatformat:2 }} + | ++ {{ hour.call_count }} + | +
+
+ {% widthratio hour.total_cost total_cost 100 as percentage %}
+
+
+ |
+
Multi-dimensional token consumption analytics
+{{ total_tokens|floatformat:0 }}
+{{ total_calls }} API calls
+{{ avg_tokens_per_call|floatformat:0 }}
+{{ success_rate }}%
+{{ successful_tokens|floatformat:0 }} tokens
+${{ total_cost|floatformat:2 }}
+${{ cost_per_1k_tokens|floatformat:4 }} per 1K
+| Model | +Tokens | +Calls | +Cost | +
|---|---|---|---|
| {{ item.model|default:"Unknown" }} | +{{ item.total_tokens|floatformat:0 }} | +{{ item.call_count }} | +${{ item.total_cost|floatformat:2 }} | +
| Function | +Tokens | +Calls | +
|---|---|---|
| {{ item.function|default:"Unknown" }} | +{{ item.total_tokens|floatformat:0 }} | +{{ item.call_count }} | +
| Account | +Total Tokens | +API Calls | +Total Cost | +Avg Tokens | +
|---|---|---|---|---|
| + + {{ consumer.account__name|default:"Unknown Account" }} + + | +{{ consumer.total_tokens|floatformat:0 }} | +{{ consumer.call_count }} | +${{ consumer.total_cost|floatformat:2 }} | ++ {% widthratio consumer.total_tokens consumer.call_count 1 %} + | +
{{ successful_tokens|floatformat:0 }}
+{{ wasted_tokens|floatformat:0 }}
+From failed requests
++ {% for hour in hourly_usage %} + {% if forloop.first or hour.token_count > hourly_usage.0.token_count %} + {{ hour.hour|floatformat:0 }}:00 + {% endif %} + {% endfor %} +
+Most active hour
+