You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
guard.parse("Caesar is a great leader") # Guardrail Fails
104
+
guard.validate(
105
+
"""An apple a day keeps a doctor away.
106
+
This is good advice for keeping your health."""
107
+
) # Both the guardrails pass
108
+
109
+
try:
110
+
guard.validate(
111
+
"""Shut the hell up! Apple just released a new iPhone."""
112
+
) # Both the guardrails fail
113
+
except Exception as e:
114
+
print(e)
100
115
```
116
+
Output:
117
+
```console
118
+
Validation failed forfield with errors: Found the following competitors: [['Apple']]. Please avoid naming those competitors next time, The following sentencesin your response were found to be toxic:
101
119
120
+
- Shut the hell up!
121
+
```
102
122
103
123
### Use Guardrails to generate structured data from LLMs
0 commit comments