@@ -325,7 +325,7 @@ import os
325
325
from openai import AzureOpenAI
326
326
client = AzureOpenAI(
327
327
api_key = os.getenv(" AZURE_OPENAI_API_KEY" ),
328
- api_version = " 2023-10 -01-preview" ,
328
+ api_version = " 2024-03 -01-preview" ,
329
329
azure_endpoint = os.getenv(" AZURE_OPENAI_ENDPOINT" )
330
330
)
331
331
@@ -339,6 +339,92 @@ response = client.completions.create(
339
339
print (response.model_dump_json(indent = 2 ))
340
340
```
341
341
342
+ ### Output
343
+
344
+ ``` json
345
+ {
346
+ "choices" : [
347
+ {
348
+ "content_filter_results" : {
349
+ "hate" : {
350
+ "filtered" : false ,
351
+ "severity" : " safe"
352
+ },
353
+ "protected_material_code" : {
354
+ "citation" : {
355
+ "URL" : " https://github.com/username/repository-name/path/to/file-example.txt" ,
356
+ "license" : " EXAMPLE-LICENSE"
357
+ },
358
+ "detected" : true ,
359
+ "filtered" : false
360
+ },
361
+ "protected_material_text" : {
362
+ "detected" : false ,
363
+ "filtered" : false
364
+ },
365
+ "self_harm" : {
366
+ "filtered" : false ,
367
+ "severity" : " safe"
368
+ },
369
+ "sexual" : {
370
+ "filtered" : false ,
371
+ "severity" : " safe"
372
+ },
373
+ "violence" : {
374
+ "filtered" : false ,
375
+ "severity" : " safe"
376
+ }
377
+ },
378
+ "finish_reason" : " stop" ,
379
+ "index" : 0 ,
380
+ "message" : {
381
+ "content" : " Example model response will be returned " ,
382
+ "role" : " assistant"
383
+ }
384
+ }
385
+ ],
386
+ "created" : 1699386280 ,
387
+ "id" : " chatcmpl-8IMI4HzcmcK6I77vpOJCPt0Vcf8zJ" ,
388
+ "model" : " gpt-35-turbo-instruct" ,
389
+ "object" : " chat.completion" ,
390
+ "prompt_filter_results" : [
391
+ {
392
+ "content_filter_results" : {
393
+ "hate" : {
394
+ "filtered" : false ,
395
+ "severity" : " safe"
396
+ },
397
+ "jailbreak" : {
398
+ "detected" : false ,
399
+ "filtered" : false
400
+ },
401
+ "profanity" : {
402
+ "detected" : false ,
403
+ "filtered" : false
404
+ },
405
+ "self_harm" : {
406
+ "filtered" : false ,
407
+ "severity" : " safe"
408
+ },
409
+ "sexual" : {
410
+ "filtered" : false ,
411
+ "severity" : " safe"
412
+ },
413
+ "violence" : {
414
+ "filtered" : false ,
415
+ "severity" : " safe"
416
+ }
417
+ },
418
+ "prompt_index" : 0
419
+ }
420
+ ],
421
+ "usage" : {
422
+ "completion_tokens" : 40 ,
423
+ "prompt_tokens" : 11 ,
424
+ "total_tokens" : 417
425
+ }
426
+ }
427
+
342
428
# [OpenAI Python 0.28.1](#tab/python)
343
429
344
430
```python
@@ -348,11 +434,11 @@ import os
348
434
import openai
349
435
openai.api_type = "azure"
350
436
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT")
351
- openai.api_version = " 2023-06 -01-preview" # API version required to use Annotations
437
+ openai.api_version = "2024-03 -01-preview" # API version required to use Annotations
352
438
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
353
439
354
440
response = openai.Completion.create(
355
- engine = " gpt-35-turbo" , # engine = "deployment_name".
441
+ engine="gpt-35-turbo-instruct ", # engine = "deployment_name".
356
442
messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Example prompt that leads to a protected code completion that was detected, but not filtered"}] # Content that is detected at severity level medium or high is filtered,
357
443
# while content detected at severity level low isn't filtered by the content filters.
358
444
)
@@ -407,7 +493,7 @@ print(response)
407
493
],
408
494
"created" : 1699386280 ,
409
495
"id" : " chatcmpl-8IMI4HzcmcK6I77vpOJCPt0Vcf8zJ" ,
410
- "model" : " gpt-35-turbo" ,
496
+ "model" : " gpt-35-turbo-instruct " ,
411
497
"object" : " chat.completion" ,
412
498
"prompt_filter_results" : [
413
499
{
@@ -457,7 +543,7 @@ import os
457
543
import openai
458
544
openai.api_type = " azure"
459
545
openai.api_base = os.getenv(" AZURE_OPENAI_ENDPOINT" )
460
- openai.api_version = " 2023-06 -01-preview" # API version required to use Annotations
546
+ openai.api_version = " 2024-03 -01-preview" # API version required to use Annotations
461
547
openai.api_key = os.getenv(" AZURE_OPENAI_API_KEY" )
462
548
463
549
try :
0 commit comments