|
92 | 92 | "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)." |
93 | 93 | ] |
94 | 94 | }, |
| 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 | + }, |
95 | 104 | { |
96 | 105 | "cell_type": "markdown", |
97 | 106 | "metadata": {}, |
|
136 | 145 | ], |
137 | 146 | "source": [ |
138 | 147 | "import guardrails as gd\n", |
139 | | - "from guardrails.validators import OnTopic\n", |
| 148 | + "from guardrails.hub import RestrictToTopic\n", |
140 | 149 | "from guardrails.errors import ValidationError\n", |
141 | 150 | "\n", |
142 | 151 | "# Create the Guard with the OnTopic Validator\n", |
143 | 152 | "guard = gd.Guard.from_string(\n", |
144 | 153 | " validators=[\n", |
145 | | - " OnTopic(\n", |
| 154 | + " RestrictToTopic(\n", |
146 | 155 | " valid_topics=valid_topics,\n", |
147 | 156 | " invalid_topics=invalid_topics,\n", |
148 | 157 | " device=device,\n", |
|
189 | 198 | "# Create the Guard with the OnTopic Validator\n", |
190 | 199 | "guard = gd.Guard.from_string(\n", |
191 | 200 | " validators=[\n", |
192 | | - " OnTopic(\n", |
| 201 | + " RestrictToTopic(\n", |
193 | 202 | " valid_topics=valid_topics,\n", |
194 | 203 | " invalid_topics=invalid_topics,\n", |
195 | 204 | " device=device,\n", |
|
242 | 251 | "# Create the Guard with the OnTopic Validator\n", |
243 | 252 | "guard = gd.Guard.from_string(\n", |
244 | 253 | " validators=[\n", |
245 | | - " OnTopic(\n", |
| 254 | + " RestrictToTopic(\n", |
246 | 255 | " valid_topics=valid_topics,\n", |
247 | 256 | " invalid_topics=invalid_topics,\n", |
248 | 257 | " llm_callable=\"gpt-3.5-turbo\",\n", |
|
0 commit comments