mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix: keep fastapi import within proxy
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
25949a87ac
commit
2876ac03ce
2 changed files with 12 additions and 5 deletions
|
|
@ -102,11 +102,9 @@ def is_guardrail_intervention(e: Exception) -> bool:
|
|||
),
|
||||
):
|
||||
return True
|
||||
try:
|
||||
from fastapi.exceptions import HTTPException
|
||||
except ImportError:
|
||||
return False
|
||||
return isinstance(e, HTTPException) and e.status_code in _GUARDRAIL_BLOCK_STATUS_CODES
|
||||
from litellm.proxy.guardrails.exception_utils import is_fastapi_http_exception
|
||||
|
||||
return is_fastapi_http_exception(e, _GUARDRAIL_BLOCK_STATUS_CODES)
|
||||
|
||||
|
||||
def _strict_guardrail_modes_enabled() -> bool:
|
||||
|
|
|
|||
9
litellm/proxy/guardrails/exception_utils.py
Normal file
9
litellm/proxy/guardrails/exception_utils.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from collections.abc import Collection
|
||||
|
||||
|
||||
def is_fastapi_http_exception(e: Exception, block_status_codes: Collection[int]) -> bool:
|
||||
try:
|
||||
from fastapi.exceptions import HTTPException
|
||||
except ImportError:
|
||||
return False
|
||||
return isinstance(e, HTTPException) and e.status_code in block_status_codes
|
||||
Loading…
Add table
Reference in a new issue