d2495190a9
AI now returns a short descriptive title per document (e.g. "ACME Corp
Invoice April 2026"). Title is stored in a new documents.title column
(migration 0002), shown in the row header instead of the raw filename,
and editable inline via PATCH /documents/{id}/title. Filename is shown
as a subtitle when a title exists.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
SYSTEM_PROMPT = (
|
|
"You are a financial document analysis assistant. "
|
|
"Given the text extracted from a PDF document, return ONLY a JSON object "
|
|
"with no markdown, no code fences, and no explanation."
|
|
)
|
|
|
|
USER_PROMPT_TEMPLATE = """Analyze the following document text and return a JSON object with exactly these keys:
|
|
title (a short, descriptive human-readable title for this document, e.g. "ACME Corp Invoice April 2026", "Office Supplies Receipt", "Q1 Flower Delivery Order"),
|
|
document_type (one of: invoice, bill, receipt, order, expense, revenue, unknown),
|
|
total_amount (string or null),
|
|
currency (string or null),
|
|
vendor_name (string or null),
|
|
customer_name (string or null),
|
|
billing_address (string or null),
|
|
customer_address (string or null),
|
|
invoice_number (string or null),
|
|
invoice_date (string or null),
|
|
due_date (string or null),
|
|
tags (array of short keyword strings describing the document),
|
|
line_items (array of objects, each with keys: description, amount),
|
|
suggested_categories (array of 2 to 5 short category name strings a user might want to file this document under, e.g. "Utilities", "Travel", "Software Subscriptions", "Client Invoices").
|
|
|
|
Document text:
|
|
{text}"""
|