Skip to content

Commit aa66b27

Browse files
committed
enhance remote validation docs
1 parent 200aa9d commit aa66b27

File tree

3 files changed

+79
-7
lines changed

3 files changed

+79
-7
lines changed

docs/concepts/remote_validation_inference.ipynb

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@
1919
"\n",
2020
":::note\n",
2121
"Remote validation inferencing is only available in Guardrails versions 0.5.0 and above.\n",
22-
":::\n",
23-
"\n",
24-
"::note\n",
25-
"To enable/disable, you can run the cli command `guardrails configure` or modify your `~/.guardrailsrc`. For example, to disable remote inference use: `use_remote_inferencing=false`.\n",
26-
":::"
22+
":::\n"
2723
]
2824
},
2925
{
@@ -114,6 +110,62 @@
114110
" display(accumulated_output)\n"
115111
]
116112
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"## Toggling Remote Inferencing\n",
118+
"\n",
119+
"To enable/disable remote inferencing, you can run the cli command `guardrails configure` or modify your `~/.guardrailsrc`.\n",
120+
"\n",
121+
"\n"
122+
]
123+
},
124+
{
125+
"cell_type": "code",
126+
"execution_count": null,
127+
"metadata": {
128+
"vscode": {
129+
"languageId": "shellscript"
130+
}
131+
},
132+
"outputs": [],
133+
"source": [
134+
"# To disable\n",
135+
"guardrails configure --disable-remote-inferencing\n",
136+
"\n",
137+
"# To enable\n",
138+
"guardrails configure --enable-remote-inferencing"
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"To disable remote inferencing from a specific validator, you can add a `use_local` kwarg to the validator's initializer\n",
146+
"\n",
147+
":::note\n",
148+
"When runnning locally, you may need to reinstall the validator with the --install-local-models flag.\n",
149+
":::"
150+
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"execution_count": null,
155+
"metadata": {},
156+
"outputs": [],
157+
"source": [
158+
"from guardrails import Guard, install\n",
159+
"try:\n",
160+
" from guardrails.hub import ToxicLanguage\n",
161+
"except ImportError:\n",
162+
" install(\"hub://guardrails/toxic_language\", install_local_models=True)\n",
163+
" from guardrails.hub import ToxicLanguage\n",
164+
"\n",
165+
"# uses validator locally.\n",
166+
"guard.use(ToxicLanguage(use_local=True))\n"
167+
]
168+
},
117169
{
118170
"cell_type": "markdown",
119171
"metadata": {},
@@ -143,6 +195,14 @@
143195
"cell_type": "markdown",
144196
"metadata": {},
145197
"source": [
198+
":::note\n",
199+
"\n",
200+
"Contact us to host validators in your own VPC with managed hardware.\n",
201+
"\n",
202+
":::\n",
203+
"\n",
204+
"# Learn more\n",
205+
"\n",
146206
"To learn more about hosting your own validators, check out the [Host Remote Validator Models doc](/docs/how_to_guides/hosting_validator_models).\n",
147207
"\n",
148208
"To learn more about writing your own validators, check out the [Custom validators doc](/docs/how_to_guides/custom_validator)."

docs/getting_started/guardrails_server.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,31 @@ A `guardrails` key is added to the response object, which includes the validatio
122122
### Advanced Client Usage
123123
Advanced client usage is available in Python. You can point a Guard shim to the Guardrails server and use it as a normal Guard object.
124124

125-
To do this, you must first set a `use_server` flag in Guardrails settings.
125+
```python
126+
# Client code
127+
from guardrails import Guard
128+
129+
name_guard = Guard.fetch_guard(name="gibberish_guard")
130+
131+
validation_outcome = name_guard.validate("floofy doopy boopy")
132+
```
133+
134+
135+
#### Guardrails < v0.5.9
136+
In older versions of Guardrails, you need to set the `use_server` var in settings to True.
126137

127138
```python
128139
# Client code
129140
from guardrails import Guard, settings
130141

131142
settings.use_server = True
132-
133143
name_guard = Guard(name="gibberish_guard")
134144

135145
validation_outcome = name_guard.validate("floofy doopy boopy")
136146
```
137147

138148

149+
139150
## Learn More
140151
- [Guardrails Server Concepts](../concepts/deploying)
141152
- [Guardrails CLI Reference](../cli)

docusaurus/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const sidebars = {
4141
label: "Migration Guides",
4242
collapsed: false,
4343
items: [
44+
"migration_guides/0-6-alpha-migration",
4445
"migration_guides/0-5-migration",
4546
"migration_guides/0-4-migration",
4647
"migration_guides/0-3-migration",

0 commit comments

Comments
 (0)