mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
test: add multi-param test to catch stop block indentation bug
This commit is contained in:
parent
f9bb09352c
commit
917f1d2c89
1 changed files with 46 additions and 0 deletions
|
|
@ -82,3 +82,49 @@ def test_map_openai_params_stop_filtering():
|
|||
drop_params=False
|
||||
)
|
||||
assert optional_params["stopSequences"] == ["STOP1", "STOP2"]
|
||||
|
||||
|
||||
def test_map_openai_params_multi_param_with_stop():
|
||||
"""Test that stop param works correctly when passed alongside other params.
|
||||
This catches the indentation bug where stop block was outside the for loop.
|
||||
"""
|
||||
config = AmazonConverseConfig()
|
||||
optional_params = {}
|
||||
|
||||
# Pass temperature, stop, and top_p all at once
|
||||
# If stop block is outside for loop, temperature and top_p won't be mapped
|
||||
config.map_openai_params(
|
||||
non_default_params={"temperature": 0.7, "stop": ["END", "STOP"], "top_p": 0.9},
|
||||
optional_params=optional_params,
|
||||
model="bedrock/anthropic.claude-3",
|
||||
drop_params=False,
|
||||
)
|
||||
# All three params must be present - if stop block breaks the loop,
|
||||
# temperature and/or top_p will be missing
|
||||
assert optional_params["temperature"] == 0.7
|
||||
assert optional_params["stopSequences"] == ["END", "STOP"]
|
||||
assert optional_params["topP"] == 0.9
|
||||
|
||||
# Test with empty stop list alongside other params
|
||||
optional_params2 = {}
|
||||
config.map_openai_params(
|
||||
non_default_params={"temperature": 0.5, "stop": [], "top_p": 0.8},
|
||||
optional_params=optional_params2,
|
||||
model="bedrock/anthropic.claude-3",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params2["temperature"] == 0.5
|
||||
assert "stopSequences" not in optional_params2 # Empty stop list filtered out
|
||||
assert optional_params2["topP"] == 0.8
|
||||
|
||||
# Test with string stop alongside other params
|
||||
optional_params3 = {}
|
||||
config.map_openai_params(
|
||||
non_default_params={"temperature": 0.3, "stop": "HALT", "top_p": 0.95},
|
||||
optional_params=optional_params3,
|
||||
model="bedrock/anthropic.claude-3",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params3["temperature"] == 0.3
|
||||
assert optional_params3["stopSequences"] == ["HALT"]
|
||||
assert optional_params3["topP"] == 0.95
|
||||
Loading…
Add table
Reference in a new issue