Skip to content

Commit cc965e6

Browse files
committed
update
1 parent 32f1346 commit cc965e6

File tree

1 file changed

+91
-5
lines changed

1 file changed

+91
-5
lines changed

articles/ai-services/openai/concepts/content-filter.md

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ import os
325325
from openai import AzureOpenAI
326326
client = AzureOpenAI(
327327
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
328-
api_version="2023-10-01-preview",
328+
api_version="2024-03-01-preview",
329329
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
330330
)
331331

@@ -339,6 +339,92 @@ response = client.completions.create(
339339
print(response.model_dump_json(indent=2))
340340
```
341341

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+
342428
# [OpenAI Python 0.28.1](#tab/python)
343429

344430
```python
@@ -348,11 +434,11 @@ import os
348434
import openai
349435
openai.api_type = "azure"
350436
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
352438
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
353439

354440
response = openai.Completion.create(
355-
engine="gpt-35-turbo", # engine = "deployment_name".
441+
engine="gpt-35-turbo-instruct", # engine = "deployment_name".
356442
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,
357443
# while content detected at severity level low isn't filtered by the content filters.
358444
)
@@ -407,7 +493,7 @@ print(response)
407493
],
408494
"created": 1699386280,
409495
"id": "chatcmpl-8IMI4HzcmcK6I77vpOJCPt0Vcf8zJ",
410-
"model": "gpt-35-turbo",
496+
"model": "gpt-35-turbo-instruct",
411497
"object": "chat.completion",
412498
"prompt_filter_results": [
413499
{
@@ -457,7 +543,7 @@ import os
457543
import openai
458544
openai.api_type = "azure"
459545
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
461547
openai.api_key = os.getenv("AZURE_OPENAI_API_KEY")
462548

463549
try:

0 commit comments

Comments
 (0)