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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .task_message_content import TaskMessageContent
from .task_message_streaming_status import TaskMessageStreamingStatus


class TaskMessage(UniversalBaseModel):
    """
    Represents a message in the agent system.

    This entity is used to store messages in MongoDB, with each message
    associated with a specific task.
    """

    content: TaskMessageContent = pydantic.Field()
    """
    The content of the message. This content is not OpenAI compatible. These are messages that are meant to be displayed to the user.
    """

    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The timestamp when the message was created
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The task message's unique id
    """

    streaming_status: typing.Optional[TaskMessageStreamingStatus] = None
    task_id: str = pydantic.Field()
    """
    ID of the task this message belongs to
    """

    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    The timestamp when the message was last updated
    """

    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
