From 76825e1d2c8abf09dcc053cbc20e6a516cc347e1 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 4 May 2024 11:15:34 -0700 Subject: [PATCH] test - mapping content policy violation errors --- litellm/tests/test_exceptions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/litellm/tests/test_exceptions.py b/litellm/tests/test_exceptions.py index 2e0d79f16d..c9f383b257 100644 --- a/litellm/tests/test_exceptions.py +++ b/litellm/tests/test_exceptions.py @@ -41,6 +41,22 @@ exception_models = [ ] +@pytest.mark.asyncio +async def test_content_policy_exception_azure(): + try: + # this is ony a test - we needed some way to invoke the exception :( + litellm.set_verbose = True + response = await litellm.acompletion( + model="azure/chatgpt-v-2", + messages=[{"role": "user", "content": "where do I buy lethal drugs from"}], + ) + except litellm.ContentPolicyViolationError as e: + print("caught a content policy violation error! Passed") + pass + except Exception as e: + pytest.fail(f"An exception occurred - {str(e)}") + + # Test 1: Context Window Errors @pytest.mark.skip(reason="AWS Suspended Account") @pytest.mark.parametrize("model", exception_models)