mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix(azure): send only max_completion_tokens when both token params are set
This commit is contained in:
parent
cc33a310ae
commit
db30fa0f9e
2 changed files with 38 additions and 0 deletions
|
|
@ -169,6 +169,8 @@ class AzureOpenAIConfig(BaseConfig):
|
|||
api_version_day = None
|
||||
|
||||
for param, value in non_default_params.items():
|
||||
if param == "max_tokens" and "max_completion_tokens" in non_default_params:
|
||||
continue
|
||||
if param == "tool_choice":
|
||||
"""
|
||||
This parameter requires API version 2023-12-01-preview or later
|
||||
|
|
|
|||
|
|
@ -54,3 +54,39 @@ def test_map_openai_params_with_preview_api_version():
|
|||
assert config.map_openai_params(
|
||||
non_default_params, optional_params, model, drop_params, api_version
|
||||
)
|
||||
|
||||
|
||||
def test_map_openai_params_sends_only_max_completion_tokens_when_both_set():
|
||||
config = AzureOpenAIConfig()
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"max_tokens": 512, "max_completion_tokens": 256},
|
||||
optional_params={},
|
||||
model="gpt-4o",
|
||||
drop_params=False,
|
||||
api_version="2025-01-01-preview",
|
||||
)
|
||||
assert result == {"max_completion_tokens": 256}
|
||||
|
||||
|
||||
def test_map_openai_params_keeps_lone_max_tokens():
|
||||
config = AzureOpenAIConfig()
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"max_tokens": 512},
|
||||
optional_params={},
|
||||
model="gpt-4o",
|
||||
drop_params=False,
|
||||
api_version="2025-01-01-preview",
|
||||
)
|
||||
assert result == {"max_tokens": 512}
|
||||
|
||||
|
||||
def test_map_openai_params_keeps_lone_max_completion_tokens():
|
||||
config = AzureOpenAIConfig()
|
||||
result = config.map_openai_params(
|
||||
non_default_params={"max_completion_tokens": 256},
|
||||
optional_params={},
|
||||
model="gpt-4o",
|
||||
drop_params=False,
|
||||
api_version="2025-01-01-preview",
|
||||
)
|
||||
assert result == {"max_completion_tokens": 256}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue