Skip to content

Commit 156e835

Browse files
committed
notebooks
1 parent 065afb0 commit 156e835

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

docs/examples/regex_validation.ipynb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
"regex = '\\\\d{3}-\\\\d{3}-\\\\d{4}'"
2828
]
2929
},
30+
{
31+
"cell_type": "markdown",
32+
"metadata": {},
33+
"source": [
34+
"### Install the ```RegexMatch``` validator from Guardrails Hub \n",
35+
"\n",
36+
"```guardrails hub install hub://guardrails/regex_match```"
37+
]
38+
},
3039
{
3140
"cell_type": "markdown",
3241
"metadata": {},
@@ -42,7 +51,7 @@
4251
"source": [
4352
"import openai\n",
4453
"from guardrails import Guard\n",
45-
"from guardrails.validators import RegexMatch\n",
54+
"from guardrails.hub import RegexMatch\n",
4655
"from rich import print"
4756
]
4857
},

docs/examples/response_is_on_topic.ipynb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
"The argument `model` indicates the model that will be used to classify the topic. See a list of all models [here](https://huggingface.co/models?pipeline_tag=zero-shot-classification&sort=trending)."
9393
]
9494
},
95+
{
96+
"cell_type": "markdown",
97+
"metadata": {},
98+
"source": [
99+
"## Install the ```RestrictToTopic``` validator from Guardrails Hub \n",
100+
"\n",
101+
"```guardrails hub install hub://tryolabs/restricttotopic```\n"
102+
]
103+
},
95104
{
96105
"cell_type": "markdown",
97106
"metadata": {},
@@ -136,13 +145,13 @@
136145
],
137146
"source": [
138147
"import guardrails as gd\n",
139-
"from guardrails.validators import OnTopic\n",
148+
"from guardrails.hub import RestrictToTopic\n",
140149
"from guardrails.errors import ValidationError\n",
141150
"\n",
142151
"# Create the Guard with the OnTopic Validator\n",
143152
"guard = gd.Guard.from_string(\n",
144153
" validators=[\n",
145-
" OnTopic(\n",
154+
" RestrictToTopic(\n",
146155
" valid_topics=valid_topics,\n",
147156
" invalid_topics=invalid_topics,\n",
148157
" device=device,\n",
@@ -189,7 +198,7 @@
189198
"# Create the Guard with the OnTopic Validator\n",
190199
"guard = gd.Guard.from_string(\n",
191200
" validators=[\n",
192-
" OnTopic(\n",
201+
" RestrictToTopic(\n",
193202
" valid_topics=valid_topics,\n",
194203
" invalid_topics=invalid_topics,\n",
195204
" device=device,\n",
@@ -242,7 +251,7 @@
242251
"# Create the Guard with the OnTopic Validator\n",
243252
"guard = gd.Guard.from_string(\n",
244253
" validators=[\n",
245-
" OnTopic(\n",
254+
" RestrictToTopic(\n",
246255
" valid_topics=valid_topics,\n",
247256
" invalid_topics=invalid_topics,\n",
248257
" llm_callable=\"gpt-3.5-turbo\",\n",

0 commit comments

Comments
 (0)