AI cost/ROI page: pricing table, cost per call, Cost tab, ROI endpoint
- templates/web/pricing.py: pricing table with source and as-of date; cost_for_call
(input rate + (output + thinking) at output rate, long-context above threshold;
unknown model raises naming the known models).
- Cost tab: coverage pill, total/this-month/tokens tiles, month-by-month table,
per-run tokens and cost ("not priced", never $0), by-hand panel with editable
assumptions labelled as such.
- Contract: RoiRun and GET /roi; optional GET /models and POST /runs/{id}/retry.
- SKILL.md: cost page wiring, model picker and retry-on-other-model as optional sections.
- Tests: test_pricing.py self-check, page_check_ai/test_ai_cost.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8951ac05a5
commit
9dcdd8f572
11 files changed
+392
-6
No files matched your search
@@ -23,6 +23,19 @@ export type ReviewRow = {
|
||||
corrected_value: string | null
|
||||
}
|
||||
|
||||
/** One run on the cost page. total_cost is null when the run recorded no token usage (unpriced). */
|
||||
export type RoiRun = {
|
||||
job_id: string
|
||||
document: string
|
||||
created_at: string // ISO, UTC
|
||||
model: string
|
||||
input_tokens: number | null
|
||||
output_tokens: number | null
|
||||
thinking_tokens: number | null
|
||||
total_cost: number | null // USD
|
||||
}
|
||||
export type Pricing = { source: string; as_of: string }
|
||||
|
||||
export const BUSY: RunStatus[] = ['queued', 'running'] // polled every 1.5s while in one of these
|
||||
|
||||
/** Legend order, label, and the colour token. Band colours are semantic: never on buttons or headings. */
|
||||
@@ -53,5 +66,6 @@ export const ai = {
|
||||
req<ReviewRow>(`/review/${rowId}`, { method: 'PATCH', body: JSON.stringify(body) }),
|
||||
verifyRemaining: (id: string) => req<{ verified: number }>(`/runs/${id}/verify-remaining`, { method: 'POST' }),
|
||||
approve: (id: string) => req<{ ok: boolean }>(`/runs/${id}/approve`, { method: 'POST' }),
|
||||
roi: () => req<{ runs: RoiRun[]; pricing: Pricing }>('/roi'),
|
||||
documentUrl: (id: string) => `${API_BASE}/runs/${id}/document`,
|
||||
}
|
||||
Reference in new issue
Block a user