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

from ...core.pydantic_utilities import UniversalBaseModel
from .role import Role
import pydantic
import typing
from .tool_call_message import ToolCallMessage
from .chat_message_tool_result import ChatMessageToolResult
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class ChatMessage(UniversalBaseModel):
    role: Role = pydantic.Field()
    """
    Role of who is providing the message.
    """

    content: typing.Optional[str] = pydantic.Field(default=None)
    """
    Transcript of the message.
    """

    tool_call: typing.Optional[ToolCallMessage] = pydantic.Field(default=None)
    """
    Function call name and arguments.
    """

    tool_result: typing.Optional[ChatMessageToolResult] = pydantic.Field(default=None)
    """
    Function call response from client.
    """

    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
