# This file was auto-generated by Fern from our API Definition.

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .extract_advanced_options import ExtractAdvancedOptions
from .extract_config_legacy_base_processor import ExtractConfigLegacyBaseProcessor
from .parse_config import ParseConfig


class ExtractConfigLegacy(UncheckedBaseModel):
    base_processor: typing_extensions.Annotated[
        typing.Optional[ExtractConfigLegacyBaseProcessor], FieldMetadata(alias="baseProcessor")
    ] = pydantic.Field(alias="baseProcessor", default=None)
    """
    The base processor to use. For extractors, this can be either `"extraction_performance"` or `"extraction_light"`. Defaults to `"extraction_performance"` if not provided. See [Extraction Changelog](https://docs.extend.ai/2026-02-09/changelog/extraction/extraction-performance) for more details.
    """

    base_version: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="baseVersion")] = (
        pydantic.Field(alias="baseVersion", default=None)
    )
    """
    The version of the `"extraction_performance"` or `"extraction_light"` processor to use. If not provided, the latest stable version for the selected `baseProcessor` will be used automatically. See [Extraction Changelog](https://docs.extend.ai/2026-02-09/changelog/extraction/extraction-performance) for more details.
    """

    extraction_rules: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="extractionRules")] = (
        pydantic.Field(alias="extractionRules", default=None)
    )
    """
    Custom rules to guide the extraction process in natural language.
    """

    fields: typing.List["ExtractionField"] = pydantic.Field()
    """
    Array of fields to extract from the document. This is the legacy format.
    
    We recommend using JSON Schema (`schema` property) for new implementations.
    """

    advanced_options: typing_extensions.Annotated[
        typing.Optional[ExtractAdvancedOptions], FieldMetadata(alias="advancedOptions")
    ] = pydantic.Field(alias="advancedOptions", default=None)
    """
    Advanced configuration options.
    """

    parse_config: typing_extensions.Annotated[typing.Optional[ParseConfig], FieldMetadata(alias="parseConfig")] = (
        pydantic.Field(alias="parseConfig", default=None)
    )
    """
    Configuration options for the parsing process.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow


from .extraction_field import ExtractionField  # noqa: E402, I001

update_forward_refs(ExtractConfigLegacy, ExtractionField=ExtractionField)
