diff --git a/tests/litellm/llms/bedrock/test_bedrock_converse_transformation.py b/tests/litellm/llms/bedrock/test_bedrock_converse_transformation.py index 438abad9cf4..c8c1d6024c2 100644 --- a/tests/litellm/llms/bedrock/test_bedrock_converse_transformation.py +++ b/tests/litellm/llms/bedrock/test_bedrock_converse_transformation.py @@ -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 \ No newline at end of file