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."""
    if random_exponential:
        wait_strategy = tenacity.wait_random_exponential(
            min=min_seconds, max=max_seconds
        )
    else:
        wait_strategy = tenacity.wait_random(min=min_seconds, max=max_seconds)

    stop_strategy = (
        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),
        )
    )

    return tenacity.retry(
        stop=stop_strategy,
        wait=wait_strategy,
        retry=tenacity.retry_if_exception_type(Exception),
        reraise=True,
    )
Create a retry decorator with custom parameters.
llama-index-integrations/embeddings/llama-index-embeddings-siliconflow/llama_index/embeddings/siliconflow/base.py