Skip to content

Commit c24fca8

Browse files
committed
writer edits
1 parent 19f8561 commit c24fca8

File tree

1 file changed

+49
-34
lines changed

1 file changed

+49
-34
lines changed

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

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,16 @@ Follow this guide to use Azure AI Content Safety Groundedness detection to check
1717

1818
## Prerequisites
1919

20-
2120
* An Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services/)
2221
* Once you have your Azure subscription, <a href="https://aka.ms/acs-create" title="Create a Content Safety resource" target="_blank">create a Content Safety resource </a> in the Azure portal to get your key and endpoint. Enter a unique name for your resource, select your subscription, and select a resource group, supported region (East US2, West US, Sweden Central), and supported pricing tier. Then select **Create**.
2322
* The resource takes a few minutes to deploy. After it does, go to the new resource. In the left pane, under **Resource Management**, select **API Keys and Endpoints**. Copy one of the subscription key values and endpoint to a temporary location for later use.
23+
(Optional) If you want to use the _reasoning_ feature, create an Azure OpenAI Service resource with a GPT model deployed.
2424
* [cURL](https://curl.haxx.se/) or [Python](https://www.python.org/downloads/) installed.
2525

26-
## Check groundedness with reasinging
27-
28-
The Groundedness detection API provides the option to include _reasoning_ in the API response. In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
29-
30-
31-
### Enable reasoning with your own GPT deployment
32-
33-
If you want to use your Azure OpenAI resource to enable the reasoning feature, use Managed Identity to allow your Content Safety resource to access the Azure OpenAI resource first:
34-
35-
1. Enable Managed Identity for Azure AI Content Safety.
36-
37-
Navigate to your Azure AI Content Safety instance in the Azure portal. Find the **Identity** section under the **Settings** category. Enable the system-assigned managed identity. This action grants your Azure AI Content Safety instance an identity that can be recognized and used within Azure for accessing other resources.
38-
39-
:::image type="content" source="media/content-safety-identity.png" alt-text="Screenshot of a Content Safety identity resource in the Azure portal." lightbox="media/content-safety-identity.png":::
4026

41-
2. Assign Role to Managed Identity.
27+
## Check groundedness without reasoning
4228

43-
Navigate to your Azure OpenAI instance, select **Add role assignment** to start the process of assigning an Azure OpenAI role to the Azure AI Content Safety identity.
44-
45-
image type="content" source="media/add-role-assignment.png" alt-text="Screenshot of adding role assignment in Azure portal.":::
46-
47-
Choose the **User** or **Contributor** role.
48-
49-
:::image type="content" source="media/assigned-roles-simple.png" alt-text="Screenshot of the Azure portal with the Contributor and User roles displayed in a list." lightbox="media/assigned-roles-simple.png":::
50-
51-
52-
## Detect groundedness without Reasoning
29+
The Groundedness detection classifies the ungroundedness of the submitted content as `true` or `false` and provides a confidence score.
5330

5431
#### [cURL](#tab/curl)
5532

@@ -204,9 +181,34 @@ The JSON objects in the output are defined here:
204181
| - `length > utf16` | The length of the ungrounded text in UTF-16 encoding. | Integer |
205182
| - `length > codePoint` | The length of the ungrounded text in terms of Unicode code points. |Integer |
206183

207-
## Making a request with reasoning using the default resource
208184

209-
The Groundedness detection API provides the option to include _reasoning_ in the API response. In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
185+
## Check groundedness with reasoning
186+
187+
The Groundedness detection API provides the option to include _reasoning_ in the API response. With reasoning enabled, the response includes a `"reasoning"` field that details specific instances and explanations for any detected ungroundedness. Be careful: using reasoning increases the processing time and incurs extra fees.
188+
189+
### Bring your own GPT deployment
190+
191+
In order to use your Azure OpenAI resource to enable the reasoning feature, use Managed Identity to allow your Content Safety resource to access the Azure OpenAI resource:
192+
193+
1. Enable Managed Identity for Azure AI Content Safety.
194+
195+
Navigate to your Azure AI Content Safety instance in the Azure portal. Find the **Identity** section under the **Settings** category. Enable the system-assigned managed identity. This action grants your Azure AI Content Safety instance an identity that can be recognized and used within Azure for accessing other resources.
196+
197+
:::image type="content" source="media/content-safety-identity.png" alt-text="Screenshot of a Content Safety identity resource in the Azure portal." lightbox="media/content-safety-identity.png":::
198+
199+
1. Assign Role to Managed Identity.
200+
201+
Navigate to your Azure OpenAI instance, select **Add role assignment** to start the process of assigning an Azure OpenAI role to the Azure AI Content Safety identity.
202+
203+
:::image type="content" source="media/add-role-assignment.png" alt-text="Screenshot of adding role assignment in Azure portal.":::
204+
205+
Choose the **User** or **Contributor** role.
206+
207+
:::image type="content" source="media/assigned-roles-simple.png" alt-text="Screenshot of the Azure portal with the Contributor and User roles displayed in a list." lightbox="media/assigned-roles-simple.png":::
208+
209+
### Make the API request
210+
211+
In your request to the Groundedness detection API, set the `"Reasoning"` body parameter to `true`, and provide the other needed parameters:
210212

211213
```json
212214
{
@@ -219,8 +221,14 @@ The Groundedness detection API provides the option to include _reasoning_ in the
219221
}
220222
```
221223

224+
#### [cURL](#tab/curl)
225+
226+
This section walks through a sample request with cURL. Paste the command below into a text editor, and make the following changes.
227+
228+
1. Replace `<endpoint>` with the endpoint URL associated with your resource.
229+
1. Replace `<your_subscription_key>` with one of the keys for your resource.
230+
1. Optionally, replace the `"query"` or `"text"` fields in the body with your own text you'd like to analyze.
222231

223-
the response includes a `"reasoning"` field that details specific instances and explanations for any detected ungroundedness. If you opt to use reasoning, you must provide your own Azure OpenAI resources. Be careful: using reasoning increases the processing time and incurs extra fees. If you choose not to use reasoning, the API only classifies the ungroundedness of the submitted content as `true` or `false` and provides a confidence score.
224232

225233
```shell
226234
curl --location --request POST '<endpoint>/contentsafety/text:detectGroundedness?api-version=2024-02-15-preview' \
@@ -239,8 +247,8 @@ curl --location --request POST '<endpoint>/contentsafety/text:detectGroundedness
239247
"reasoning": true,
240248
"llmResource": {
241249
"resourceType": "AzureOpenAI",
242-
"azureOpenAIEndpoint": "string",
243-
"azureOpenAIDeploymentName": "string"
250+
"azureOpenAIEndpoint": "<your_OpenAI_endpoint>",
251+
"azureOpenAIDeploymentName": "<your_deployment_name>"
244252
}'
245253
```
246254

@@ -271,8 +279,8 @@ Create a new Python file named _quickstart.py_. Open the new file in your prefer
271279
"reasoning": True
272280
"llmResource": {
273281
"resourceType": "AzureOpenAI",
274-
"azureOpenAIEndpoint": "string",
275-
"azureOpenAIDeploymentName": "string"
282+
"azureOpenAIEndpoint": "<your_OpenAI_endpoint>",
283+
"azureOpenAIDeploymentName": "<your_deployment_name>"
276284
}
277285
})
278286
headers = {
@@ -285,6 +293,14 @@ Create a new Python file named _quickstart.py_. Open the new file in your prefer
285293
print(data.decode("utf-8"))
286294
```
287295

296+
1. Run the application with the `python` command:
297+
298+
```console
299+
python quickstart.py
300+
````
301+
302+
Wait a few moments to get the response.
303+
288304
---
289305

290306
The parameters in the request body are defined in this table:
@@ -304,7 +320,6 @@ The parameters in the request body are defined in this table:
304320
| - `azureOpenAIEndpoint `| Your endpoint URL for Azure OpenAI service. | String |
305321
| - `azureOpenAIDeploymentName` | The name of the specific GPT deployment to use. | String|
306322

307-
308323
### Interpret the API response
309324

310325
After you submit your request, you'll receive a JSON response reflecting the Groundedness analysis performed. Here’s what a typical output looks like:

0 commit comments

Comments
 (0)