Guardrails Response Object
Validation Outcome Previous when calling__call__ or parse on a Guard, the Guard would return a tuple of the raw llm output and the validated output or just the validated output respecitvely.
Now, in order to communicate more information, we respond with a ValidationOutcome class that contains the above information and more. See ValidationOutcome in the API Reference for more information on these additioanl properties.
In order to limit how much this changes breaks the current experience, we made this class iterable so you can still deconstruct its properties.
Whereas in 0.2.x you would receive the response like so:
validation_passed field. This field is a boolean that will be True if the guard process resulted in valid output and False otherwise. In conjunction with this, ValidationOutcome.validated_output will only have a value if validation succeeded. If the end result was not valid and either was or still contained reasks, validated_output will be none and the invalid output will be captured on ValidationOutcome.reask.
History & Logs Improvements
If you’re familiar with Guardrails, then you might have used theGuard.state property to inspect how the Guard process behaved over time. In order to make the Guard process more transparent, as part of v0.3.0 we redesigned how you access this information.
Now, on a Guard, you can access logs related to any __call__ or parse call within the current session via Guard.history. We documented this new structure and how it works here, but to give a quick example of the differences, where before if you needed to check if validation of a particualr step succeeded or not you might need to do something like this:
v0.2.0:
v0.3.0 you can simply: