mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
Add test for handling gaurdrails param
This commit is contained in:
parent
a1536fdd87
commit
085b07cdde
1 changed files with 25 additions and 0 deletions
|
|
@ -541,3 +541,28 @@ def test_amazon_titan_image_gen():
|
|||
print(f"response cost: {response._hidden_params['response_cost']}")
|
||||
|
||||
assert response._hidden_params["response_cost"] > 0
|
||||
|
||||
|
||||
def test_extract_headers_from_optional_params_with_guardrails():
|
||||
"""Test that guardrail parameters are correctly extracted from optional_params and converted to headers"""
|
||||
handler = BedrockImageGeneration()
|
||||
|
||||
# Test with both guardrail parameters
|
||||
optional_params = {
|
||||
"guardrailIdentifier": "4cf5knqaeq15",
|
||||
"guardrailVersion": "1",
|
||||
"someOtherParam": "value",
|
||||
}
|
||||
|
||||
headers = handler._extract_headers_from_optional_params(optional_params)
|
||||
|
||||
# Verify headers are correctly set
|
||||
assert headers["x-amz-bedrock-guardrail-identifier"] == "4cf5knqaeq15"
|
||||
assert headers["x-amz-bedrock-guardrail-version"] == "1"
|
||||
|
||||
# Verify guardrail params are removed from optional_params
|
||||
assert "guardrailIdentifier" not in optional_params
|
||||
assert "guardrailVersion" not in optional_params
|
||||
|
||||
# Verify other params remain in optional_params
|
||||
assert optional_params["someOtherParam"] == "value"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue