forked from phoenix/litellm-mirror
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:
parent
52b1ca292c
commit
66dbd938e8
3 changed files with 39 additions and 38 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue