forked from phoenix/litellm-mirror
fix(azure.py): support dynamic drop params
This commit is contained in:
parent
60ec3228ed
commit
b360ab4c89
3 changed files with 13 additions and 2 deletions
|
@ -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",
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue