hsa-app/internal/web/templates/ai.html
Jean-Michel Tremblay c715c8e0c0
All checks were successful
Build and Test / build-and-test (push) Successful in 37s
AI classifier correction notes + misread review (AI tab)
Add a global, temporal ai_notes list appended to the classifier prompt
(seeded once from no-PII defaults, documented in README), managed inline
on a new AI tab with a read-only view of the assembled prompt. Every
AI-run upload records the browser-round-tripped suggestion blob + model;
misreads are derived (final field != AI guess) and reviewed one by one
(image + per-field guess-vs-entered + notes-since), attributing which
note fixed each or closing unresolved. Update SPEC (new section 10),
DESIGN item 15, README, and changelog (0.0.3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 16:04:30 -04:00

49 lines
1.6 KiB
HTML

{{define "title"}}AI{{end}}
{{define "content"}}
<header>
<span><a href="/">← Add receipt</a></span>
<span><a href="/recent">Recent</a> · <a href="/tally">Tally</a> · <a href="/manage">Manage</a></span>
</header>
<h1>AI classifier</h1>
{{if .Error}}<div class="err">{{.Error}}</div>{{end}}
<h2>Correction notes</h2>
<p><small>Free-text rules appended to the classifier prompt to fix recurring misreads. Editing a note keeps the old version in history.</small></p>
{{range .Notes}}
<form class="row" method="post" action="/ai/notes/edit">
<input type="hidden" name="id" value="{{.ID}}">
<input type="text" name="text" value="{{.Text}}">
<button type="submit">Save</button>
<button type="submit" formaction="/ai/notes/delete" class="danger"></button>
</form>
{{end}}
<form class="row add" method="post" action="/ai/notes">
<input type="text" name="text" placeholder="New correction note">
<button type="submit">Add</button>
</form>
<h2>Review misreads {{if .Misses}}({{len .Misses}}){{end}}</h2>
{{if not .Misses}}
<p><small>No misreads to review — the AI matched what you submitted (or nothing has been classified yet).</small></p>
{{else}}
<ul class="recent">
{{range .Misses}}
<li>
<a class="amt" href="/ai/review/{{.ReceiptID}}">${{.Amount}}</a>
<span class="meta">{{.When}} · changed: {{.Fields}}</span>
<span class="when">{{.Model}}</span>
</li>
{{end}}
</ul>
{{end}}
<h2>Current prompt</h2>
{{if .Prompt}}
<details>
<summary>View the exact system prompt sent to the model</summary>
<pre class="prompt">{{.Prompt}}</pre>
</details>
{{else}}
<p><small>{{.PromptNote}}</small></p>
{{end}}
{{end}}