|
6 | 6 | "source": [ |
7 | 7 | "## Check whether an LLM-generated code response contains secrets\n", |
8 | 8 | "\n", |
9 | | - "### Using the `DetectSecrets` validator\n", |
| 9 | + "### Using the `SecretsPresent` validator\n", |
10 | 10 | "\n", |
11 | 11 | "This is a simple walkthrough of how to use the `DetectSecrets` validator to check whether an LLM-generated code response contains secrets. It utilizes the `detect-secrets` library, which is a Python library that scans code files for secrets. The library is available on GitHub at [this link](https://github.com/Yelp/detect-secrets).\n" |
12 | 12 | ] |
|
31 | 31 | "! pip install detect-secrets -q" |
32 | 32 | ] |
33 | 33 | }, |
| 34 | + { |
| 35 | + "cell_type": "markdown", |
| 36 | + "metadata": {}, |
| 37 | + "source": [ |
| 38 | + "We also need to install the ```SecretsPresent``` validator from Guardrails Hub: \n", |
| 39 | + "\n", |
| 40 | + "```guardrails hub install hub://guardrails/secrets_present```" |
| 41 | + ] |
| 42 | + }, |
34 | 43 | { |
35 | 44 | "cell_type": "code", |
36 | | - "execution_count": 2, |
| 45 | + "execution_count": null, |
37 | 46 | "metadata": {}, |
38 | 47 | "outputs": [ |
39 | 48 | { |
|
47 | 56 | ], |
48 | 57 | "source": [ |
49 | 58 | "# Import the guardrails package\n", |
50 | | - "# and the DetectSecrets validator\n", |
| 59 | + "# and import the SecretsPresent validator\n", |
| 60 | + "# from Guardrails Hub\n", |
51 | 61 | "import guardrails as gd\n", |
52 | | - "from guardrails.validators import DetectSecrets\n", |
| 62 | + "from guardrails.hub import SecretsPresent\n", |
53 | 63 | "from rich import print" |
54 | 64 | ] |
55 | 65 | }, |
|
64 | 74 | "# if the validator detects secrets\n", |
65 | 75 | "\n", |
66 | 76 | "guard = gd.Guard.from_string(\n", |
67 | | - " validators=[DetectSecrets(on_fail=\"fix\")],\n", |
| 77 | + " validators=[SecretsPresent(on_fail=\"fix\")],\n", |
68 | 78 | " description=\"testmeout\",\n", |
69 | 79 | ")" |
70 | 80 | ] |
|
207 | 217 | "cell_type": "markdown", |
208 | 218 | "metadata": {}, |
209 | 219 | "source": [ |
210 | | - "#### In this way, you can use the `DetectSecrets` validator to check whether an LLM-generated code response contains secrets. With Guardrails as wrapper, you can be assured that the secrets in the code will be detected and masked and not be exposed.\n" |
| 220 | + "#### In this way, you can use the `SecretsPresent` validator to check whether an LLM-generated code response contains secrets. With Guardrails as wrapper, you can be assured that the secrets in the code will be detected and masked and not be exposed.\n" |
211 | 221 | ] |
212 | 222 | } |
213 | 223 | ], |
|
0 commit comments