fix(exceptions.py): use correct status code for content policy exceptions

Fixes https://github.com/BerriAI/litellm/issues/4941#issuecomment-2256578732
This commit is contained in:
Krrish Dholakia 2024-07-29 12:01:54 -07:00
parent 2a705dbb49
commit 7de70a19e4
3 changed files with 39 additions and 38 deletions

View file

@ -500,6 +500,16 @@ def mock_completion(
llm_provider=getattr(mock_response, "llm_provider", custom_llm_provider or "openai"), # type: ignore
model=model,
)
elif isinstance(mock_response, str) and mock_response.startswith(
"Exception: content_filter_policy"
):
raise litellm.MockException(
status_code=400,
message=mock_response,
llm_provider="azure",
model=model, # type: ignore
request=httpx.Request(method="POST", url="https://api.openai.com/v1/"),
)
time_delay = kwargs.get("mock_delay", None)
if time_delay is not None:
time.sleep(time_delay)