From 9ef83126d71c25b7917b778ab8e0a2dcc1a90544 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 1 Jun 2024 19:31:34 -0700 Subject: [PATCH] fix(utils.py): correctly instrument passing through api version in optional param check --- litellm/llms/azure.py | 1 - litellm/main.py | 1 + litellm/tests/test_streaming.py | 1 + litellm/utils.py | 7 ++++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/litellm/llms/azure.py b/litellm/llms/azure.py index 3536ec9a6ef..a92a03803d8 100644 --- a/litellm/llms/azure.py +++ b/litellm/llms/azure.py @@ -147,7 +147,6 @@ class AzureOpenAIConfig: api_version_year = api_version_times[0] api_version_month = api_version_times[1] api_version_day = api_version_times[2] - args = locals() for param, value in non_default_params.items(): if param == "tool_choice": """ diff --git a/litellm/main.py b/litellm/main.py index 7021137a817..d71b046a015 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -838,6 +838,7 @@ def completion( logprobs=logprobs, top_logprobs=top_logprobs, extra_headers=extra_headers, + api_version=api_version, **non_default_params, ) diff --git a/litellm/tests/test_streaming.py b/litellm/tests/test_streaming.py index 6c1cb612866..25f36826d2f 100644 --- a/litellm/tests/test_streaming.py +++ b/litellm/tests/test_streaming.py @@ -2828,6 +2828,7 @@ async def test_azure_astreaming_and_function_calling(): password=os.environ["REDIS_PASSWORD"], ) try: + litellm.set_verbose = True response = await litellm.acompletion( model="azure/gpt-4-nov-release", tools=tools, diff --git a/litellm/utils.py b/litellm/utils.py index 5f42c2f46e1..77690270806 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -5192,6 +5192,7 @@ def get_optional_params( logprobs=None, top_logprobs=None, extra_headers=None, + api_version=None, **kwargs, ): # retrieve all parameters passed to the function @@ -5262,6 +5263,7 @@ def get_optional_params( "logprobs": None, "top_logprobs": None, "extra_headers": None, + "api_version": None, } # filter out those parameters that were passed with non-default values non_default_params = { @@ -5270,6 +5272,7 @@ def get_optional_params( if ( k != "model" and k != "custom_llm_provider" + and k != "api_version" and k in default_params and v != default_params[k] ) @@ -6051,9 +6054,7 @@ def get_optional_params( ) _check_valid_arg(supported_params=supported_params) api_version = ( - passed_params.get("api_version", None) - or litellm.api_version - or get_secret("AZURE_API_VERSION") + api_version or litellm.api_version or get_secret("AZURE_API_VERSION") ) optional_params = litellm.AzureOpenAIConfig().map_openai_params( non_default_params=non_default_params,