mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
Properly handle unexpected decision values
This commit is contained in:
parent
34ee1be71d
commit
4150be56dc
1 changed files with 12 additions and 4 deletions
|
|
@ -358,9 +358,13 @@ class XecGuardGuardrail(CustomGuardrail):
|
|||
@staticmethod
|
||||
def _raise_if_unsafe_scan(result: dict) -> None:
|
||||
"""Raise HTTPException when XecGuard /scan returns UNSAFE."""
|
||||
decision = result.get("decision", "SAFE")
|
||||
if decision != "UNSAFE":
|
||||
decision = result.get("decision", "")
|
||||
if decision == "SAFE":
|
||||
return
|
||||
if decision != "UNSAFE":
|
||||
verbose_proxy_logger.warning(
|
||||
"XecGuard returned unexpected decision %r – treating as UNSAFE", decision
|
||||
)
|
||||
|
||||
trace_id = result.get("trace_id", "n/a")
|
||||
xecguard_result = result.get("xecguard_result", [])
|
||||
|
|
@ -388,9 +392,13 @@ class XecGuardGuardrail(CustomGuardrail):
|
|||
@staticmethod
|
||||
def _raise_if_unsafe_grounding(result: dict) -> None:
|
||||
"""Raise HTTPException when XecGuard /grounding returns UNSAFE."""
|
||||
decision = result.get("decision", "SAFE")
|
||||
if decision != "UNSAFE":
|
||||
decision = result.get("decision", "")
|
||||
if decision == "SAFE":
|
||||
return
|
||||
if decision != "UNSAFE":
|
||||
verbose_proxy_logger.warning(
|
||||
"XecGuard returned unexpected decision %r – treating as UNSAFE", decision
|
||||
)
|
||||
|
||||
trace_id = result.get("trace_id", "n/a")
|
||||
xr = result.get("xecguard_result")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue