Skip to content

Commit 45377f0

Browse files
author
Bharathi Srinivasan
committed
removing force install and clearing outputs
1 parent d8023cb commit 45377f0

File tree

1 file changed

+14
-137
lines changed

1 file changed

+14
-137
lines changed

responsible_ai/bedrock-guardrails/guardrails_for_code_modality.ipynb

Lines changed: 14 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -22,83 +22,20 @@
2222
},
2323
{
2424
"cell_type": "code",
25-
"execution_count": 10,
25+
"execution_count": null,
2626
"id": "716c8924",
2727
"metadata": {},
28-
"outputs": [
29-
{
30-
"name": "stdout",
31-
"output_type": "stream",
32-
"text": [
33-
"Looking in indexes: https://pypi.org/simple, https://plugin.us-east-1.prod.workshops.aws\n",
34-
"Collecting boto3\n",
35-
" Using cached boto3-1.41.0-py3-none-any.whl.metadata (6.8 kB)\n",
36-
"Collecting botocore<1.42.0,>=1.41.0 (from boto3)\n",
37-
" Using cached botocore-1.41.0-py3-none-any.whl.metadata (5.9 kB)\n",
38-
"Collecting jmespath<2.0.0,>=0.7.1 (from boto3)\n",
39-
" Using cached jmespath-1.0.1-py3-none-any.whl.metadata (7.6 kB)\n",
40-
"Collecting s3transfer<0.15.0,>=0.14.0 (from boto3)\n",
41-
" Using cached s3transfer-0.14.0-py3-none-any.whl.metadata (1.7 kB)\n",
42-
"Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.42.0,>=1.41.0->boto3)\n",
43-
" Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)\n",
44-
"Collecting urllib3!=2.2.0,<3,>=1.25.4 (from botocore<1.42.0,>=1.41.0->boto3)\n",
45-
" Using cached urllib3-2.5.0-py3-none-any.whl.metadata (6.5 kB)\n",
46-
"Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.42.0,>=1.41.0->boto3)\n",
47-
" Using cached six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)\n",
48-
"Using cached boto3-1.41.0-py3-none-any.whl (139 kB)\n",
49-
"Using cached botocore-1.41.0-py3-none-any.whl (14.2 MB)\n",
50-
"Using cached jmespath-1.0.1-py3-none-any.whl (20 kB)\n",
51-
"Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)\n",
52-
"Using cached s3transfer-0.14.0-py3-none-any.whl (85 kB)\n",
53-
"Using cached urllib3-2.5.0-py3-none-any.whl (129 kB)\n",
54-
"Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)\n",
55-
"Installing collected packages: urllib3, six, jmespath, python-dateutil, botocore, s3transfer, boto3\n",
56-
"\u001b[2K Attempting uninstall: urllib3\n",
57-
"\u001b[2K Found existing installation: urllib3 2.5.0\n",
58-
"\u001b[2K Uninstalling urllib3-2.5.0:\n",
59-
"\u001b[2K Successfully uninstalled urllib3-2.5.0\n",
60-
"\u001b[2K Attempting uninstall: six━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0/7\u001b[0m [urllib3]\n",
61-
"\u001b[2K Found existing installation: six 1.17.0━\u001b[0m \u001b[32m0/7\u001b[0m [urllib3]\n",
62-
"\u001b[2K Uninstalling six-1.17.0:━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0/7\u001b[0m [urllib3]\n",
63-
"\u001b[2K Successfully uninstalled six-1.17.0━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1/7\u001b[0m [six]\n",
64-
"\u001b[2K Attempting uninstall: jmespath━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1/7\u001b[0m [six]\n",
65-
"\u001b[2K Found existing installation: jmespath 1.0.1━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1/7\u001b[0m [six]\n",
66-
"\u001b[2K Uninstalling jmespath-1.0.1:━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1/7\u001b[0m [six]\n",
67-
"\u001b[2K Successfully uninstalled jmespath-1.0.1━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1/7\u001b[0m [six]\n",
68-
"\u001b[2K Attempting uninstall: python-dateutil━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
69-
"\u001b[2K Found existing installation: python-dateutil 2.9.0.post0━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
70-
"\u001b[2K Uninstalling python-dateutil-2.9.0.post0:━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
71-
"\u001b[2K Successfully uninstalled python-dateutil-2.9.0.post0━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
72-
"\u001b[2K Attempting uninstall: botocore0m━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
73-
"\u001b[2K Found existing installation: botocore 1.41.0━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
74-
"\u001b[2K Uninstalling botocore-1.41.0:m━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2/7\u001b[0m [jmespath]\n",
75-
"\u001b[2K Successfully uninstalled botocore-1.41.090m━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4/7\u001b[0m [botocore]\n",
76-
"\u001b[2K Attempting uninstall: s3transfer\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4/7\u001b[0m [botocore]\n",
77-
"\u001b[2K Found existing installation: s3transfer 0.14.0━━━━━━━━━━━━\u001b[0m \u001b[32m4/7\u001b[0m [botocore]\n",
78-
"\u001b[2K Uninstalling s3transfer-0.14.0:╸\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4/7\u001b[0m [botocore]\n",
79-
"\u001b[2K Successfully uninstalled s3transfer-0.14.0━━━━━━━━━━━━━━\u001b[0m \u001b[32m4/7\u001b[0m [botocore]\n",
80-
"\u001b[2K Attempting uninstall: boto3━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━\u001b[0m \u001b[32m5/7\u001b[0m [s3transfer]\n",
81-
"\u001b[2K Found existing installation: boto3 1.41.0m\u001b[90m━━━━━━━━━━━\u001b[0m \u001b[32m5/7\u001b[0m [s3transfer]\n",
82-
"\u001b[2K Uninstalling boto3-1.41.0:━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━\u001b[0m \u001b[32m5/7\u001b[0m [s3transfer]\n",
83-
"\u001b[2K Successfully uninstalled boto3-1.41.0[0m\u001b[90m━━━━━━━━━━━\u001b[0m \u001b[32m5/7\u001b[0m [s3transfer]\n",
84-
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7/7\u001b[0m [boto3]32m6/7\u001b[0m [boto3]]\n",
85-
"\u001b[1A\u001b[2KSuccessfully installed boto3-1.41.0 botocore-1.41.0 jmespath-1.0.1 python-dateutil-2.9.0.post0 s3transfer-0.14.0 six-1.17.0 urllib3-2.5.0\n",
86-
"\n",
87-
"\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;49m25.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n",
88-
"\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;49mpip3 install --upgrade pip\u001b[0m\n"
89-
]
90-
}
91-
],
28+
"outputs": [],
9229
"source": [
9330
"#Start by installing the dependencies to ensure we have a recent version\n",
94-
"!pip install --upgrade --force-reinstall boto3\n",
31+
"!pip install --upgrade boto3\n",
9532
"import boto3\n",
9633
"import json"
9734
]
9835
},
9936
{
10037
"cell_type": "code",
101-
"execution_count": 9,
38+
"execution_count": null,
10239
"id": "2ba9275e",
10340
"metadata": {},
10441
"outputs": [],
@@ -133,18 +70,10 @@
13370
},
13471
{
13572
"cell_type": "code",
136-
"execution_count": 5,
73+
"execution_count": null,
13774
"id": "13c291fc",
13875
"metadata": {},
139-
"outputs": [
140-
{
141-
"name": "stdout",
142-
"output_type": "stream",
143-
"text": [
144-
"{'ResponseMetadata': {'RequestId': '8dc78e1b-0727-409b-99b2-171a1df08146', 'HTTPStatusCode': 202, 'HTTPHeaders': {'date': 'Thu, 20 Nov 2025 02:18:57 GMT', 'content-type': 'application/json', 'content-length': '172', 'connection': 'keep-alive', 'x-amzn-requestid': '8dc78e1b-0727-409b-99b2-171a1df08146'}, 'RetryAttempts': 0}, 'guardrailId': '0v2ve519giw9', 'guardrailArn': 'arn:aws:bedrock:us-east-1:686642339053:guardrail/0v2ve519giw9', 'version': 'DRAFT', 'createdAt': datetime.datetime(2025, 11, 20, 2, 18, 57, 659905, tzinfo=tzutc())}\n"
145-
]
146-
}
147-
],
76+
"outputs": [],
14877
"source": [
14978
"create_response = client.create_guardrail(\n",
15079
" name='code-modality-guardrail',\n",
@@ -231,7 +160,7 @@
231160
},
232161
{
233162
"cell_type": "code",
234-
"execution_count": 11,
163+
"execution_count": null,
235164
"id": "ab0a32d5",
236165
"metadata": {},
237166
"outputs": [],
@@ -242,23 +171,10 @@
242171
},
243172
{
244173
"cell_type": "code",
245-
"execution_count": 24,
174+
"execution_count": null,
246175
"id": "cc843d1b",
247176
"metadata": {},
248-
"outputs": [
249-
{
250-
"name": "stdout",
251-
"output_type": "stream",
252-
"text": [
253-
"API Response Elements:\n",
254-
"Response of Guardrail: GUARDRAIL_INTERVENED\n",
255-
"\n",
256-
"Content Policy Assessment:\n",
257-
" Type: PROMPT_ATTACK | Confidence: HIGH | Action: BLOCKED\n",
258-
" Type: MISCONDUCT | Confidence: LOW | Action: BLOCKED\n"
259-
]
260-
}
261-
],
177+
"outputs": [],
262178
"source": [
263179
"# Example of Input Prompt with harmful intent\n",
264180
"# Notice the output \n",
@@ -308,25 +224,10 @@
308224
},
309225
{
310226
"cell_type": "code",
311-
"execution_count": 18,
227+
"execution_count": null,
312228
"id": "e90191c5",
313229
"metadata": {},
314-
"outputs": [
315-
{
316-
"name": "stdout",
317-
"output_type": "stream",
318-
"text": [
319-
"API Response Elements:\n",
320-
"Response of Guardrail: GUARDRAIL_INTERVENED\n",
321-
"\n",
322-
"Content Policy Assessment:\n",
323-
" Type: MISCONDUCT | Confidence: HIGH | Action: BLOCKED\n",
324-
"\n",
325-
"Sensitive Information Policy Assessment:\n",
326-
" Found: US_SOCIAL_SECURITY_NUMBER | Match: '123-45-6789' | Action: BLOCKED\n"
327-
]
328-
}
329-
],
230+
"outputs": [],
330231
"source": [
331232
"# Example of Input Prompt with harmful intent\n",
332233
"# Notice the output \n",
@@ -387,19 +288,7 @@
387288
"execution_count": null,
388289
"id": "d0eb65b1",
389290
"metadata": {},
390-
"outputs": [
391-
{
392-
"name": "stdout",
393-
"output_type": "stream",
394-
"text": [
395-
"API Response Elements:\n",
396-
"Response of Guardrail: GUARDRAIL_INTERVENED\n",
397-
"\n",
398-
"Content Policy Assessment:\n",
399-
" Type: HATE | Confidence: HIGH | Action: BLOCKED\n"
400-
]
401-
}
402-
],
291+
"outputs": [],
403292
"source": [
404293
"# Example of Input Prompt with harmful intent\n",
405294
"# Notice the output \n",
@@ -439,22 +328,10 @@
439328
},
440329
{
441330
"cell_type": "code",
442-
"execution_count": 23,
331+
"execution_count": null,
443332
"id": "a9ceddb1",
444333
"metadata": {},
445-
"outputs": [
446-
{
447-
"name": "stdout",
448-
"output_type": "stream",
449-
"text": [
450-
"API Response Elements:\n",
451-
"Response of Guardrail: GUARDRAIL_INTERVENED\n",
452-
"\n",
453-
"Topic Policy Assessment:\n",
454-
" Topic Name: N/A | Action: BLOCKED\n"
455-
]
456-
}
457-
],
334+
"outputs": [],
458335
"source": [
459336
"# Example of Input Prompt with harmful intent\n",
460337
"# Notice the output \n",

0 commit comments

Comments
 (0)