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

from ..core.pydantic_utilities import UniversalBaseModel
import typing_extensions
import typing
from ..core.serialization import FieldMetadata
import pydantic
from .text_node_relationships_value import TextNodeRelationshipsValue
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class TextNode(UniversalBaseModel):
    """
    Provided for backward compatibility.

    Note: we keep the field with the typo "seperator" to maintain backward compatibility for
    serialized objects.
    """

    id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="id_")] = pydantic.Field(default=None)
    """
    Unique ID of the node.
    """

    embedding: typing.Optional[typing.List[float]] = pydantic.Field(default=None)
    """
    Embedding of the node.
    """

    extra_info: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    A flat dictionary of metadata fields
    """

    excluded_embed_metadata_keys: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Metadata keys that are excluded from text for the embed model.
    """

    excluded_llm_metadata_keys: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Metadata keys that are excluded from text for the LLM.
    """

    relationships: typing.Optional[typing.Dict[str, TextNodeRelationshipsValue]] = pydantic.Field(default=None)
    """
    A mapping of relationships to other node information.
    """

    metadata_template: typing.Optional[str] = pydantic.Field(default=None)
    """
    Template for how metadata is formatted, with {key} and {value} placeholders.
    """

    metadata_seperator: typing.Optional[str] = pydantic.Field(default=None)
    """
    Separator between metadata fields when converting to string.
    """

    text: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text content of the node.
    """

    mimetype: typing.Optional[str] = pydantic.Field(default=None)
    """
    MIME type of the node content.
    """

    start_char_idx: typing.Optional[int] = pydantic.Field(default=None)
    """
    Start char index of the node.
    """

    end_char_idx: typing.Optional[int] = pydantic.Field(default=None)
    """
    End char index of the node.
    """

    text_template: typing.Optional[str] = pydantic.Field(default=None)
    """
    Template for how text is formatted, with {content} and {metadata_str} placeholders.
    """

    class_name: typing.Optional[str] = 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
