Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: mark flaky tests

Krrish Dholakia2486a106f45d
diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py
index 54d87cc42e2..7578019dfff 100644
--- a/litellm/litellm_core_utils/exception_mapping_utils.py
+++ b/litellm/litellm_core_utils/exception_mapping_utils.py
@@ -311,6 +311,9 @@ def exception_type( # type: ignore # noqa: PLR0915
elif (
"invalid_request_error" in error_str
and "content_policy_violation" in error_str
+ ) or (
+ "Invalid prompt" in error_str
+ and "violating our usage policy" in error_str
):
exception_mapping_worked = True
raise ContentPolicyViolationError(
diff --git a/tests/llm_translation/base_llm_unit_tests.py b/tests/llm_translation/base_llm_unit_tests.py
index bbdb8e776ff..230781c6361 100644
--- a/tests/llm_translation/base_llm_unit_tests.py
+++ b/tests/llm_translation/base_llm_unit_tests.py
@@ -811,6 +811,7 @@ class BaseLLMChatTest(ABC):
return url
+ @pytest.mark.flaky(retries=3, delay=1)
def test_empty_tools(self):
"""
Related Issue: https://github.com/BerriAI/litellm/issues/9080
@@ -833,6 +834,8 @@ class BaseLLMChatTest(ABC):
response = completion(**base_completion_call_args, messages=[{"role": "user", "content": "Hello, how are you?"}], tools=[]) # just make sure call doesn't fail
print("response: ", response)
assert response is not None
+ except litellm.ContentPolicyViolationError:
+ pass
except litellm.InternalServerError:
pytest.skip("Model is overloaded")
except litellm.RateLimitError:
@@ -840,6 +843,7 @@ class BaseLLMChatTest(ABC):
except Exception as e:
pytest.fail(f"Error occurred: {e}")
+ @pytest.mark.flaky(retries=3, delay=1)
def test_basic_tool_calling(self):
try:
from litellm import completion, ModelResponse