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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel


class AgentResponsePayload(UncheckedBaseModel):
    """
    Text chunk sent from your server to ElevenLabs for speech synthesis.
    Stream LLM output by sending multiple messages with `is_final: false`, then
    terminate the response with a message where `is_final: true` and `content` is
    an empty string.
    """

    type: typing.Literal["agent_response"] = pydantic.Field(default="agent_response")
    """
    The message type identifier.
    """

    content: str = pydantic.Field()
    """
    The text to synthesize. For streaming responses, send incremental chunks here.
    The final message in a response must have an empty string (`""`).
    """

    event_id: typing.Optional[int] = pydantic.Field(default=None)
    """
    The `event_id` from the `user_transcript` this response addresses. ElevenLabs
    uses this to discard responses that belong to an interrupted turn.
    """

    is_final: bool = pydantic.Field()
    """
    Set to `true` on the last message of a response (with an empty `content`).
    Set to `false` on all preceding chunks.
    """

    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
