diff --git a/docs/test.ipynb b/docs/test.ipynb deleted file mode 100644 index 7f818f26b..000000000 --- a/docs/test.ipynb +++ /dev/null @@ -1,123 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/Users/calebcourier/Projects/gr-mono/guardrails/docs/.venv/bin/guardrails\n" - ] - } - ], - "source": [ - "! which guardrails" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mdetect_pii...\u001b[0m\n", - "\u001b[2K\u001b[32m[ ]\u001b[0m Fetching manifestst\n", - "\u001b[2K\u001b[32m[= ]\u001b[0m Downloading dependenciespendencies Running command git clone --filter=blob:none --quiet https://github.com/guardrails-ai/detect_pii.git /private/var/folders/w2/ssf16z690zd7_4dggw0y5s_m0000gn/T/pip-req-build-58meepeu\n", - "\u001b[2K\u001b[32m[== ]\u001b[0m Downloading dependencies\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[=== ]\u001b[0m Downloading dependencies\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[= ]\u001b[0m Downloading dependencies\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[ =]\u001b[0m Downloading dependencies\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[ =]\u001b[0m Downloading dependencies\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[ ]\u001b[0m Downloading dependencies\n", - "\u001b[2K\u001b[32m[== ]\u001b[0m Running post-install setuptall setup\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "\u001b[2K\u001b[32m[== ]\u001b[0m Running post-install setup\n", - "\u001b[1A\u001b[2K✅Successfully installed guardrails/detect_pii!\n", - "\n", - "\n", - "\u001b[1mImport validator:\u001b[0m\n", - "from guardrails.hub import DetectPII\n", - "\n", - "\u001b[1mGet more info:\u001b[0m\n", - "\u001b[4;94mhttps://hub.guardrailsai.com/validator/guardrails/detect_pii\u001b[0m\n", - "\n" - ] - } - ], - "source": [ - "! guardrails hub install hub://guardrails/detect_pii" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Validation failed for field with errors: The following text in your response contains PII:\n", - "My email address is not_a_real_email@guardrailsai.com\n" - ] - } - ], - "source": [ - "import openai\n", - "from guardrails import Guard\n", - "from guardrails.errors import ValidationError\n", - "from guardrails.hub import DetectPII\n", - "from guardrails.types import OnFailAction\n", - "\n", - "guard = Guard()\n", - "guard.use(DetectPII(pii_entities=[\"EMAIL_ADDRESS\", \"PHONE_NUMBER\"], on_fail=OnFailAction.EXCEPTION), on=\"prompt\")\n", - "\n", - "try:\n", - " guard(\n", - " openai.chat.completions.create,\n", - " prompt=\"My email address is not_a_real_email@guardrailsai.com\",\n", - " )\n", - "except ValidationError as e:\n", - " print(e)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": ".venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}