# 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 .spelling_patience import SpellingPatience
from .turn_eagerness import TurnEagerness
from .turn_model import TurnModel


class BaseTurnConfig(UncheckedBaseModel):
    turn_timeout: typing.Optional[float] = pydantic.Field(default=None)
    """
    Maximum wait time for the user's reply before re-engaging the user
    """

    initial_wait_time: typing.Optional[float] = pydantic.Field(default=None)
    """
    How long the agent will wait for the user to start the conversation if the first message is empty. If not set, uses the regular turn_timeout.
    """

    silence_end_call_timeout: typing.Optional[float] = pydantic.Field(default=None)
    """
    Maximum wait time since the user last spoke before terminating the call
    """

    turn_eagerness: typing.Optional[TurnEagerness] = pydantic.Field(default=None)
    """
    Controls how eager the agent is to respond. Low = less eager (waits longer), Standard = default eagerness, High = more eager (responds sooner)
    """

    spelling_patience: typing.Optional[SpellingPatience] = pydantic.Field(default=None)
    """
    Controls if the agent should be more patient when user is spelling numbers and named entities. Auto = model based, Off = never wait extra
    """

    speculative_turn: typing.Optional[bool] = pydantic.Field(default=None)
    """
    When enabled, starts generating LLM responses during silence before full turn confidence is reached, reducing perceived latency. May increase LLM costs.
    """

    retranscribe_on_turn_timeout: typing.Optional[bool] = pydantic.Field(default=None)
    """
    When enabled, if VAD detects no speech, attempts to re-transcribe accumulated audio at turn timeout. Disables silence discount billing for affected turns.
    """

    turn_model: typing.Optional[TurnModel] = None
    interruption_ignore_terms: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    List of terms that should not trigger an interruption when spoken by the user (e.g. 'gotcha', 'understood'). Uses case-insensitive exact matching.
    """

    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
