# 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 .return_chat_event_role import ReturnChatEventRole
from .return_chat_event_type import ReturnChatEventType


class ReturnChatEvent(UniversalBaseModel):
    """
    A description of a single event in a chat returned from the server
    """

    chat_id: str = pydantic.Field()
    """
    Identifier for the Chat this event occurred in. Formatted as a UUID.
    """

    emotion_features: typing.Optional[str] = pydantic.Field(default=None)
    """
    Stringified JSON containing the prosody model inference results.
    
    EVI uses the prosody model to measure 48 expressions related to speech and vocal characteristics. These results contain a detailed emotional and tonal analysis of the audio. Scores typically range from 0 to 1, with higher values indicating a stronger confidence level in the measured attribute.
    """

    id: str = pydantic.Field()
    """
    Identifier for a Chat Event. Formatted as a UUID.
    """

    message_text: typing.Optional[str] = pydantic.Field(default=None)
    """
    The text of the Chat Event. This field contains the message content for each event type listed in the `type` field.
    """

    metadata: typing.Optional[str] = pydantic.Field(default=None)
    """
    Stringified JSON with additional metadata about the chat event.
    """

    related_event_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Identifier for a related chat event. Currently only seen on ASSISTANT_PROSODY events, to point back to the ASSISTANT_MESSAGE that generated these prosody scores
    """

    role: ReturnChatEventRole
    timestamp: int = pydantic.Field()
    """
    Time at which the Chat Event occurred. Measured in seconds since the Unix epoch.
    """

    type: ReturnChatEventType

    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
