Skip to content

Commit 978c5dd

Browse files
authored
Update quickstart-custom-categories.md
1 parent df5a0f5 commit 978c5dd

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

articles/ai-services/content-safety/quickstart-custom-categories.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ms.date: 07/03/2024
1111
ms.author: pafarley
1212
---
1313

14+
# Custom categories (standard mode) (preview) User Flow
15+
16+
![image](https://github.com/user-attachments/assets/2a510f8c-9f88-461e-9082-64d5e05ce13a)
17+
1418
# Quickstart: Custom categories (standard mode) (preview)
1519

1620
Follow this guide to use Azure AI Content Safety Custom categories (standard) REST API to create your own content categories for your use case and train Azure AI Content Safety to detect them in new text content.
@@ -59,7 +63,21 @@ In the command below, replace `<your_api_key>`, `<your_endpoint>`, and other nec
5963
### Create new category version
6064

6165
```bash
62-
curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-version=2024-02-15-preview" \
66+
curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-version=2024-09-15-preview" \
67+
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
68+
-H "Content-Type: application/json" \
69+
-d "{
70+
\"categoryName\": \"survival-advice\",
71+
\"definition\": \"text prompts about survival advice in camping/wilderness situations\",
72+
\"sampleBlobUrl\": \"https://<your-azure-storage-url>/example-container/survival-advice.jsonl\"
73+
}"
74+
```
75+
> [!TIP]
76+
> Every time you change your category name, definition or samples, a new version will be created. You can use the version number to trace back to previous versions. Please remember this version number, as it will be required in the URL for the next step- training custom categories.
77+
### Get new category version
78+
79+
```bash
80+
curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-version=2024-09-15-preview" \
6381
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
6482
-H "Content-Type: application/json" \
6583
-d "{
@@ -71,10 +89,10 @@ curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-v
7189

7290
### Start the category build process:
7391

74-
Replace `<your_api_key>` and `<your_endpoint>` with your own values. Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly. After you receive the response, store the operation ID (referred to as `id`) in a temporary location. This ID will be necessary for retrieving the build status using the **Get status** API in the next section.
92+
Replace <your_api_key> and <your_endpoint> with your own values, and also **append the version number you obtained from the last step.** Allow enough time for model training: the end-to-end execution of custom category training can take from around five hours to ten hours. Plan your moderation pipeline accordingly. After you receive the response, store the operation ID (referred to as `id`) in a temporary location. This ID will be necessary for retrieving the build status using the **Get status** API in the next section.
7593

7694
```bash
77-
curl -X POST "<your_endpoint>/contentsafety/text/categories/survival-advice:build?api-version=2024-02-15-preview" \
95+
curl -X POST "<your_endpoint>/contentsafety/text/categories/survival-advice:build?api-version=2024-09-15-preview**&version={version}**" \
7896
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
7997
-H "Content-Type: application/json"
8098
```
@@ -83,7 +101,7 @@ curl -X POST "<your_endpoint>/contentsafety/text/categories/survival-advice:buil
83101
To retrieve the status, utilize the `id` obtained from the previous API response and place it in the path of the API below.
84102

85103
```bash
86-
curl -X GET "<your_endpoint>/contentsafety/text/categories/operations/<id>?api-version=2024-02-15-preview" \
104+
curl -X GET "<your_endpoint>/contentsafety/text/categories/operations/<id>?api-version=2024-09-15-preview" \
87105
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
88106
-H "Content-Type: application/json"
89107
```
@@ -93,7 +111,7 @@ curl -X GET "<your_endpoint>/contentsafety/text/categories/operations/<id>?api-v
93111
Run the following command to analyze text with your customized category. Replace `<your_api_key>` and `<your_endpoint>` with your own values.
94112

95113
```bash
96-
curl -X POST "<your_endpoint>/contentsafety/text:analyzeCustomCategory?api-version=2024-02-15-preview" \
114+
curl -X POST "<your_endpoint>/contentsafety/text:analyzeCustomCategory?api-version=2024-09-15-preview" \
97115
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
98116
-H "Content-Type: application/json" \
99117
-d "{
@@ -132,7 +150,7 @@ You can create a new category with *category name*, *definition* and *sample_blo
132150

133151
```python
134152
def create_new_category_version(category_name, definition, sample_blob_url):
135-
url = f"{ENDPOINT}/contentsafety/text/categories/{category_name}?api-version=2024-02-15-preview"
153+
url = f"{ENDPOINT}/contentsafety/text/categories/{category_name}?api-version=2024-09-15-preview"
136154
data = {
137155
"categoryName": category_name,
138156
"definition": definition,
@@ -156,7 +174,7 @@ You can start the category build process with the *category name* and *version n
156174

157175
```python
158176
def trigger_category_build_process(category_name, version):
159-
url = f"{ENDPOINT}/contentsafety/text/categories/{category_name}:build?api-version=2024-02-15-preview&version={version}"
177+
url = f"{ENDPOINT}/contentsafety/text/categories/{category_name}:build?api-version=2024-09-15-preview&version={version}"
160178
response = requests.post(url, headers=headers)
161179
return response.status_code
162180

@@ -174,7 +192,7 @@ To retrieve the status, utilize the `id` obtained from the previous response.
174192

175193
```python
176194
def get_build_status(id):
177-
url = f"{ENDPOINT}/contentsafety/text/categories/operations/{id}?api-version=2024-02-15-preview"
195+
url = f"{ENDPOINT}/contentsafety/text/categories/operations/{id}?api-version=2024-09-15-preview"
178196
response = requests.get(url, headers=headers)
179197
return response.status_code
180198

@@ -192,7 +210,7 @@ You need to specify the *category name* and the *version number* (optional; the
192210

193211
```python
194212
def analyze_text_with_customized_category(text, category_name, version):
195-
url = f"{ENDPOINT}/contentsafety/text:analyzeCustomCategory?api-version=2024-02-15-preview"
213+
url = f"{ENDPOINT}/contentsafety/text:analyzeCustomCategory?api-version=2024-09-15-preview"
196214
data = {
197215
"text": text,
198216
"categoryName": category_name,

0 commit comments

Comments
 (0)