def create_retry_decorator(
    max_retries: int,
    min_seconds: float = 1,
    max_seconds: float = 20,
    random_exponential: bool = True,
    stop_after_delay_seconds: Optional[float] = None,
) -> Callable[[Any], Any]:
    """Create a retry decorator with custom parameters."""
    return tenacity.Retrying(
        stop=(
            tenacity.stop_after_attempt(max_retries)
            if stop_after_delay_seconds is None
            else tenacity.stop_any(
                tenacity.stop_after_delay(stop_after_delay_seconds),
                tenacity.stop_after_attempt(max_retries),
            )
        ),
        wait=(
            tenacity.wait_random_exponential(min=min_seconds, max=max_seconds)
            if random_exponential
            else tenacity.wait_random(min=min_seconds, max=max_seconds)
        ),
        retry=tenacity.retry_if_exception_type(Exception),
        reraise=True,
    )
Create a retry decorator with custom parameters.
llama-index-integrations/llms/llama-index-llms-siliconflow/llama_index/llms/siliconflow/base.py