mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
fix(proxy_server.py): support env vars for controlling global max parallel request retry/timeouts
fixes issue where litellm module level settings weren't working for global retries, due to time of init
This commit is contained in:
parent
3007f0344d
commit
ab28e55b76
2 changed files with 23 additions and 2 deletions
|
@ -2,3 +2,6 @@ model_list:
|
||||||
- model_name: "*"
|
- model_name: "*"
|
||||||
litellm_params:
|
litellm_params:
|
||||||
model: "*"
|
model: "*"
|
||||||
|
|
||||||
|
general_settings:
|
||||||
|
global_max_parallel_requests: 0
|
|
@ -311,6 +311,24 @@ except Exception as e:
|
||||||
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
|
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
|
||||||
_license_check = LicenseCheck()
|
_license_check = LicenseCheck()
|
||||||
premium_user: bool = _license_check.is_premium()
|
premium_user: bool = _license_check.is_premium()
|
||||||
|
global_max_parallel_request_retries_env: Optional[str] = os.getenv(
|
||||||
|
"LITELLM_GLOBAL_MAX_PARALLEL_REQUEST_RETRIES"
|
||||||
|
)
|
||||||
|
if global_max_parallel_request_retries_env is None:
|
||||||
|
global_max_parallel_request_retries: int = 3
|
||||||
|
else:
|
||||||
|
global_max_parallel_request_retries = int(global_max_parallel_request_retries_env)
|
||||||
|
|
||||||
|
global_max_parallel_request_retry_timeout_env: Optional[str] = os.getenv(
|
||||||
|
"LITELLM_GLOBAL_MAX_PARALLEL_REQUEST_RETRY_TIMEOUT"
|
||||||
|
)
|
||||||
|
if global_max_parallel_request_retry_timeout_env is None:
|
||||||
|
global_max_parallel_request_retry_timeout: float = 60.0
|
||||||
|
else:
|
||||||
|
global_max_parallel_request_retry_timeout = float(
|
||||||
|
global_max_parallel_request_retry_timeout_env
|
||||||
|
)
|
||||||
|
|
||||||
ui_link = f"{server_root_path}/ui/"
|
ui_link = f"{server_root_path}/ui/"
|
||||||
ui_message = (
|
ui_message = (
|
||||||
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
|
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
|
||||||
|
@ -3021,8 +3039,8 @@ def model_list(
|
||||||
@backoff.on_exception(
|
@backoff.on_exception(
|
||||||
backoff.expo,
|
backoff.expo,
|
||||||
Exception, # base exception to catch for the backoff
|
Exception, # base exception to catch for the backoff
|
||||||
max_tries=litellm.num_retries or 3, # maximum number of retries
|
max_tries=global_max_parallel_request_retries, # maximum number of retries
|
||||||
max_time=litellm.request_timeout or 60, # maximum total time to retry for
|
max_time=global_max_parallel_request_retry_timeout, # maximum total time to retry for
|
||||||
on_backoff=on_backoff, # specifying the function to call on backoff
|
on_backoff=on_backoff, # specifying the function to call on backoff
|
||||||
giveup=giveup,
|
giveup=giveup,
|
||||||
logger=verbose_proxy_logger,
|
logger=verbose_proxy_logger,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue