hsa-app/internal/web/templates/ai.html

61 lines
2 KiB
HTML
Raw Normal View History

{{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="note" method="post" action="/ai/notes/edit">
<input type="hidden" name="id" value="{{.ID}}">
<textarea name="text" rows="2">{{.Text}}</textarea>
<div class="note-actions">
<button type="submit">Save</button>
<button type="submit" formaction="/ai/notes/delete" class="danger">Delete</button>
</div>
</form>
{{end}}
<form class="note add" method="post" action="/ai/notes">
<textarea name="text" rows="2" placeholder="New correction note…"></textarea>
<div class="note-actions"><button type="submit">Add note</button></div>
</form>
<script>
// Grow each note's textarea to fit its full text, so long notes are readable.
document.querySelectorAll("form.note textarea").forEach(function (ta) {
function fit() { ta.style.height = "auto"; ta.style.height = ta.scrollHeight + "px"; }
ta.addEventListener("input", fit);
fit();
});
</script>
<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}}