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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class RetryConfiguration(UniversalBaseModel):
    """
    Configuration for automatic retry of failed LLM requests with exponential backoff.
    """

    enabled: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether retry is enabled. Enabled by default to provide resilience against transient failures.
    """

    max_retries: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum number of retry attempts after initial failure.
    """

    initial_backoff_ms: typing.Optional[int] = pydantic.Field(default=None)
    """
    Initial backoff time in milliseconds before first retry.
    """

    max_backoff_ms: typing.Optional[int] = pydantic.Field(default=None)
    """
    Maximum backoff time in milliseconds between retries.
    """

    backoff_factor: typing.Optional[float] = pydantic.Field(default=None)
    """
    Multiplication factor for exponential backoff between retries.
    """

    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
