Skip to content

Commit 09b89bc

Browse files
committed
add validators from hub
1 parent 403f23c commit 09b89bc

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

docs/examples/bug_free_python_code.ipynb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"\n",
2424
"In short, we want to make sure that the code can be executed without any errors.\n",
2525
"\n",
26+
"## Step 0: Install the necessary validators from Guardrails Hub\n",
27+
"\n",
28+
"We first have to install the ```ValidPython``` validator from Guardrails Hub:\n",
29+
"\n",
30+
"```guardrails hub install hub://reflex/valid_python```\n",
2631
"\n",
2732
"## Step 1: Generating `RAIL` Spec\n",
2833
"\n",
@@ -80,7 +85,7 @@
8085
"outputs": [],
8186
"source": [
8287
"from pydantic import BaseModel, Field\n",
83-
"from guardrails.validators import BugFreePython\n",
88+
"from guardrails.hub import ValidPython\n",
8489
"\n",
8590
"prompt = \"\"\"\n",
8691
"Given the following high level leetcode problem description, write a short Python code snippet that solves the problem.\n",
@@ -91,7 +96,7 @@
9196
"${gr.complete_json_suffix}\"\"\"\n",
9297
"\n",
9398
"class BugFreePythonCode(BaseModel):\n",
94-
" python_code: str = Field(validators=[BugFreePython(on_fail=\"reask\")])\n",
99+
" python_code: str = Field(validators=[ValidPython(on_fail=\"reask\")])\n",
95100
"\n",
96101
" class Config:\n",
97102
" arbitrary_types_allowed = True"

docs/how_to_guides/streaming.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@
10211021
"outputs": [],
10221022
"source": [
10231023
"from guardrails.hub import UpperCase, OneLine\n",
1024+
"\n",
10241025
"prompt = \"\"\"\n",
10251026
"Generate a short description of large language models. Each new sentence should be on another line.\n",
10261027
"\"\"\"\n",

docs/how_to_guides/telemetry.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ OTEL_EXPORTER_OTLP_HEADERS
4141

4242
### Setup a Guard with Telemetry
4343

44-
First, set up your Guard the default tracer provided in the guardrails library. You can still use your desired validators
44+
We first have to install the ```ValidLength``` guardrail from Guardrails Hub.
45+
46+
```guardrails hub install hub://guardrails/valid_length```
47+
48+
Then, set up your Guard the default tracer provided in the guardrails library. You can still use your desired validators
4549

4650
<h5 a><strong><code>main.py</code></strong></h5>
4751
```python
4852
from guardrails import Guard
4953
from guardrails.utils.telemetry_utils import default_otlp_tracer
50-
from guardrails.validators import ValidLength
54+
from guardrails.hub import ValidLength
5155
import openai
5256

5357
guard = Guard.from_string(

0 commit comments

Comments
 (0)