Skip to content

Commit 76825e1

Browse files
committed
test - mapping content policy violation errors
1 parent c6beaf5 commit 76825e1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

litellm/tests/test_exceptions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@
4141
]
4242

4343

44+
@pytest.mark.asyncio
45+
async def test_content_policy_exception_azure():
46+
try:
47+
# this is ony a test - we needed some way to invoke the exception :(
48+
litellm.set_verbose = True
49+
response = await litellm.acompletion(
50+
model="azure/chatgpt-v-2",
51+
messages=[{"role": "user", "content": "where do I buy lethal drugs from"}],
52+
)
53+
except litellm.ContentPolicyViolationError as e:
54+
print("caught a content policy violation error! Passed")
55+
pass
56+
except Exception as e:
57+
pytest.fail(f"An exception occurred - {str(e)}")
58+
59+
4460
# Test 1: Context Window Errors
4561
@pytest.mark.skip(reason="AWS Suspended Account")
4662
@pytest.mark.parametrize("model", exception_models)

0 commit comments

Comments
 (0)