From 81836ebe5d19ea426da7de2197c29c5271718467 Mon Sep 17 00:00:00 2001 From: Edwin Jose George <52248484+edwinjosegeorge@users.noreply.github.com> Date: Wed, 15 May 2024 22:36:15 +0930 Subject: [PATCH] fix: custom_llm_provider needs to be set before setting timeout --- litellm/main.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index 3429cab4d2f..d51c28f244a 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -674,20 +674,6 @@ def completion( k: v for k, v in kwargs.items() if k not in default_params } # model-specific params - pass them straight to the model/provider - ### TIMEOUT LOGIC ### - timeout = timeout or kwargs.get("request_timeout", 600) or 600 - # set timeout for 10 minutes by default - - if ( - timeout is not None - and isinstance(timeout, httpx.Timeout) - and supports_httpx_timeout(custom_llm_provider) == False - ): - read_timeout = timeout.read or 600 - timeout = read_timeout # default 10 min timeout - elif timeout is not None and not isinstance(timeout, httpx.Timeout): - timeout = float(timeout) # type: ignore - try: if base_url is not None: api_base = base_url @@ -727,6 +713,16 @@ def completion( "aws_region_name", None ) # support region-based pricing for bedrock + ### TIMEOUT LOGIC ### + timeout = timeout or kwargs.get("request_timeout", 600) or 600 + # set timeout for 10 minutes by default + if isinstance(timeout, httpx.Timeout) and not supports_httpx_timeout( + custom_llm_provider + ): + timeout = timeout.read or 600 # default 10 min timeout + elif not isinstance(timeout, httpx.Timeout): + timeout = float(timeout) # type: ignore + ### REGISTER CUSTOM MODEL PRICING -- IF GIVEN ### if input_cost_per_token is not None and output_cost_per_token is not None: litellm.register_model(