Skip to content

Commit 2dce264

Browse files
authored
Merge pull request #123791 from Sayaka-4987/patch-2
Format Content Safety document
2 parents faeab25 + 10a3b47 commit 2dce264

File tree

5 files changed

+86
-93
lines changed

5 files changed

+86
-93
lines changed

articles/ai-services/content-safety/includes/quickstarts/rest-quickstart-image.md

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ curl --location --request POST '<endpoint>/contentsafety/image:analyze?api-versi
5151
"image": {
5252
"content": "<base_64_string>"
5353
},
54-
"categories": [
55-
"Hate", "SelfHarm", "Sexual", "Violence"
56-
],
54+
"categories": ["Hate", "SelfHarm", "Sexual", "Violence"],
5755
"outputType": "FourSeverityLevels"
5856
}'
5957
```
@@ -63,9 +61,9 @@ curl --location --request POST '<endpoint>/contentsafety/image:analyze?api-versi
6361
>
6462
> ```
6563
> {
66-
> "image": {
67-
> "blobUrl": "<your_storage_url>"
68-
> }
64+
> "image": {
65+
> "blobUrl": "<your_storage_url>"
66+
> }
6967
> }
7068
> ```
7169
@@ -91,24 +89,24 @@ You should see the image moderation results displayed as JSON data in the consol
9189
9290
```json
9391
{
94-
"categoriesAnalysis": [
95-
{
96-
"category": "Hate",
97-
"severity": 2
98-
},
99-
{
100-
"category": "SelfHarm",
101-
"severity": 0
102-
},
103-
{
104-
"category": "Sexual",
105-
"severity": 0
106-
},
107-
{
108-
"category": "Violence",
109-
"severity": 0
110-
}
111-
]
92+
"categoriesAnalysis": [
93+
{
94+
"category": "Hate",
95+
"severity": 2
96+
},
97+
{
98+
"category": "SelfHarm",
99+
"severity": 0
100+
},
101+
{
102+
"category": "Sexual",
103+
"severity": 0
104+
},
105+
{
106+
"category": "Violence",
107+
"severity": 0
108+
}
109+
]
112110
}
113111
```
114112

articles/ai-services/content-safety/includes/quickstarts/rest-quickstart-text.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ curl --location --request POST '<endpoint>/contentsafety/text:analyze?api-versio
3636
--header 'Content-Type: application/json' \
3737
--data-raw '{
3838
"text": "I hate you",
39-
"categories": [
40-
"Hate","Sexual","SelfHarm","Violence"
41-
],
42-
"blocklistNames": [
43-
"string"
44-
],
45-
"haltOnBlocklistHit": true,
46-
"outputType": "FourSeverityLevels"
39+
"categories": ["Hate", "Sexual", "SelfHarm", "Violence"],
40+
"blocklistNames": ["string"],
41+
"haltOnBlocklistHit": true,
42+
"outputType": "FourSeverityLevels"
4743
}'
4844
```
4945

@@ -68,12 +64,8 @@ See the following sample request body:
6864
```json
6965
{
7066
"text": "I hate you",
71-
"categories": [
72-
"Hate","Sexual","SelfHarm","Violence"
73-
],
74-
"blocklistNames": [
75-
"array"
76-
],
67+
"categories": ["Hate", "Sexual", "SelfHarm", "Violence"],
68+
"blocklistNames": ["array"],
7769
"haltOnBlocklistHit": false,
7870
"outputType": "FourSeverityLevels"
7971
}
@@ -96,21 +88,22 @@ You should see the text moderation results displayed as JSON data in the console
9688
}
9789
],
9890
"categoriesAnalysis": [
99-
{
100-
"category": "Hate",
101-
"severity": 2
102-
},
103-
{
104-
"category": "SelfHarm",
105-
"severity": 0
106-
},
107-
{
108-
"category": "Sexual",
109-
"severity": 0
110-
},
111-
{
112-
"category": "Violence",
113-
"severity": 0
91+
{
92+
"category": "Hate",
93+
"severity": 2
94+
},
95+
{
96+
"category": "SelfHarm",
97+
"severity": 0
98+
},
99+
{
100+
"category": "Sexual",
101+
"severity": 0
102+
},
103+
{
104+
"category": "Violence",
105+
"severity": 0
106+
}
114107
]
115108
}
116109
```

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ curl -X PUT "<your_endpoint>/contentsafety/text/categories/survival-advice?api-v
6161
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
6262
-H "Content-Type: application/json" \
6363
-d "{
64-
\"categoryName\": \"survival-advice\",
65-
\"definition\": \"text prompts about survival advice in camping/wilderness situations\",
66-
\"sampleBlobUrl\": \"https://<your-azure-storage-url>/example-container/survival-advice.jsonl\"
64+
\"categoryName\": \"survival-advice\",
65+
\"definition\": \"text prompts about survival advice in camping/wilderness situations\",
66+
\"sampleBlobUrl\": \"https://<your-azure-storage-url>/example-container/survival-advice.jsonl\"
6767
}"
6868
```
6969

@@ -95,9 +95,9 @@ curl -X POST "<your_endpoint>/contentsafety/text:analyzeCustomCategory?api-versi
9595
-H "Ocp-Apim-Subscription-Key: <your_api_key>" \
9696
-H "Content-Type: application/json" \
9797
-d "{
98-
\"text\": \"<Example text to analyze>\",
99-
\"categoryName\": \"survival-advice\",
100-
\"version\": 1
98+
\"text\": \"<Example text to analyze>\",
99+
\"categoryName\": \"survival-advice\",
100+
\"version\": 1
101101
}"
102102
```
103103

articles/ai-services/content-safety/quickstart-groundedness.md

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This section walks through a sample request with cURL. Paste the command below i
4545
"domain": "Generic",
4646
"task": "QnA",
4747
"qna": {
48-
"query": "How much does she currently get paid per hour at the bank?"
48+
"query": "How much does she currently get paid per hour at the bank?"
4949
},
5050
"text": "12/hour",
5151
"groundingSources": [
@@ -108,11 +108,13 @@ To test a summarization task instead of a question answering (QnA) task, use the
108108
109109
```json
110110
{
111-
"domain": "Medical",
112-
"task": "Summarization",
113-
"text": "Ms Johnson has been in the hospital after experiencing a stroke.",
114-
"groundingSources": ["Our patient, Ms. Johnson, presented with persistent fatigue, unexplained weight loss, and frequent night sweats. After a series of tests, she was diagnosed with Hodgkin’s lymphoma, a type of cancer that affects the lymphatic system. The diagnosis was confirmed through a lymph node biopsy revealing the presence of Reed-Sternberg cells, a characteristic of this disease. She was further staged using PET-CT scans. Her treatment plan includes chemotherapy and possibly radiation therapy, depending on her response to treatment. The medical team remains optimistic about her prognosis given the high cure rate of Hodgkin’s lymphoma."],
115-
"reasoning": false
111+
"domain": "Medical",
112+
"task": "Summarization",
113+
"text": "Ms Johnson has been in the hospital after experiencing a stroke.",
114+
"groundingSources": [
115+
"Our patient, Ms. Johnson, presented with persistent fatigue, unexplained weight loss, and frequent night sweats. After a series of tests, she was diagnosed with Hodgkin’s lymphoma, a type of cancer that affects the lymphatic system. The diagnosis was confirmed through a lymph node biopsy revealing the presence of Reed-Sternberg cells, a characteristic of this disease. She was further staged using PET-CT scans. Her treatment plan includes chemotherapy and possibly radiation therapy, depending on her response to treatment. The medical team remains optimistic about her prognosis given the high cure rate of Hodgkin’s lymphoma."
116+
],
117+
"reasoning": false
116118
}
117119
```
118120

@@ -140,13 +142,13 @@ After you submit your request, you'll receive a JSON response reflecting the Gro
140142

141143
```json
142144
{
143-
"ungroundedDetected": true,
144-
"ungroundedPercentage": 1,
145-
"ungroundedDetails": [
146-
{
147-
"text": "12/hour."
148-
}
149-
]
145+
"ungroundedDetected": true,
146+
"ungroundedPercentage": 1,
147+
"ungroundedDetails": [
148+
{
149+
"text": "12/hour."
150+
}
151+
]
150152
}
151153
```
152154

@@ -176,7 +178,7 @@ In order to use your Azure OpenAI GPT4-Turbo (1106-preview) resource to enable t
176178
In your request to the Groundedness detection API, set the `"reasoning"` body parameter to `true`, and provide the other needed parameters:
177179

178180
```json
179-
{
181+
{
180182
"reasoning": true,
181183
"llmResource": {
182184
"resourceType": "AzureOpenAI",
@@ -203,7 +205,7 @@ This section walks through a sample request with cURL. Paste the command below i
203205
"domain": "Generic",
204206
"task": "QnA",
205207
"qna": {
206-
"query": "How much does she currently get paid per hour at the bank?"
208+
"query": "How much does she currently get paid per hour at the bank?"
207209
},
208210
"text": "12/hour",
209211
"groundingSources": [
@@ -291,24 +293,24 @@ After you submit your request, you'll receive a JSON response reflecting the Gro
291293

292294
```json
293295
{
294-
"ungroundedDetected": true,
295-
"ungroundedPercentage": 1,
296-
"ungroundedDetails": [
297-
{
298-
"text": "12/hour.",
299-
"offset": {
300-
"utf8": 0,
301-
"utf16": 0,
302-
"codePoint": 0
303-
},
304-
"length": {
305-
"utf8": 8,
306-
"utf16": 8,
307-
"codePoint": 8
308-
},
309-
"reason": "None. The premise mentions a pay of \"10/hour\" but does not mention \"12/hour.\" It's neutral. "
310-
}
311-
]
296+
"ungroundedDetected": true,
297+
"ungroundedPercentage": 1,
298+
"ungroundedDetails": [
299+
{
300+
"text": "12/hour.",
301+
"offset": {
302+
"utf8": 0,
303+
"utf16": 0,
304+
"codePoint": 0
305+
},
306+
"length": {
307+
"utf8": 8,
308+
"utf16": 8,
309+
"codePoint": 8
310+
},
311+
"reason": "None. The premise mentions a pay of \"10/hour\" but does not mention \"12/hour.\" It's neutral. "
312+
}
313+
]
312314
}
313315
```
314316

articles/ai-services/content-safety/quickstart-protected-material.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ curl --location --request POST '<endpoint>/contentsafety/text:detectProtectedMat
3737
--header 'Ocp-Apim-Subscription-Key: <your_subscription_key>' \
3838
--header 'Content-Type: application/json' \
3939
--data-raw '{
40-
"text": "to everyone, the best things in life are free. the stars belong to everyone, they gleam there for you and me. the flowers in spring, the robins that sing, the sunbeams that shine, they\'re yours, they\'re mine. and love can come to everyone, the best things in life are"
40+
"text": "to everyone, the best things in life are free. the stars belong to everyone, they gleam there for you and me. the flowers in spring, the robins that sing, the sunbeams that shine"
4141
}'
4242
```
4343
The below fields must be included in the url:

0 commit comments

Comments
 (0)