mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
Merge branch 'main' into litellm_standardize_slack_exception_msg_format
This commit is contained in:
commit
8413fdf4c7
4 changed files with 81 additions and 30 deletions
|
@ -8071,11 +8071,8 @@ def _should_retry(status_code: int):
|
|||
return False
|
||||
|
||||
|
||||
def _calculate_retry_after(
|
||||
remaining_retries: int,
|
||||
max_retries: int,
|
||||
def _get_retry_after_from_exception_header(
|
||||
response_headers: Optional[httpx.Headers] = None,
|
||||
min_timeout: int = 0,
|
||||
):
|
||||
"""
|
||||
Reimplementation of openai's calculate retry after, since that one can't be imported.
|
||||
|
@ -8101,10 +8098,20 @@ def _calculate_retry_after(
|
|||
retry_after = int(retry_date - time.time())
|
||||
else:
|
||||
retry_after = -1
|
||||
return retry_after
|
||||
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
retry_after = -1
|
||||
|
||||
|
||||
def _calculate_retry_after(
|
||||
remaining_retries: int,
|
||||
max_retries: int,
|
||||
response_headers: Optional[httpx.Headers] = None,
|
||||
min_timeout: int = 0,
|
||||
):
|
||||
retry_after = _get_retry_after_from_exception_header(response_headers)
|
||||
|
||||
# If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says.
|
||||
if 0 < retry_after <= 60:
|
||||
return retry_after
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue