Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I am referring to the documentation to setup multiple guardrails for a single guard object - https://www.guardrailsai.com/docs/hub/how_to_guides/multiple_validators

Is there a way to prioritize the response in the case where multiple guardrails get triggered so that the highest priority guardrail response gets returned? For instance maybe we have a self-harm and PII guardrails and they both trigger, we would like the response for self-harm to come back.

Is that possible in guardrails-ai?

You must be logged in to vote

At the moment no, all guards are run with the same prioritization. You may be able to get some of the info you are looking for by checking the guard history:

 from guardrails import Guard
 from guardrails.hub import RegexMatch, ValidLength

 guard = Guard().use_many(
     ValidLength(min=1, max=128, on_fail="fix"),
     RegexMatch(regex="^[A-Z][a-z]*$", on_fail="fix"),
 )

 result = guard.parse("��Caesar is a great leader")  # Guardrail Fails

 print(guard.history)

It will have some of the information for each guard that is run

Replies: 2 comments

Comment options

At the moment no, all guards are run with the same prioritization. You may be able to get some of the info you are looking for by checking the guard history:

 from guardrails import Guard
 from guardrails.hub import RegexMatch, ValidLength

 guard = Guard().use_many(
     ValidLength(min=1, max=128, on_fail="fix"),
     RegexMatch(regex="^[A-Z][a-z]*$", on_fail="fix"),
 )

 result = guard.parse("��Caesar is a great leader")  # Guardrail Fails

 print(guard.history)

It will have some of the information for each guard that is run

You must be logged in to vote
0 replies
Answer selected by hodgesz
Comment options

Appreciate your quick response! Let me try guard.history and see how that works. I will reach back out if I have any more questions.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.