Metadata-Version: 2.4
Name: demystify-extract
Version: 0.2.0
Summary: Client SDK for dmstfy-extract: schema-first document extraction with generated Pydantic types
Project-URL: Homepage, https://github.com/demystify-systems/ai-services-tools/tree/main/modules/dmstfy-extract/packages/extract-py
Project-URL: Repository, https://github.com/demystify-systems/ai-services-tools
Author: Demystify Systems
License: MIT
Requires-Python: >=3.11
Requires-Dist: demystify-platform-contracts
Requires-Dist: httpx<1,>=0.27
Requires-Dist: pydantic<3,>=2
Provides-Extra: dev
Requires-Dist: mypy<2,>=1.13; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest<9,>=8; extra == 'dev'
Requires-Dist: ruff<0.9,>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

# demystify-extract

Python client SDK for **dmstfy-extract** — schema-first document extraction with
generated [Pydantic](https://docs.pydantic.dev) v2 models for the starter schema
library (invoice, bank statement, resume, contract, email).

> Not yet published to PyPI. Until then, use it via the monorepo (see the module
> README's **"Use as your own repo"** section) or an editable/path install.

```bash
pip install demystify-extract      # once published — httpx + pydantic v2
```

## What you get

- **Generated Pydantic models** for each library schema version (`InvoiceV1`, …)
  that validate the API result shape, including the `{raw, value}` normalization
  envelope.
- **Envelope accessors** — `field_value` / `field_raw` / `is_normalized_field`.

## The normalization envelope

Fields whose schema carries `x-demystify-normalize: date|amount|name` come back
as `{"raw": ..., "value": ...}`. `raw` is the text exactly as printed; `value`
is canonical (ISO 8601 date / integer minor units / cleaned name). **Amount**
envelopes add `currency` (ISO 4217 or `None`) and `exponent` (minor-unit scale —
INR/USD 2, JPY 0, BHD 3), so `¥1234` →
`{"raw": "¥1234", "value": 1234, "currency": "JPY", "exponent": 0}`.

```python
from demystify_extract.generated import InvoiceV1
from demystify_extract import field_value

invoice = InvoiceV1.model_validate(result["data"])
field_value(invoice.total_amount)  # integer minor units
```

Results carry a top-level `result_format: "normalized@1"` version tag.

See the [module README](../../README.md) for the full API, offline quickstart,
and architecture.

## License

MIT
