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

from ..core.pydantic_utilities import UniversalBaseModel
import typing
from .message_role import MessageRole
from .chat_message_blocks_item import ChatMessageBlocksItem
from ..core.pydantic_utilities import IS_PYDANTIC_V2
import pydantic


class ChatMessage(UniversalBaseModel):
    """
    Chat message.
    """

    role: typing.Optional[MessageRole] = None
    additional_kwargs: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None
    blocks: typing.Optional[typing.List[ChatMessageBlocksItem]] = 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
