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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .chat_message_content import ChatMessageContent
from .chat_message_role import ChatMessageRole


class ChatMessage(UniversalBaseModel):
    text: typing.Optional[str] = None
    role: ChatMessageRole
    content: typing.Optional[ChatMessageContent] = None
    source: typing.Optional[str] = pydantic.Field(default=None)
    """
    An optional identifier representing who or what generated this message.
    """

    metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = 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
