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:
VasanthandClaude Opus 5.5 committed 2026-10-16 15:23:52 +05:30
1 parent 8951ac05a5
commit 9dcdd8f572
11 files changed
+392 -6

No files matched your search

+26 -5
View File
@@ -1,6 +1,6 @@
---
name: rpa-dashboard-ai
description: Builds a working dashboard for an RPA bot or service that uses AI (an LLM or OCR extraction call). It has everything from rpa-dashboard-no-ai (sidebar, top bar with dark toggle and status dot, KPI cards, batch donut, run panel with steps and live log, report table with search and export) plus confidence bands, a review split pane (source document beside the extracted fields, band filters, draft edits, Verify) and an approve gate the server enforces. Web path is React + Vite + Tailwind with a sample-data server stub. Use when the user asks for an "AI RPA dashboard", an "extraction dashboard", an "LLM/OCR review dashboard", or any RPA/bot dashboard in a project that calls an LLM or OCR to extract fields. Needs rpa-dashboard-no-ai installed next to it.
description: Builds a working dashboard for an RPA bot or service that uses AI (an LLM or OCR extraction call). It has everything from rpa-dashboard-no-ai (sidebar, top bar with dark toggle and status dot, KPI cards, batch donut, run panel with steps and live log, report table with search and export) plus confidence bands, a review split pane (source document beside the extracted fields, band filters, draft edits, Verify), an approve gate the server enforces, and a cost/ROI page (tokens and cost per run, total and monthly spend, priced coverage, an against-doing-it-by-hand panel). Web path is React + Vite + Tailwind with a sample-data server stub. Use when the user asks for an "AI RPA dashboard", an "extraction dashboard", an "LLM/OCR review dashboard", or any RPA/bot dashboard in a project that calls an LLM or OCR to extract fields. Needs rpa-dashboard-no-ai installed next to it.
---
# RPA dashboard (AI)
@@ -11,7 +11,8 @@ means `../rpa-dashboard-no-ai/templates/`.
| File | What it is |
|---|---|
| `templates/web/` | The React + Vite + Tailwind starter: shell, KPI, donut, run panel, report, **band legend, review split pane, approve gate**, sample data. |
| `templates/web/` | The React + Vite + Tailwind starter: shell, KPI, donut, run panel, report, **band legend, review split pane, approve gate, cost page**, sample data. |
| `templates/web/pricing.py` | The pricing table (with its source and as-of date) and `cost_for_call`. The backend imports it. |
| `templates/web/server_stub.py` | Sample-data backend for runs, review rows and the approve gate. Standard library only. |
| `templates/web/bands.py` | The band cut points and rules. The one source of truth: the backend imports it. |
| `templates/contract.md` | The AI contract: runs, review rows, endpoints and the gate. Extends `<no-ai>contract.md`. |
@@ -31,7 +32,8 @@ Before asking anything:
`<no-ai>frontend.md` section 1.
- **AI call:** find the LLM or OCR extraction (for example `genai`, `openai`,
`anthropic`, Textract or Tesseract calls): which fields it returns, which are
mandatory, and whether it returns per-word scores.
mandatory, and whether it returns per-word scores. Note the provider, the model
names, and whether the response's token usage (input, output, thinking) is kept.
- **Bot or backend:** the entry point, what it prints, and any web framework
(FastAPI, Flask, Django).
@@ -63,9 +65,17 @@ uses PyQt, choose desktop and say so.
## 5. Ask which optional sections to build
Always built: the no-AI shell and sections, plus the band legend, the review split
pane and the approve gate. Ask which extras to add (choose any, or none):
**checkpoint tracker**, **admin/roles screen**, **login page**. Build only the
pane, the approve gate and the cost page. Ask which extras to add (choose any, or none):
**checkpoint tracker**, **admin/roles screen**, **login page**, **model picker** (choose
the model per batch), **retry on another model** (for failed runs). Build only the
chosen ones at their `OPTIONAL:` markers, and delete the markers.
- **Model picker:** a `<select>` filled from `GET /models` (the pricing table's keys), at
the marker in `Cost.tsx` or next to the Run button; the chosen model goes with the
batch's start action. Remember the last choice per user.
- **Retry on another model:** on a `failed` run, at the marker in `Review.tsx`: a model
`<select>` (from `GET /models`, defaulting to the run's own model) and a Retry button
that sends `POST /runs/{job_id}/retry {model}`, then polls the run as usual.
Both need the endpoints in `templates/contract.md`; add them to the backend (and the stub).
## 6. Build (web)
@@ -103,6 +113,14 @@ review rows and the gate.
mandatory)`. The approve endpoint must refuse (409 with `detail`) while any flagged
field is unverified: the page never decides that. For the shell, set
`SAMPLE_DATA = false` and serve the no-AI endpoints too.
- **Cost page:** copy `pricing.py` next to the backend. Fill `PRICING` with the rates of
the models the project really calls, from the provider's pricing page, and set
`PRICING_SOURCE` and `PRICING_AS_OF`. If you can't read the rates, ask the user for
them. The backend stores each run's token usage and serves `GET /roi`, pricing each run
with `cost_for_call`. A run with no recorded usage gets `null`, never 0. If the
extraction doesn't keep token usage yet, wire it to (for example Gemini's
`usage_metadata`, OpenAI's and Anthropic's `usage`). In sample mode, replace the stub's
`ROI_RUNS` models with the project's models.
- Never invent fields, model names or prices the project doesn't have.
## 8. Verify
@@ -119,6 +137,9 @@ Open the page and check, in light, dark (the toggle) and a window 820px wide or
- on Review: the band legend counts and the caveat, band filters, a typed edit marked
unsaved until Save, a refused Approve while flagged fields are unverified, and
"page X of Y" on a running document;
- on Cost: the coverage pill, total and this month's spend, the month table, a run
marked "not priced", the pricing source and as-of date, and the by-hand figure
changing when an assumption is edited;
- no `{{` is left and the console shows no script errors.
If you can't run npm here, say so and give the user these commands. Finish by