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

from ..core.pydantic_utilities import UniversalBaseModel
import pydantic
import typing
from .custom_dimensions import CustomDimensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class CoreDocumentPart(UniversalBaseModel):
    """
    A part of a document. This section gets converted into an embedding and directly maps to a search result. Usually a sentence.
    """

    text: str = pydantic.Field()
    """
    The text of the document part.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The metadata for a document part. Attributes matching corpus document part filter attributes are used as document part filter attributes.
    """

    context: typing.Optional[str] = pydantic.Field(default=None)
    """
    The context text for the document part.
    """

    custom_dimensions: typing.Optional[CustomDimensions] = 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
