# 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


class ChatMessageSchema(UniversalBaseModel):
    """
    Schema for a single message in a chat conversation.
    """

    id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Unique identifier of the message
    """

    role: str = pydantic.Field()
    """
    The role of the message sender ('user' or 'assistant')
    """

    content: str = pydantic.Field()
    """
    The content of the message
    """

    timestamp: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the message was sent
    """

    search_mode: typing.Optional[str] = pydantic.Field(default=None)
    """
    Search mode used for assistant reply
    """

    search_results_count: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of search results considered in the reply
    """

    response_time_ms: typing.Optional[float] = pydantic.Field(default=None)
    """
    Time taken to generate the assistant reply
    """

    user_feedback: typing.Optional[str] = pydantic.Field(default=None)
    """
    Feedback provided by the user
    """

    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
