mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Litellm dev 01 20 2025 p1 (#7884)
* fix(initial-test-to-return-api-timeout-value-in-openai-timeout-exception): Makes it easier for user to debug why request timed out * feat(openai.py): return timeout value + time taken on openai timeout errors helps debug timeout errors * fix(utils.py): fix num retries extraction logic when num_retries = 0 * fix(config_settings.md): litellm_logging.py support printing payload to console if 'LITELLM_PRINT_STANDARD_LOGGING_PAYLOAD' is true Enables easier debug * test(test_auth_checks.py'): remove common checks userapikeyauth enforcement check * fix(litellm_logging.py): fix linting error
This commit is contained in:
parent
806df5d31c
commit
4b23420a20
11 changed files with 65 additions and 46 deletions
|
@ -622,6 +622,28 @@ async def _client_async_logging_helper(
|
|||
)
|
||||
|
||||
|
||||
def _get_wrapper_num_retries(
|
||||
kwargs: Dict[str, Any], exception: Exception
|
||||
) -> Tuple[Optional[int], Dict[str, Any]]:
|
||||
"""
|
||||
Get the number of retries from the kwargs and the retry policy.
|
||||
Used for the wrapper functions.
|
||||
"""
|
||||
num_retries = kwargs.get("num_retries", None)
|
||||
if num_retries is None:
|
||||
num_retries = litellm.num_retries
|
||||
if kwargs.get("retry_policy", None):
|
||||
retry_policy_num_retries = get_num_retries_from_retry_policy(
|
||||
exception=exception,
|
||||
retry_policy=kwargs.get("retry_policy"),
|
||||
)
|
||||
kwargs["retry_policy"] = reset_retry_policy()
|
||||
if retry_policy_num_retries is not None:
|
||||
num_retries = retry_policy_num_retries
|
||||
|
||||
return num_retries, kwargs
|
||||
|
||||
|
||||
def client(original_function): # noqa: PLR0915
|
||||
rules_obj = Rules()
|
||||
|
||||
|
@ -736,19 +758,6 @@ def client(original_function): # noqa: PLR0915
|
|||
except Exception as e:
|
||||
raise e
|
||||
|
||||
def _get_num_retries(
|
||||
kwargs: Dict[str, Any], exception: Exception
|
||||
) -> Tuple[Optional[int], Dict[str, Any]]:
|
||||
num_retries = kwargs.get("num_retries", None) or litellm.num_retries or None
|
||||
if kwargs.get("retry_policy", None):
|
||||
num_retries = get_num_retries_from_retry_policy(
|
||||
exception=exception,
|
||||
retry_policy=kwargs.get("retry_policy"),
|
||||
)
|
||||
kwargs["retry_policy"] = reset_retry_policy()
|
||||
|
||||
return num_retries, kwargs
|
||||
|
||||
@wraps(original_function)
|
||||
def wrapper(*args, **kwargs): # noqa: PLR0915
|
||||
# DO NOT MOVE THIS. It always needs to run first
|
||||
|
@ -1200,7 +1209,7 @@ def client(original_function): # noqa: PLR0915
|
|||
raise e
|
||||
|
||||
call_type = original_function.__name__
|
||||
num_retries, kwargs = _get_num_retries(kwargs=kwargs, exception=e)
|
||||
num_retries, kwargs = _get_wrapper_num_retries(kwargs=kwargs, exception=e)
|
||||
if call_type == CallTypes.acompletion.value:
|
||||
context_window_fallback_dict = kwargs.get(
|
||||
"context_window_fallback_dict", {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue