# 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 SoftTimeoutConfig(UncheckedBaseModel):
    """
    Configuration for soft timeout functionality during LLM response generation.
    """

    timeout_seconds: typing.Optional[float] = pydantic.Field(default=None)
    """
    Time in seconds before showing the predefined message while waiting for LLM response. Set to -1 to disable.
    """

    message: typing.Optional[str] = pydantic.Field(default=None)
    """
    Message to show when the first soft timeout is reached while waiting for LLM response. Supports dynamic variables (e.g., {{system__time}}, {{custom_variable}}).
    """

    additional_soft_timeout_messages: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Extra static filler messages for subsequent soft timeouts in the same LLM generation. The first timeout uses `message`. If fewer messages are configured than `max_soft_timeouts_per_generation`, the last configured message is repeated; otherwise a built-in filler is used.
    """

    use_llm_generated_message: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If enabled, the soft timeout message will be generated dynamically instead of using the static message.
    """

    randomize_fillers: typing.Optional[bool] = pydantic.Field(default=None)
    """
    If enabled, shuffle the order of static soft timeout messages once at the start of each turn. Only applies when use_llm_generated_message is false.
    """

    max_soft_timeouts_per_generation: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum filler messages while waiting for a single LLM response. Fires every timeout_seconds until the LLM streams content or this limit is reached.
    """

    llm_generated_message_prompt_override: typing.Optional[str] = pydantic.Field(default=None)
    """
    Custom prompt for generating the soft timeout filler message when use_llm_generated_message is enabled. Recent conversation context is provided as a separate user message. If not set, the default prompt will be used. Supports dynamic variables (e.g., {{system__time}}, {{custom_variable}}).
    """

    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
