Skip to content

docs: add payment data extraction example#2081

Open
marlonbarreto-git wants to merge 1 commit into567-labs:mainfrom
marlonbarreto-git:example/payment-data-extraction
Open

docs: add payment data extraction example#2081
marlonbarreto-git wants to merge 1 commit into567-labs:mainfrom
marlonbarreto-git:example/payment-data-extraction

Conversation

@marlonbarreto-git
Copy link

Summary

Adds a new example for extracting structured payment data from unstructured text (bank statements, invoices, emails).

This example demonstrates several Instructor patterns applied to the payments domain:

  • Pydantic models for payment transactions with custom field validators
  • ISO 4217 currency code validation — ensures 3-letter uppercase codes
  • PaymentMethod enum — constrains LLM output to valid payment types
  • Cross-field model validation — verifies total matches sum of transactions
  • Multi-currency handling — skips total validation when currencies differ
  • Instructor retry logic — automatic re-prompting on validation failure

Motivation

Financial data extraction is a common use case for structured outputs. The existing extracting_receipts.md covers image-based receipt parsing, but there was no example for text-based payment data extraction with multi-currency support and cross-field validation patterns.

Changes

  • docs/examples/payment_data_extraction.md — New example with full code
  • mkdocs.yml — Added nav entry next to the receipts example

Add a comprehensive example for extracting structured payment data from
unstructured text (bank statements, invoices, emails). Demonstrates:

- Pydantic models for payment transactions with field validators
- ISO 4217 currency code validation
- Multi-currency report handling
- Cross-field validation (total vs sum of transactions)
- Instructor retry logic for validation failures
- PaymentMethod enum for constrained output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant