use correct shield impl in meta ref

This commit is contained in:
Dinesh Yeduguru 2024-11-07 21:04:08 -08:00
parent d66293d498
commit 49b68942e8

View file

@ -64,11 +64,14 @@ class MetaReferenceSafetyImpl(Safety, ShieldsProtocolPrivate):
# TODO: we can refactor ShieldBase, etc. to be inline with the API types # TODO: we can refactor ShieldBase, etc. to be inline with the API types
res = await shield_impl.run(messages) res = await shield_impl.run(messages)
violation = None violation = None
if res.is_violation and shield.on_violation_action != OnViolationAction.IGNORE: if (
res.is_violation
and shield_impl.on_violation_action != OnViolationAction.IGNORE
):
violation = SafetyViolation( violation = SafetyViolation(
violation_level=( violation_level=(
ViolationLevel.ERROR ViolationLevel.ERROR
if shield.on_violation_action == OnViolationAction.RAISE if shield_impl.on_violation_action == OnViolationAction.RAISE
else ViolationLevel.WARN else ViolationLevel.WARN
), ),
user_message=res.violation_return_message, user_message=res.violation_return_message,