# 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
from .start_agents_request_properties_turn_detection_config_end_of_speech_mode import (
    StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechMode,
)
from .start_agents_request_properties_turn_detection_config_end_of_speech_semantic_config import (
    StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechSemanticConfig,
)
from .start_agents_request_properties_turn_detection_config_end_of_speech_vad_config import (
    StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechVadConfig,
)


class StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeech(UncheckedBaseModel):
    """
    End of Speech (EoS) detection configuration. Determines when a user ends their speech.
    """

    mode: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechMode] = pydantic.Field(default=None)
    """
    End of speech detection mode:
    - `vad`: Based on VAD (Voice Activity Detection). Detects silence duration.
    - `semantic`: Based on semantic triggering. Uses semantic understanding to determine when conversation ends.
    """

    vad_config: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechVadConfig] = pydantic.Field(
        default=None
    )
    """
    VAD configuration. Used when `mode` is `vad`.
    """

    semantic_config: typing.Optional[StartAgentsRequestPropertiesTurnDetectionConfigEndOfSpeechSemanticConfig] = (
        pydantic.Field(default=None)
    )
    """
    Semantic configuration. Used when `mode` is `semantic`.
    """

    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
