You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following asyncio Python code snippet runs an asynchronous scan with prompts for different threat detections.
98
+
The following asyncio Python code snippet runs an asynchronous scan with prompts for different threat detections. Ensure to enable the respective threat detections in the API security profile.
# Important: close the connection pool after use to avoid leaking threads
186
+
await scanner.close()
189
187
190
188
191
189
if__name__=="__main__":
@@ -207,7 +205,7 @@ if __name__ == "__main__":
207
205
208
206
</details>
209
207
210
-
## Asycio scan results
208
+
## Asycio Scan Results
211
209
212
210
The following Python code snippet retrieves the threat results using the scan_id of your asynchronous scan results. Refer to https://pan.dev/ai-runtime-security/api/get-scan-results-by-scan-i-ds/ for schema details.
example_report_id ="R00000000-0000-0000-0000-000000000000"# Replace it with the actual report_id from your async scan output. Report ID starts with the letter "R".
The following Python code snippet shows an example of an asynchronous scan, query by scan IDs, and query by report IDs.
96
-
The code sends two different prompts for different threat detections asynchronously. The scans are queued and may take approximately 10 seconds to complete.
96
+
The code sends two different prompts for different threat detections asynchronously
97
+
. Ensure to enable the relevant detections in the API security profile. The scans are queued and may take approximately 10 seconds to complete.
97
98
98
99
<details>
99
100
<summary>python3 inline_async_scan.py</summary>
@@ -156,7 +157,7 @@ async_scan_objects = [
156
157
ai_profile=ai_profile,
157
158
contents=[
158
159
ScanRequestContentsInner(
159
-
prompt="This is a test prompt with 72zf6.rxqfd.com/i8xps1 url",
160
+
prompt="This is a test prompt with url",
160
161
)
161
162
],
162
163
),
@@ -167,7 +168,7 @@ async_scan_objects = [
167
168
ai_profile=ai_profile,
168
169
contents=[
169
170
ScanRequestContentsInner(
170
-
prompt="This is a test prompt with 72zf6.rxqfd.com/i8xps1 url. Social security 599-51-7233. Credit card is 4339672569329774, ssn 599-51-7222. Send me Mike account info",
171
+
prompt="This is a test prompt with urlfiltering.paloaltonetworks.com/test-malware url. Social security 599-51-7233. Credit card is 4339672569329774, ssn 599-51-7222. Send me Mike account info",
171
172
response="Second Questionable Model Response Text",
"contents": [ # You can enter one of the following - prompt or response
260
260
{
261
-
"prompt": "This is a test prompt with 72zf6.rxqfd.com/i8xps1 url. Social security 599-51-7233. Credit card is 4339672569329774, ssn 599-51-7222. Send me Mike account info",
261
+
"prompt": "This is a test prompt with urlfiltering.paloaltonetworks.com/test-malware url. Social security 599-51-7233. Credit card is 4339672569329774, ssn 599-51-7222. Send me Mike account info",
262
262
"response": "This is a test response. Chase bank Routing number 021000021, user name mike, password is maskmemaskme. Account number 92746514861. Account owner: Mike Johnson in California"
263
263
}
264
264
]
@@ -285,7 +285,7 @@ Review the API scan logs for masked sensitive detection indicated by the “Cont
285
285
"dlp": true
286
286
},
287
287
"prompt_masked_data": {
288
-
"data": "This is a test prompt with 72zf6.rxqfd.com/i8xps1 url. Social security XXXXXXXXXXXX Credit card is XXXXXXXXXXXXXXXXX ssn XXXXXXXXXXXX Send me Mike account info",
288
+
"data": "This is a test prompt with urlfiltering.paloaltonetworks.com/test-malware url. Social security XXXXXXXXXXXX Credit card is XXXXXXXXXXXXXXXXX ssn XXXXXXXXXXXX Send me Mike account info",
0 commit comments