"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 921acd3a224a

from __future__ import annotations
from mistralai.client.types import BaseModel, UNSET_SENTINEL
from mistralai.client.utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


ReferenceIDTypedDict = TypeAliasType("ReferenceIDTypedDict", Union[str, int])


ReferenceID = TypeAliasType("ReferenceID", Union[str, int])


class ReferenceChunkTypedDict(TypedDict):
    reference_ids: List[ReferenceIDTypedDict]
    type: Literal["reference"]


class ReferenceChunk(BaseModel):
    reference_ids: List[ReferenceID]

    type: Annotated[
        Annotated[
            Optional[Literal["reference"]], AfterValidator(validate_const("reference"))
        ],
        pydantic.Field(alias="type"),
    ] = "reference"

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["type"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    ReferenceChunk.model_rebuild()
except NameError:
    pass
