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

from __future__ import annotations

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, update_forward_refs
from .chunking_strategy import ChunkingStrategy
from .custom_dimensions import CustomDimensions


class StructuredDocument(UniversalBaseModel):
    """
    A document with layout features.
    """

    id: str = pydantic.Field()
    """
    The document ID must be unique within the corpus.
    """

    type: typing.Literal["structured"] = "structured"
    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    The title of the document.
    """

    description: typing.Optional[str] = pydantic.Field(default=None)
    """
    The description of the document.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The metadata for a document as an arbitrary JSON object. Properties of this object can be used by document level filter attributes.
    """

    custom_dimensions: typing.Optional[CustomDimensions] = None
    sections: typing.List["StructuredDocumentSection"] = pydantic.Field()
    """
    The subsection of the document.
    """

    chunking_strategy: typing.Optional[ChunkingStrategy] = None

    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 .structured_document_section import StructuredDocumentSection  # noqa: E402, F401, I001

update_forward_refs(StructuredDocument)
