Skip to content

Schema Models

These classes define the structure of a generated schema and provide utilities for converting it to a Pydantic model.

FieldType

Bases: StrEnum

FieldDef

Bases: BaseModel

Definition of a single extraction field.

Attributes:

Name Type Description
type_ FieldType

Data type — one of string, integer, boolean, float, or enum.

enum_name str | None

Name for the dynamically created enum type (required when type_ is enum).

enum_values list[str]

Allowed values when type_ is enum.

description str

Human-readable description of what this field captures.

NamedFieldDef

Bases: FieldDef

A FieldDef with an attached field name, used in SchemaFields.

SchemaFields

Bases: BaseModel

Container for the full set of named fields in a generated schema.

DynamicModelFactory

Creates a typed Pydantic BaseModel subclass from a SchemaFields spec at runtime.

Example
factory = DynamicModelFactory()
model_cls = factory(spec)
instance = model_cls(violation_type="privacy", severity=3)