def retry_on_failure(func: Callable) -> Callable:
    """Decorator to apply tenacity retry with exponential backoff and jitter for 5xx errors."""
    return retry(
        wait=wait_exponential_jitter(exp_base=2, max=10),
        stop=stop_after_attempt(5),
        retry=retry_if_exception(is_retryable_http_error),
        reraise=True,
    )(func)
Decorator to apply tenacity retry with exponential backoff and jitter for 5xx errors.
llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/llama_index/indices/managed/llama_cloud/api_utils.py