Skip to content

Prioritizing Responses with Multiple Guardrails on a Single Guard Object #807

Answered by wylansford
hodgesz asked this question in Q&A
Discussion options

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

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

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