From b360ab4c89bea9f1657cabcf42e8e2abd227f26d Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 5 Jun 2024 09:03:10 -0700 Subject: [PATCH] fix(azure.py): support dynamic drop params --- litellm/llms/azure.py | 13 +++++++++++-- litellm/tests/test_completion.py | 1 + litellm/utils.py | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/litellm/llms/azure.py b/litellm/llms/azure.py index 999a443c07..834fcbea96 100644 --- a/litellm/llms/azure.py +++ b/litellm/llms/azure.py @@ -157,6 +157,7 @@ class AzureOpenAIConfig: optional_params: dict, model: str, api_version: str, # Y-M-D-{optional} + drop_params, ) -> dict: supported_openai_params = self.get_supported_openai_params() @@ -181,7 +182,11 @@ class AzureOpenAIConfig: and api_version_day < "01" ) ): - if litellm.drop_params == False: + if litellm.drop_params == True or ( + drop_params is not None and drop_params == True + ): + pass + else: raise UnsupportedParamsError( status_code=400, message=f"""Azure does not support 'tool_choice', for api_version={api_version}. Bump your API version to '2023-12-01-preview' or later. This parameter requires 'api_version="2023-12-01-preview"' or later. Azure API Reference: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions""", @@ -189,7 +194,11 @@ class AzureOpenAIConfig: elif value == "required" and ( api_version_year == "2024" and api_version_month <= "05" ): ## check if tool_choice value is supported ## - if litellm.drop_params == False: + if litellm.drop_params == True or ( + drop_params is not None and drop_params == True + ): + pass + else: raise UnsupportedParamsError( status_code=400, message=f"Azure does not support '{value}' as a {param} param, for api_version={api_version}. To drop 'tool_choice=required' for calls with this Azure API version, set `litellm.drop_params=True` or for proxy:\n\n`litellm_settings:\n drop_params: true`\nAzure API Reference: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions", diff --git a/litellm/tests/test_completion.py b/litellm/tests/test_completion.py index 4aedaeb39e..47c55ca4f3 100644 --- a/litellm/tests/test_completion.py +++ b/litellm/tests/test_completion.py @@ -2160,6 +2160,7 @@ def test_completion_azure_key_completion_arg(): model="azure/chatgpt-v-2", messages=messages, api_key=old_key, + logprobs=True, max_tokens=10, ) print(f"response: {response}") diff --git a/litellm/utils.py b/litellm/utils.py index 32f7a938fa..3bf07a9e7b 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -6048,6 +6048,7 @@ def get_optional_params( optional_params=optional_params, model=model, api_version=api_version, # type: ignore + drop_params=drop_params, ) else: # assume passing in params for text-completion openai supported_params = get_supported_openai_params(