fix(utils.py): add coverage for azure img gen content policy violation error

This commit is contained in:
Krrish Dholakia 2024-06-04 08:02:25 -07:00
parent 0d16ecc956
commit 7b474ec267

View file

@ -9838,15 +9838,19 @@ def exception_type(
response=original_exception.response, response=original_exception.response,
) )
elif ( elif (
"invalid_request_error" in error_str (
and "content_policy_violation" in error_str "invalid_request_error" in error_str
) or ( and "content_policy_violation" in error_str
"The response was filtered due to the prompt triggering Azure OpenAI's content management" )
in error_str or (
"The response was filtered due to the prompt triggering Azure OpenAI's content management"
in error_str
)
or "Your task failed as a result of our safety system" in error_str
): ):
exception_mapping_worked = True exception_mapping_worked = True
raise ContentPolicyViolationError( raise ContentPolicyViolationError(
message=f"AzureException ContentPolicyViolationError - {original_exception.message}", message=f"litellm.ContentPolicyViolationError: AzureException - {original_exception.message}",
llm_provider="azure", llm_provider="azure",
model=model, model=model,
litellm_debug_info=extra_information, litellm_debug_info=extra_information,