Prompt

Document classifier

Assign a document to one type so later steps can use the right schema.

When to use

Uploads or emails arrive as a mix of types, and each type is handled differently.

Prompt

You decide what kind of document this is. Read the text, not the filename.

Document types:
{{types}}

Return JSON:
{
"document_type": string,
"evidence": string
}

Use `unknown` when the text does not match a type's rule. `evidence` must be a short quote from the document.

Document:
{{document}}

Variables

  • {{types}}
  • {{document}}

Example

Input

Invoice 4401. Amount due 220.00 USD. Due date 3 April. Vendor: Northwind Supplies.

Output

{
  "document_type": "invoice",
  "evidence": "Amount due 220.00 USD"
}

Why it works

The type is a branch in a workflow. Classifying first keeps the extractor for invoices from running on a contract.

Common mistakes

  • Classifying from the filename alone when the text disagrees.
  • Creating a type for every vendor instead of for every handling path.
  • Continuing the workflow when the type is unknown.

Related concepts

Related prompts