Skip to content

Commit 729293c

Browse files
committed
update
1 parent 77713cc commit 729293c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: mrbullwinkle
66
ms.author: mbullwin
77
ms.service: azure-ai-openai
88
ms.topic: conceptual
9-
ms.date: 09/15/2023
9+
ms.date: 11/06/2023
1010
ms.custom: template-concept
1111
manager: nitinme
1212
keywords:
@@ -294,11 +294,10 @@ When annotations are enabled as shown in the code snippet below, the following i
294294

295295
Annotations are currently in preview for Completions and Chat Completions (GPT models); the following code snippet shows how to use annotations in preview:
296296

297-
# [Python](#tab/python)
297+
# [OpenAI Python 0.28.1](#tab/python)
298298

299299

300300
```python
301-
# Note: The openai-python library support for Azure OpenAI is in preview.
302301
# os.getenv() for the endpoint and key assumes that you are using environment variables.
303302

304303
import os
@@ -387,7 +386,6 @@ print(response)
387386
The following code snippet shows how to retrieve annotations when content was filtered:
388387

389388
```python
390-
# Note: The openai-python library support for Azure OpenAI is in preview.
391389
# os.getenv() for the endpoint and key assumes that you are using environment variables.
392390

393391
import os
@@ -416,6 +414,29 @@ except openai.error.InvalidRequestError as e:
416414

417415
```
418416

417+
# [OpenAI Python 1.x](#tab/python-new)
418+
419+
```python
420+
# os.getenv() for the endpoint and key assumes that you are using environment variables.
421+
422+
import os
423+
from openai import AzureOpenAI
424+
client = AzureOpenAI(
425+
api_key=os.getenv("AZURE_OPENAI_KEY"),
426+
api_version="2023-10-01-preview",
427+
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
428+
)
429+
430+
response = client.completions.create(
431+
model="gpt-35-turbo-instruct", # model = "deployment_name".
432+
prompt="{Example prompt where a severity level of low is detected}"
433+
# Content that is detected at severity level medium or high is filtered,
434+
# while content detected at severity level low isn't filtered by the content filters.
435+
)
436+
437+
print(response.model_dump_json(indent=2))
438+
```
439+
419440
# [JavaScript](#tab/javascrit)
420441

421442
[Azure OpenAI JavaScript SDK source code & samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/openai/openai)

0 commit comments

Comments
 (0)