Add raw AI response to parse result for debugging
- Backend returns raw AI text alongside parsed fields - Drawer shows expandable "Raw AI response" section when result has empty fields - Scan Receipt shows raw response inline if no fields were extracted - Helps diagnose model output issues without needing server logs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1ece0908af
commit
a7c54ca61c
4 changed files with 18 additions and 2 deletions
|
|
@ -260,7 +260,16 @@ export default function TransactionDetailDrawer({ transaction, accountName, cate
|
|||
{parseResult.data.date && <div className="flex justify-between"><span className="text-muted-foreground">Date</span><span className="font-medium">{parseResult.data.date}</span></div>}
|
||||
{parseResult.data.description && <div className="flex justify-between gap-4"><span className="text-muted-foreground shrink-0">Description</span><span className="font-medium text-right">{parseResult.data.description}</span></div>}
|
||||
{parseResult.data.category && <div className="flex justify-between"><span className="text-muted-foreground">Category hint</span><span className="font-medium">{parseResult.data.category}</span></div>}
|
||||
{!parseResult.data.merchant && !parseResult.data.amount && !parseResult.data.description && (
|
||||
<div className="text-muted-foreground">No fields detected.</div>
|
||||
)}
|
||||
</div>
|
||||
{parseResult.data.raw && (
|
||||
<details className="text-xs">
|
||||
<summary className="text-muted-foreground cursor-pointer hover:text-foreground">Raw AI response</summary>
|
||||
<pre className="mt-1.5 bg-background rounded p-2 text-xs overflow-x-auto whitespace-pre-wrap break-all border border-border">{parseResult.data.raw}</pre>
|
||||
</details>
|
||||
)}
|
||||
<div className="flex gap-2 pt-1">
|
||||
<button
|
||||
onClick={() => applyMutation.mutate(parseResult.data)}
|
||||
|
|
|
|||
|
|
@ -104,8 +104,13 @@ export default function TransactionList() {
|
|||
setScanError(null);
|
||||
try {
|
||||
const parsed = await parseReceiptFile(file);
|
||||
setReceiptParsed(parsed);
|
||||
setShowForm(true);
|
||||
const hasAnyField = parsed.merchant || parsed.amount || parsed.description || parsed.date;
|
||||
if (!hasAnyField && parsed.raw) {
|
||||
setScanError(`AI couldn't extract any fields. Raw response: "${parsed.raw}"`);
|
||||
} else {
|
||||
setReceiptParsed(parsed);
|
||||
setShowForm(true);
|
||||
}
|
||||
} catch (e: any) {
|
||||
setScanError(e?.response?.data?.detail ?? "Could not parse receipt. Check your AI settings.");
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue