Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/templates/admin/usage_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h2 id="report-totals-heading">Filtered totals</h2>
<div class="metric"><span class="metric-label">Prompt tokens</span><strong>{{ summary.prompt_tokens }}</strong></div>
<div class="metric"><span class="metric-label">Completion tokens</span><strong>{{ summary.completion_tokens }}</strong></div>
<div class="metric"><span class="metric-label">Total tokens</span><strong>{{ summary.total_tokens }}</strong></div>
<div class="metric"><span class="metric-label">Estimated cost</span><strong>{{ currency.symbol }}{{ '%.6f'|format(summary.cost_estimate) }}</strong></div>
<div class="metric"><span class="metric-label" title="Estimated from the configured price table; not a provider-confirmed charge.">Estimated cost</span><strong title="Estimated from the configured price table; not a provider-confirmed charge." aria-label="Estimated cost, {{ currency.code }}">{{ currency.symbol }}{{ '%.6f'|format(summary.cost_estimate) }}</strong></div>
</div>
<p class="sidebar-empty">
{{ summary.priced_records }} of {{ summary['count'] }} rows have a known price.
Expand All @@ -97,7 +97,7 @@ <h2 id="report-rows-heading">Usage rows</h2>
<th scope="col">Model</th>
<th scope="col">Status</th>
<th scope="col">Tokens</th>
<th scope="col">Estimated cost</th>
<th scope="col" title="Estimated from the configured price table; not a provider-confirmed charge.">Estimated cost</th>
</tr>
</thead>
<tbody>
Expand All @@ -111,7 +111,7 @@ <h2 id="report-rows-heading">Usage rows</h2>
<td>{{ row.model or 'unknown' }}</td>
<td>{{ row.status or 'unknown' }}</td>
<td>{{ row.total_tokens or 0 }}</td>
<td>{% if row.cost_estimate is none %}&mdash;{% else %}{{ currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}{% endif %}</td>
<td title="Estimated from the configured price table; not a provider-confirmed charge.">{% if row.cost_estimate is none %}&mdash;{% else %}{{ currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}{% endif %}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
10 changes: 5 additions & 5 deletions app/templates/billing/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h2 id="totals-heading">Totals</h2>
<div class="metric"><span class="metric-label">Prompt tokens</span><strong>{{ dashboard.totals.prompt_tokens }}</strong></div>
<div class="metric"><span class="metric-label">Completion tokens</span><strong>{{ dashboard.totals.completion_tokens }}</strong></div>
<div class="metric"><span class="metric-label">Operations</span><strong>{{ dashboard.totals['count'] }}</strong></div>
<div class="metric"><span class="metric-label">Estimated cost</span><strong>{{ dashboard.currency.symbol }}{{ '%.6f'|format(dashboard.totals.cost_estimate) }}</strong></div>
<div class="metric"><span class="metric-label" title="Estimated from the configured price table; not a provider-confirmed charge.">Estimated cost</span><strong title="Estimated from the configured price table; not a provider-confirmed charge." aria-label="Estimated cost, {{ dashboard.currency.code }}">{{ dashboard.currency.symbol }}{{ '%.6f'|format(dashboard.totals.cost_estimate) }}</strong></div>
</div>
<p class="sidebar-empty">
{{ dashboard.totals.priced_records }} of {{ dashboard.totals['count'] }} operations have a known price.
Expand All @@ -81,7 +81,7 @@ <h2 id="{{ title|lower|replace(' ', '-') }}-heading">{{ title }}</h2>
<th scope="col">Prompt</th>
<th scope="col">Completion</th>
<th scope="col">Total tokens</th>
<th scope="col">Estimated cost</th>
<th scope="col" title="Estimated from the configured price table; not a provider-confirmed charge.">Estimated cost</th>
</tr>
</thead>
<tbody>
Expand All @@ -92,7 +92,7 @@ <h2 id="{{ title|lower|replace(' ', '-') }}-heading">{{ title }}</h2>
<td>{{ row.prompt_tokens }}</td>
<td>{{ row.completion_tokens }}</td>
<td>{{ row.total_tokens }}</td>
<td>{{ dashboard.currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}</td>
<td title="Estimated from the configured price table; not a provider-confirmed charge.">{{ dashboard.currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -118,7 +118,7 @@ <h2 id="daily-heading">Daily time series</h2>
<th scope="col">Prompt</th>
<th scope="col">Completion</th>
<th scope="col">Total tokens</th>
<th scope="col">Estimated cost</th>
<th scope="col" title="Estimated from the configured price table; not a provider-confirmed charge.">Estimated cost</th>
</tr>
</thead>
<tbody>
Expand All @@ -129,7 +129,7 @@ <h2 id="daily-heading">Daily time series</h2>
<td>{{ row.prompt_tokens }}</td>
<td>{{ row.completion_tokens }}</td>
<td>{{ row.total_tokens }}</td>
<td>{{ dashboard.currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}</td>
<td title="Estimated from the configured price table; not a provider-confirmed charge.">{{ dashboard.currency.symbol }}{{ '%.6f'|format(row.cost_estimate) }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
14 changes: 14 additions & 0 deletions tests/test_admin_usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,17 @@ def test_filters_persist_in_pagination_links(self, client, login):
html = response.get_data(as_text=True)
assert "source=chat" in html
assert f"user_id={user.id}" in html

def test_cost_values_are_explicitly_labelled_as_estimates(self, client, login):
user = _user("cost-reader", "cost-reader@example.com")
_admin()
_record(user)
login(email="admin@example.com")

response = client.get("/admin/usage/report")

assert response.status_code == 200
html = response.get_data(as_text=True)
assert 'title="Estimated from the configured price table; not a provider-confirmed charge."' in html
assert 'aria-label="Estimated cost, USD"' in html
assert "<th scope=\"col\" title=\"Estimated from the configured price table; not a provider-confirmed charge.\">Estimated cost</th>" in html
Loading