Base¶
Base class for structured extractors.
Defines the abstract interface for extracting structured data from document images.
BaseStructuredExtractor
¶
Bases: ABC
Abstract base class for structured extractors.
Structured extractors return data matching a user-provided Pydantic schema.
Example
extract
abstractmethod
¶
extract(
image: Union[Image, ndarray, str, Path],
schema: type[BaseModel],
prompt: str,
) -> StructuredOutput
Extract structured data from an image.
| PARAMETER | DESCRIPTION |
|---|---|
image
|
Input image (PIL Image, numpy array, or file path).
TYPE:
|
schema
|
Pydantic model class defining the expected output structure.
TYPE:
|
prompt
|
Extraction prompt describing what to extract.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StructuredOutput
|
StructuredOutput containing the validated data. |