"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

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


UserMessageContentTypedDict = TypeAliasType(
    "UserMessageContentTypedDict", Union[str, List[ContentChunkTypedDict]]
)


UserMessageContent = TypeAliasType("UserMessageContent", Union[str, List[ContentChunk]])


class UserMessageTypedDict(TypedDict):
    content: Nullable[UserMessageContentTypedDict]
    role: Literal["user"]


class UserMessage(BaseModel):
    content: Nullable[UserMessageContent]

    role: Annotated[
        Annotated[Literal["user"], AfterValidator(validate_const("user"))],
        pydantic.Field(alias="role"),
    ] = "user"

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                m[k] = val

        return m


try:
    UserMessage.model_rebuild()
except NameError:
    pass
