Skip to content

Commit

Permalink
[Cognitive Services - Azure AI Content Safety] GA Restful API (#25498)
Browse files Browse the repository at this point in the history
* Add ga contract for Content Safety

* Update examples for 2023-10-01

* Resolve ModelValidation SpellCheck and Avocado

* Fix typo

* Fix minor errors in example and readme

* Fix example

* remove the 0430 content

* update readme

* re-format markdowm

* Fix example

* update blocklist example

* Add eight severity levels
  • Loading branch information
mengaims authored and jnlycklama committed Nov 8, 2023
1 parent 06c862b commit 4f3d1d0
Show file tree
Hide file tree
Showing 28 changed files with 1,546 additions and 204 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"title": "Add BlockItems To Text Blocklist",
"operationId": "TextBlocklists_AddBlockItems",
"title": "Add or Update BlocklistItems To Text Blocklist",
"operationId": "TextBlocklists_AddOrUpdateBlocklistItems",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist",
"body": {
"blockItems": [
"blocklistItems": [
{
"description": "Hate word",
"text": "hate"
Expand All @@ -16,9 +16,9 @@
"responses": {
"200": {
"body": {
"value": [
"blocklistItems": [
{
"blockItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"blocklistItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"description": "Hate word",
"text": "hate"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"title": "Analyze Image",
"operationId": "ImageOperations_AnalyzeImage",
"parameters": {
"api-version": "2023-10-01",
"body": {
"image": {
"content": "Y29udGVudDE="
}
}
},
"responses": {
"200": {
"body": {
"categoriesAnalysis": [
{
"category": "Hate",
"severity": 0
},
{
"category": "SelfHarm",
"severity": 0
},
{
"category": "Sexual",
"severity": 0
},
{
"category": "Violence",
"severity": 2
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"title": "Analyze Text",
"operationId": "TextOperations_AnalyzeText",
"parameters": {
"api-version": "2023-10-01",
"body": {
"text": "This is text example"
}
},
"responses": {
"200": {
"body": {
"blocklistsMatch": [],
"categoriesAnalysis": [
{
"category": "Hate",
"severity": 0
},
{
"category": "SelfHarm",
"severity": 0
},
{
"category": "Sexual",
"severity": 0
},
{
"category": "Violence",
"severity": 0
}
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Create Or Update Text Blocklist",
"operationId": "TextBlocklists_CreateOrUpdateTextBlocklist",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist",
"resource": {
"description": "Test Blocklist"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Delete Text Blocklist By blocklistName",
"operationId": "TextBlocklists_DeleteTextBlocklist",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Get Text Blocklist By blocklistName",
"operationId": "TextBlocklists_GetTextBlocklist",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"title": "Get BlockItem By blocklistName And blockItemId",
"title": "Get BlockItem By blocklistName And blocklistItemId",
"operationId": "TextBlocklists_GetTextBlocklistItem",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist",
"blockItemId": "9511969e-f1e3-4604-9127-05ee16c509ec"
"blocklistItemId": "9511969e-f1e3-4604-9127-05ee16c509ec"
},
"responses": {
"200": {
"body": {
"blockItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"blocklistItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"description": "Hate word",
"text": "hate"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"title": "Get All BlockItems By blocklistName",
"operationId": "TextBlocklists_ListTextBlocklistItems",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist"
},
"responses": {
"200": {
"body": {
"value": [
{
"blockItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"blocklistItemId": "9511969e-f1e3-4604-9127-05ee16c509ec",
"description": "Hate word",
"text": "hate"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Get All Text Blocklists",
"operationId": "TextBlocklists_ListTextBlocklists",
"parameters": {
"api-version": "2023-04-30-preview"
"api-version": "2023-10-01"
},
"responses": {
"200": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"title": "Remove BlockItems From Text Blocklist",
"operationId": "TextBlocklists_RemoveBlockItems",
"operationId": "TextBlocklists_RemoveBlocklistItems",
"parameters": {
"api-version": "2023-04-30-preview",
"api-version": "2023-10-01",
"blocklistName": "TestBlocklist",
"body": {
"blockItemIds": [
"blocklistItemIds": [
"9511969e-f1e3-4604-9127-05ee16c509ec"
]
}
Expand Down
13 changes: 11 additions & 2 deletions specification/cognitiveservices/ContentSafety/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ using Azure.Core;
title: "ContentSafety Service",
})
@versioned(ContentSafety.Versions)
@useAuth(ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key">)
@useAuth(
ApiKeyAuth<ApiKeyLocation.header, "Ocp-Apim-Subscription-Key"> | OAuth2Auth<[
{
type: OAuth2FlowType.clientCredentials,
tokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
refreshUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
scopes: ["https://cognitiveservices.azure.com/.default"],
}
]>
)
@server(
"{endpoint}/contentsafety",
"Analyze harmful content",
Expand All @@ -31,5 +40,5 @@ namespace ContentSafety;
#suppress "@azure-tools/typespec-azure-core/documentation-required" "https://github.com/Azure/typespec-azure/issues/3107"
enum Versions {
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
v2023_04_30_Preview: "2023-04-30-preview",
v2023_10_01: "2023-10-01",
}
Loading

0 comments on commit 4f3d1d0

Please sign in to comment.