From 41076720e9e40114cb09dae3348cc398edf0f405 Mon Sep 17 00:00:00 2001 From: mengaims Date: Wed, 18 Oct 2023 17:51:37 +0800 Subject: [PATCH 1/2] Adaptive annotation service contract --- .../cognitiveservices/ContentSafety/main.tsp | 3 + .../ContentSafety/models.tsp | 78 + .../ContentSafety/routes.tsp | 30 + .../2023-10-30-preview/contentsafety.json | 1398 +++++++++++++++++ 4 files changed, 1509 insertions(+) create mode 100644 specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json diff --git a/specification/cognitiveservices/ContentSafety/main.tsp b/specification/cognitiveservices/ContentSafety/main.tsp index 1a746db9fd1d..a84687b1738c 100644 --- a/specification/cognitiveservices/ContentSafety/main.tsp +++ b/specification/cognitiveservices/ContentSafety/main.tsp @@ -41,4 +41,7 @@ namespace ContentSafety; enum Versions { @useDependency(Azure.Core.Versions.v1_0_Preview_2) v2023_10_01: "2023-10-01", + + @useDependency(Azure.Core.Versions.v1_0_Preview_2) + v2023_10_30_Preview: "2023-10-30-preview", } diff --git a/specification/cognitiveservices/ContentSafety/models.tsp b/specification/cognitiveservices/ContentSafety/models.tsp index a97f8a1b1bd1..5e129d8991f3 100644 --- a/specification/cognitiveservices/ContentSafety/models.tsp +++ b/specification/cognitiveservices/ContentSafety/models.tsp @@ -180,3 +180,81 @@ model RemoveTextBlocklistItemsOptions { @doc("Array of blocklistItemIds to remove.") blocklistItemIds: string[]; } + +#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update" +@doc("Text analyze category.") +@added(Versions.v2023_10_30_Preview) +enum AnnotateTextBuiltinCategory { + Hate, + SelfHarm, + Sexual, + Violence, +} + +@doc("Annotate text options") +@added(Versions.v2023_10_30_Preview) +model AnnotateTextOptions { + @doc("The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request.") + @maxLength(10000) + text: string; + + @doc("The category will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned.") + category?: AnnotateTextBuiltinCategory; +} + +@doc("The text annotation response.") +@added(Versions.v2023_10_30_Preview) +model AnnotateTextResult { + @doc("The label.") + label: int32; + + @doc("The reasoning.") + reasoning?: string; +} + +@added(Versions.v2023_10_30_Preview) +@doc("Pre-defined concept.") +model PreDefinedConcept { + concept: string; + description: string; +} + +@added(Versions.v2023_10_30_Preview) +@doc("Label definition.") +model Label { + label: integer; + labelName?: string; + scenarios: string[]; +} + +@added(Versions.v2023_10_30_Preview) +@doc("Text Customized categories.") +@resource("text/customizedCategories") +model TextCustomizedCategory { + @doc("Text customizedCategories name.") + @pattern("^Customized_[0-9A-Za-z._~-]+$") + @key("categoryName") + @visibility("read", "create", "query") + @maxLength(64) + categoryName: string; + + preDefinedConcepts?: PreDefinedConcept[]; + labels: Label[]; + emphasis?: string[]; + exampleBlobUrl?: url; +} + +@doc("The text annotation response.") +@added(Versions.v2023_10_30_Preview) +@resource("text/customizedCategories/operations") +model TextCustomizedCategoryOperation { + @doc("The operation id.") + @key("operationId") + operationId: int32; + + @doc("The status.") + status: string; + + @doc("The reason of failure.") + error?: string; +} diff --git a/specification/cognitiveservices/ContentSafety/routes.tsp b/specification/cognitiveservices/ContentSafety/routes.tsp index 1e3893cf987f..ada52c1bdc79 100644 --- a/specification/cognitiveservices/ContentSafety/routes.tsp +++ b/specification/cognitiveservices/ContentSafety/routes.tsp @@ -90,3 +90,33 @@ interface TextBlocklists { ListQueryParametersTrait >; } + +@added(Versions.v2023_10_30_Preview) +interface PromptTextOperations { + @summary("Annotate Text by Prompt") + @route("/text:adaptiveAnnotate") + @post + annotateText is Azure.Core.RpcOperation< + { + @body + @doc("The text analysis request.") + body: AnnotateTextOptions; + }, + AnnotateTextResult + >; +} + +@added(Versions.v2023_10_30_Preview) +interface TextCategoryCustomization { + createOrReplaceTextCustomizedCategory is ResourceCreateOrReplace; + + getTextCustomizedCategory is ResourceRead; + + deleteTextCustomizedCategory is ResourceDelete; + + @route("/text/customizedCategories/operations/{operationId}") + @get + getTextCustomizedCategoryOperation( + @path operationId: string, + ): TextCustomizedCategoryOperation; +} diff --git a/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json b/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json new file mode 100644 index 000000000000..fca2d0d2e06f --- /dev/null +++ b/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json @@ -0,0 +1,1398 @@ +{ + "swagger": "2.0", + "info": { + "title": "ContentSafety Service", + "version": "2023-10-30-preview", + "description": "Analyze harmful content", + "x-typespec-generated": [ + { + "emitter": "@azure-tools/typespec-autorest" + } + ] + }, + "schemes": [ + "https" + ], + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}/contentsafety", + "useSchemePrefix": false, + "parameters": [ + { + "name": "endpoint", + "in": "path", + "description": "Supported Cognitive Services endpoints (protocol and hostname, for example:\nhttps://.cognitiveservices.azure.com).", + "required": true, + "type": "string" + } + ] + }, + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "security": [ + { + "ApiKeyAuth": [] + }, + { + "OAuth2Auth": [ + "https://cognitiveservices.azure.com/.default" + ] + } + ], + "securityDefinitions": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "Ocp-Apim-Subscription-Key", + "in": "header" + }, + "OAuth2Auth": { + "type": "oauth2", + "flow": "application", + "scopes": { + "https://cognitiveservices.azure.com/.default": "" + }, + "tokenUrl": "https://login.microsoftonline.com/common/oauth2/v2.0/token" + } + }, + "tags": [], + "paths": { + "/image:analyze": { + "post": { + "operationId": "ImageOperations_AnalyzeImage", + "summary": "Analyze Image", + "description": "A synchronous API for the analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "body", + "in": "body", + "description": "The image analysis request.", + "required": true, + "schema": { + "$ref": "#/definitions/AnalyzeImageOptions" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/AnalyzeImageResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/blocklists": { + "get": { + "operationId": "TextBlocklists_ListTextBlocklists", + "summary": "Get All Text Blocklists", + "description": "Get all text blocklists details.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/PagedTextBlocklist" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/text/blocklists/{blocklistName}": { + "get": { + "operationId": "TextBlocklists_GetTextBlocklist", + "summary": "Get Text Blocklist By blocklistName", + "description": "Returns text blocklist details.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextBlocklist" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + }, + "patch": { + "operationId": "TextBlocklists_CreateOrUpdateTextBlocklist", + "summary": "Create Or Update Text Blocklist", + "description": "Updates a text blocklist. If the blocklistName does not exist, a new blocklist will be created.", + "consumes": [ + "application/merge-patch+json" + ], + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + }, + { + "name": "resource", + "in": "body", + "description": "The resource instance.", + "required": true, + "schema": { + "$ref": "#/definitions/TextBlocklistCreateOrUpdate" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextBlocklist" + } + }, + "201": { + "description": "The request has succeeded and a new resource has been created as a result.", + "schema": { + "$ref": "#/definitions/TextBlocklist" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + }, + "delete": { + "operationId": "TextBlocklists_DeleteTextBlocklist", + "summary": "Delete Text Blocklist By blocklistName", + "description": "Deletes a text blocklist.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/blocklists/{blocklistName}:addOrUpdateBlocklistItems": { + "post": { + "operationId": "TextBlocklists_AddOrUpdateBlocklistItems", + "summary": "Add or update BlocklistItems To Text Blocklist", + "description": "Add or update blocklistItems to a text blocklist. You can add or update at most 100 blocklistItems in one request.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/AddOrUpdateTextBlocklistItemsOptions" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/AddOrUpdateTextBlocklistItemsResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/blocklists/{blocklistName}:removeBlocklistItems": { + "post": { + "operationId": "TextBlocklists_RemoveBlocklistItems", + "summary": "Remove BlocklistItems From Text Blocklist", + "description": "Remove blocklistItems from a text blocklist. You can remove at most 100 BlocklistItems in one request.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/RemoveTextBlocklistItemsOptions" + } + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/blocklists/{blocklistName}/blocklistItems": { + "get": { + "operationId": "TextBlocklists_ListTextBlocklistItems", + "summary": "Get All BlocklistItems By blocklistName", + "description": "Get all blocklistItems in a text blocklist.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + }, + { + "$ref": "#/parameters/Azure.Core.TopQueryParameter" + }, + { + "$ref": "#/parameters/Azure.Core.SkipQueryParameter" + }, + { + "$ref": "#/parameters/Azure.Core.MaxPageSizeQueryParameter" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/PagedTextBlocklistItem" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + }, + "/text/blocklists/{blocklistName}/blocklistItems/{blocklistItemId}": { + "get": { + "operationId": "TextBlocklists_GetTextBlocklistItem", + "summary": "Get BlocklistItem By blocklistName And blocklistItemId", + "description": "Get blocklistItem by blocklistName and blocklistItemId from a text blocklist.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "blocklistName", + "in": "path", + "description": "Text blocklist name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$" + }, + { + "name": "blocklistItemId", + "in": "path", + "description": "The service will generate a BlocklistItemId, which will be a UUID.", + "required": true, + "type": "string", + "maxLength": 64 + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextBlocklistItem" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/customizedCategories/{categoryName}": { + "get": { + "operationId": "TextCategoryCustomization_GetTextCustomizedCategory", + "description": "DEPRECATED: Use `ResourceRead` from a `ResourceOperations` interface instance.\nThis can be done by instantiating your own version with the traits you want `alias Operations = Azure.Core.ResourceOperations;`.\nSee https://azure.github.io/typespec-azure/docs/getstarted/azure-core/step05#defining-the-operation-interface for details on how to use.\n\nOperation signature to retrieve a resource.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "categoryName", + "in": "path", + "description": "Text customizedCategories name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^Customized_[0-9A-Za-z._~-]+$" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextCustomizedCategory" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + }, + "put": { + "operationId": "TextCategoryCustomization_CreateOrReplaceTextCustomizedCategory", + "description": "DEPRECATED: Use `ResourceCreateOrReplace` from a `ResourceOperations` interface instance.\nThis can be done by instantiating your own version with the traits you want `alias Operations = Azure.Core.ResourceOperations;`.\nSee https://azure.github.io/typespec-azure/docs/getstarted/azure-core/step05#defining-the-operation-interface for details on how to use.\n\nOperation signature to create or replace a resource.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "categoryName", + "in": "path", + "description": "Text customizedCategories name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^Customized_[0-9A-Za-z._~-]+$" + }, + { + "name": "resource", + "in": "body", + "description": "The resource instance.", + "required": true, + "schema": { + "$ref": "#/definitions/TextCustomizedCategory" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextCustomizedCategory" + } + }, + "201": { + "description": "The request has succeeded and a new resource has been created as a result.", + "schema": { + "$ref": "#/definitions/TextCustomizedCategory" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + }, + "delete": { + "operationId": "TextCategoryCustomization_DeleteTextCustomizedCategory", + "description": "DEPRECATED: Use `ResourceDelete` from a `ResourceOperations` interface instance.\nThis can be done by instantiating your own version with the traits you want `alias Operations = Azure.Core.ResourceOperations;`.\nSee https://azure.github.io/typespec-azure/docs/getstarted/azure-core/step05#defining-the-operation-interface for details on how to use.\n\nOperation signature to delete a resource.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "categoryName", + "in": "path", + "description": "Text customizedCategories name.", + "required": true, + "type": "string", + "maxLength": 64, + "pattern": "^Customized_[0-9A-Za-z._~-]+$" + } + ], + "responses": { + "204": { + "description": "There is no content to send for this request, but the headers may be useful. " + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text/customizedCategories/operations/{operationId}": { + "get": { + "operationId": "TextCategoryCustomization_GetTextCustomizedCategoryOperation", + "parameters": [ + { + "name": "operationId", + "in": "path", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/TextCustomizedCategoryOperation" + } + } + } + } + }, + "/text:adaptiveAnnotate": { + "post": { + "operationId": "PromptTextOperations_AnnotateText", + "summary": "Annotate Text by Prompt", + "description": "A remote procedure call (RPC) operation.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "body", + "in": "body", + "description": "The text analysis request.", + "required": true, + "schema": { + "$ref": "#/definitions/AnnotateTextOptions" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/AnnotateTextResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + }, + "/text:analyze": { + "post": { + "operationId": "TextOperations_AnalyzeText", + "summary": "Analyze Text", + "description": "A synchronous API for the analysis of potentially harmful text content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence.", + "parameters": [ + { + "$ref": "#/parameters/Azure.Core.Foundations.ApiVersionParameter" + }, + { + "name": "body", + "in": "body", + "description": "The text analysis request.", + "required": true, + "schema": { + "$ref": "#/definitions/AnalyzeTextOptions" + } + } + ], + "responses": { + "200": { + "description": "The request has succeeded.", + "schema": { + "$ref": "#/definitions/AnalyzeTextResult" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" + }, + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "String error code indicating what went wrong." + } + } + } + } + } + } + }, + "definitions": { + "AddOrUpdateTextBlocklistItemsOptions": { + "type": "object", + "description": "The request to add blocklistItems to a text blocklist.", + "properties": { + "blocklistItems": { + "type": "array", + "description": "Array of blocklistItems to add.", + "items": { + "$ref": "#/definitions/TextBlocklistItem" + }, + "x-ms-identifiers": [] + } + }, + "required": [ + "blocklistItems" + ] + }, + "AddOrUpdateTextBlocklistItemsResult": { + "type": "object", + "description": "The response of adding blocklistItems to the text blocklist.", + "properties": { + "blocklistItems": { + "type": "array", + "description": "Array of blocklistItems have been added.", + "items": { + "$ref": "#/definitions/TextBlocklistItem" + }, + "x-ms-identifiers": [] + } + }, + "required": [ + "blocklistItems" + ] + }, + "AnalyzeImageOptions": { + "type": "object", + "description": "The image analysis request.", + "properties": { + "image": { + "$ref": "#/definitions/ImageData", + "description": "The image needs to be analyzed." + }, + "categories": { + "type": "array", + "description": "The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned.", + "items": { + "$ref": "#/definitions/ImageCategory" + } + }, + "outputType": { + "$ref": "#/definitions/AnalyzeImageOutputType", + "description": "This refers to the type of image analysis output. If no value is assigned, the default value will be \"FourSeverityLevels\".", + "default": "FourSeverityLevels" + } + }, + "required": [ + "image" + ] + }, + "AnalyzeImageOutputType": { + "type": "string", + "description": "The type of image analysis output.", + "enum": [ + "FourSeverityLevels" + ], + "x-ms-enum": { + "name": "AnalyzeImageOutputType", + "modelAsString": true, + "values": [ + { + "name": "FourSeverityLevels", + "value": "FourSeverityLevels", + "description": "Output severities in four levels, the value could be 0,2,4,6." + } + ] + } + }, + "AnalyzeImageResult": { + "type": "object", + "description": "The image analysis response.", + "properties": { + "categoriesAnalysis": { + "type": "array", + "description": "Analysis result for categories.", + "items": { + "$ref": "#/definitions/ImageCategoriesAnalysis" + }, + "x-ms-identifiers": [] + } + }, + "required": [ + "categoriesAnalysis" + ] + }, + "AnalyzeTextOptions": { + "type": "object", + "description": "The text analysis request.", + "properties": { + "text": { + "type": "string", + "description": "The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request.", + "maxLength": 10000 + }, + "categories": { + "type": "array", + "description": "The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned.", + "items": { + "$ref": "#/definitions/TextCategory" + } + }, + "blocklistNames": { + "type": "array", + "description": "The names of blocklists.", + "items": { + "type": "string" + } + }, + "haltOnBlocklistHit": { + "type": "boolean", + "description": "When set to true, further analyses of harmful content will not be performed in cases where blocklists are hit. When set to false, all analyses of harmful content will be performed, whether or not blocklists are hit." + }, + "outputType": { + "$ref": "#/definitions/AnalyzeTextOutputType", + "description": "This refers to the type of text analysis output. If no value is assigned, the default value will be \"FourSeverityLevels\".", + "default": "FourSeverityLevels" + } + }, + "required": [ + "text" + ] + }, + "AnalyzeTextOutputType": { + "type": "string", + "description": "The type of text analysis output.", + "enum": [ + "FourSeverityLevels", + "EightSeverityLevels" + ], + "x-ms-enum": { + "name": "AnalyzeTextOutputType", + "modelAsString": true, + "values": [ + { + "name": "FourSeverityLevels", + "value": "FourSeverityLevels", + "description": "Output severities in four levels, the value could be 0,2,4,6." + }, + { + "name": "EightSeverityLevels", + "value": "EightSeverityLevels", + "description": "Output severities in eight levels, the value could be 0,1,2,3,4,5,6,7." + } + ] + } + }, + "AnalyzeTextResult": { + "type": "object", + "description": "The text analysis response.", + "properties": { + "blocklistsMatch": { + "type": "array", + "description": "The blocklist match details.", + "items": { + "$ref": "#/definitions/TextBlocklistMatch" + }, + "x-ms-identifiers": [] + }, + "categoriesAnalysis": { + "type": "array", + "description": "Analysis result for categories.", + "items": { + "$ref": "#/definitions/TextCategoriesAnalysis" + }, + "x-ms-identifiers": [] + } + }, + "required": [ + "categoriesAnalysis" + ] + }, + "AnnotateTextBuiltinCategory": { + "type": "string", + "description": "Text analyze category.", + "enum": [ + "Hate", + "SelfHarm", + "Sexual", + "Violence" + ], + "x-ms-enum": { + "name": "AnnotateTextBuiltinCategory", + "modelAsString": true + } + }, + "AnnotateTextOptions": { + "type": "object", + "description": "Annotate text options", + "properties": { + "text": { + "type": "string", + "description": "The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request.", + "maxLength": 10000 + }, + "category": { + "$ref": "#/definitions/AnnotateTextBuiltinCategory", + "description": "The category will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned." + } + }, + "required": [ + "text" + ] + }, + "AnnotateTextResult": { + "type": "object", + "description": "The text annotation response.", + "properties": { + "label": { + "type": "integer", + "format": "int32", + "description": "The label." + }, + "reasoning": { + "type": "string", + "description": "The reasoning." + } + }, + "required": [ + "label" + ] + }, + "Azure.Core.Foundations.Error": { + "type": "object", + "description": "The error object.", + "properties": { + "code": { + "type": "string", + "description": "One of a server-defined set of error codes." + }, + "message": { + "type": "string", + "description": "A human-readable representation of the error." + }, + "target": { + "type": "string", + "description": "The target of the error." + }, + "details": { + "type": "array", + "description": "An array of details about specific errors that led to this reported error.", + "items": { + "$ref": "#/definitions/Azure.Core.Foundations.Error" + }, + "x-ms-identifiers": [] + }, + "innererror": { + "$ref": "#/definitions/Azure.Core.Foundations.InnerError", + "description": "An object containing more specific information than the current object about the error." + } + }, + "required": [ + "code", + "message" + ] + }, + "Azure.Core.Foundations.ErrorResponse": { + "type": "object", + "description": "A response containing error details.", + "properties": { + "error": { + "$ref": "#/definitions/Azure.Core.Foundations.Error", + "description": "The error object." + } + }, + "required": [ + "error" + ] + }, + "Azure.Core.Foundations.InnerError": { + "type": "object", + "description": "An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.", + "properties": { + "code": { + "type": "string", + "description": "One of a server-defined set of error codes." + }, + "innererror": { + "$ref": "#/definitions/Azure.Core.Foundations.InnerError", + "description": "Inner error." + } + } + }, + "ImageCategoriesAnalysis": { + "type": "object", + "description": "Image analysis result.", + "properties": { + "category": { + "$ref": "#/definitions/ImageCategory", + "description": "The image analysis category." + }, + "severity": { + "type": "integer", + "format": "int32", + "description": "The value increases with the severity of the input content. The value of this field is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’, and the output value can be 0, 2, 4, 6." + } + }, + "required": [ + "category" + ] + }, + "ImageCategory": { + "type": "string", + "description": "Image analyze category.", + "enum": [ + "Hate", + "SelfHarm", + "Sexual", + "Violence" + ], + "x-ms-enum": { + "name": "ImageCategory", + "modelAsString": true + } + }, + "ImageData": { + "type": "object", + "description": "The image can be either base64 encoded bytes or a blob URL. You can choose only one of these options. If both are provided, the request will be refused. The maximum image size is 2048 x 2048 pixels and should not exceed 4 MB, while the minimum image size is 50 x 50 pixels.", + "properties": { + "content": { + "type": "string", + "format": "byte", + "description": "The Base64 encoding of the image." + }, + "blobUrl": { + "type": "string", + "format": "uri", + "description": "The blob url of the image." + } + } + }, + "Label": { + "type": "object", + "description": "Label definition.", + "properties": { + "label": { + "type": "integer", + "format": "int64" + }, + "labelName": { + "type": "string" + }, + "scenarios": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "label", + "scenarios" + ] + }, + "PagedTextBlocklist": { + "type": "object", + "description": "Paged collection of TextBlocklist items", + "properties": { + "value": { + "type": "array", + "description": "The TextBlocklist items on this page", + "items": { + "$ref": "#/definitions/TextBlocklist" + }, + "x-ms-identifiers": [] + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "PagedTextBlocklistItem": { + "type": "object", + "description": "Paged collection of TextBlocklistItem items", + "properties": { + "value": { + "type": "array", + "description": "The TextBlocklistItem items on this page", + "items": { + "$ref": "#/definitions/TextBlocklistItem" + }, + "x-ms-identifiers": [] + }, + "nextLink": { + "type": "string", + "format": "uri", + "description": "The link to the next page of items" + } + }, + "required": [ + "value" + ] + }, + "PreDefinedConcept": { + "type": "object", + "description": "Pre-defined concept.", + "properties": { + "concept": { + "type": "string" + }, + "description": { + "type": "string" + } + }, + "required": [ + "concept", + "description" + ] + }, + "RemoveTextBlocklistItemsOptions": { + "type": "object", + "description": "The request to remove blocklistItems from a text blocklist.", + "properties": { + "blocklistItemIds": { + "type": "array", + "description": "Array of blocklistItemIds to remove.", + "items": { + "type": "string" + } + } + }, + "required": [ + "blocklistItemIds" + ] + }, + "TextBlocklist": { + "type": "object", + "description": "Text Blocklist.", + "properties": { + "blocklistName": { + "type": "string", + "description": "Text blocklist name.", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "description": { + "type": "string", + "description": "Text blocklist description.", + "maxLength": 1024 + } + }, + "required": [ + "blocklistName" + ] + }, + "TextBlocklistCreateOrUpdate": { + "type": "object", + "description": "Text Blocklist.", + "properties": { + "blocklistName": { + "type": "string", + "description": "Text blocklist name.", + "maxLength": 64, + "pattern": "^[0-9A-Za-z._~-]+$", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "description": { + "type": "string", + "description": "Text blocklist description.", + "maxLength": 1024 + } + } + }, + "TextBlocklistItem": { + "type": "object", + "description": "Item in a TextBlocklist.", + "properties": { + "blocklistItemId": { + "type": "string", + "description": "The service will generate a BlocklistItemId, which will be a UUID.", + "maxLength": 64, + "readOnly": true + }, + "description": { + "type": "string", + "description": "BlocklistItem description.", + "maxLength": 1024 + }, + "text": { + "type": "string", + "description": "BlocklistItem content.", + "maxLength": 128 + } + }, + "required": [ + "blocklistItemId", + "text" + ] + }, + "TextBlocklistMatch": { + "type": "object", + "description": "The result of blocklist match.", + "properties": { + "blocklistName": { + "type": "string", + "description": "The name of the matched blocklist.", + "maxLength": 64 + }, + "blocklistItemId": { + "type": "string", + "description": "The ID of the matched item.", + "maxLength": 64 + }, + "blocklistItemText": { + "type": "string", + "description": "The content of the matched item.", + "maxLength": 128 + } + }, + "required": [ + "blocklistName", + "blocklistItemId", + "blocklistItemText" + ] + }, + "TextCategoriesAnalysis": { + "type": "object", + "description": "Text analysis result.", + "properties": { + "category": { + "$ref": "#/definitions/TextCategory", + "description": "The text analysis category." + }, + "severity": { + "type": "integer", + "format": "int32", + "description": "The value increases with the severity of the input content. The value of this field is determined by the output type specified in the request. The output type could be ‘FourSeverityLevels’ or ‘EightSeverity Levels’, and the output value can be 0, 2, 4, 6 or 0, 1, 2, 3, 4, 5, 6, or 7." + } + }, + "required": [ + "category" + ] + }, + "TextCategory": { + "type": "string", + "description": "Text analyze category.", + "enum": [ + "Hate", + "SelfHarm", + "Sexual", + "Violence" + ], + "x-ms-enum": { + "name": "TextCategory", + "modelAsString": true + } + }, + "TextCustomizedCategory": { + "type": "object", + "description": "Text Customized categories.", + "properties": { + "categoryName": { + "type": "string", + "description": "Text customizedCategories name.", + "maxLength": 64, + "pattern": "^Customized_[0-9A-Za-z._~-]+$", + "x-ms-mutability": [ + "read", + "create" + ] + }, + "preDefinedConcepts": { + "type": "array", + "items": { + "$ref": "#/definitions/PreDefinedConcept" + }, + "x-ms-identifiers": [] + }, + "labels": { + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-ms-identifiers": [] + }, + "emphasis": { + "type": "array", + "items": { + "type": "string" + } + }, + "exampleBlobUrl": { + "type": "string", + "format": "uri" + } + }, + "required": [ + "categoryName", + "labels" + ] + }, + "TextCustomizedCategoryOperation": { + "type": "object", + "description": "The text annotation response.", + "properties": { + "operationId": { + "type": "integer", + "format": "int32", + "description": "The operation id." + }, + "status": { + "type": "string", + "description": "The status." + }, + "error": { + "type": "string", + "description": "The reason of failure." + } + }, + "required": [ + "operationId", + "status" + ] + }, + "Versions": { + "type": "string", + "enum": [ + "2023-10-01", + "2023-10-30-preview" + ], + "x-ms-enum": { + "name": "Versions", + "modelAsString": true, + "values": [ + { + "name": "v2023_10_01", + "value": "2023-10-01" + }, + { + "name": "v2023_10_30_Preview", + "value": "2023-10-30-preview" + } + ] + } + } + }, + "parameters": { + "Azure.Core.Foundations.ApiVersionParameter": { + "name": "api-version", + "in": "query", + "description": "The API version to use for this operation.", + "required": true, + "type": "string", + "minLength": 1, + "x-ms-parameter-location": "method", + "x-ms-client-name": "apiVersion" + }, + "Azure.Core.MaxPageSizeQueryParameter": { + "name": "maxpagesize", + "in": "query", + "description": "The maximum number of result items per page.", + "required": false, + "type": "integer", + "format": "int32", + "x-ms-parameter-location": "method" + }, + "Azure.Core.SkipQueryParameter": { + "name": "skip", + "in": "query", + "description": "The number of result items to skip.", + "required": false, + "type": "integer", + "format": "int32", + "default": 0, + "x-ms-parameter-location": "method" + }, + "Azure.Core.TopQueryParameter": { + "name": "top", + "in": "query", + "description": "The number of result items to return.", + "required": false, + "type": "integer", + "format": "int32", + "x-ms-parameter-location": "method" + } + } +} From 6722c36b7dd8d188ac63ba6fef980e40f9c615ae Mon Sep 17 00:00:00 2001 From: mengaims Date: Wed, 18 Oct 2023 17:55:48 +0800 Subject: [PATCH 2/2] Remove operations --- .../ContentSafety/models.tsp | 28 ++++++------ .../ContentSafety/routes.tsp | 10 ++--- .../2023-10-30-preview/contentsafety.json | 44 ------------------- 3 files changed, 19 insertions(+), 63 deletions(-) diff --git a/specification/cognitiveservices/ContentSafety/models.tsp b/specification/cognitiveservices/ContentSafety/models.tsp index 5e129d8991f3..10cb087c0a38 100644 --- a/specification/cognitiveservices/ContentSafety/models.tsp +++ b/specification/cognitiveservices/ContentSafety/models.tsp @@ -244,17 +244,17 @@ model TextCustomizedCategory { exampleBlobUrl?: url; } -@doc("The text annotation response.") -@added(Versions.v2023_10_30_Preview) -@resource("text/customizedCategories/operations") -model TextCustomizedCategoryOperation { - @doc("The operation id.") - @key("operationId") - operationId: int32; - - @doc("The status.") - status: string; - - @doc("The reason of failure.") - error?: string; -} +// @doc("The text annotation response.") +// @added(Versions.v2023_10_30_Preview) +// @resource("text/customizedCategories/operations") +// model TextCustomizedCategoryOperation { +// @doc("The operation id.") +// @key("operationId") +// operationId: int32; + +// @doc("The status.") +// status: string; + +// @doc("The reason of failure.") +// error?: string; +// } diff --git a/specification/cognitiveservices/ContentSafety/routes.tsp b/specification/cognitiveservices/ContentSafety/routes.tsp index ada52c1bdc79..3cbdde9513f8 100644 --- a/specification/cognitiveservices/ContentSafety/routes.tsp +++ b/specification/cognitiveservices/ContentSafety/routes.tsp @@ -114,9 +114,9 @@ interface TextCategoryCustomization { deleteTextCustomizedCategory is ResourceDelete; - @route("/text/customizedCategories/operations/{operationId}") - @get - getTextCustomizedCategoryOperation( - @path operationId: string, - ): TextCustomizedCategoryOperation; + // @route("/text/customizedCategories/operations/{operationId}") + // @get + // getTextCustomizedCategoryOperation( + // @path operationId: string, + // ): TextCustomizedCategoryOperation; } diff --git a/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json b/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json index fca2d0d2e06f..3392371a35c7 100644 --- a/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json +++ b/specification/cognitiveservices/data-plane/ContentSafety/preview/2023-10-30-preview/contentsafety.json @@ -594,27 +594,6 @@ } } }, - "/text/customizedCategories/operations/{operationId}": { - "get": { - "operationId": "TextCategoryCustomization_GetTextCustomizedCategoryOperation", - "parameters": [ - { - "name": "operationId", - "in": "path", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "The request has succeeded.", - "schema": { - "$ref": "#/definitions/TextCustomizedCategoryOperation" - } - } - } - } - }, "/text:adaptiveAnnotate": { "post": { "operationId": "PromptTextOperations_AnnotateText", @@ -1310,29 +1289,6 @@ "labels" ] }, - "TextCustomizedCategoryOperation": { - "type": "object", - "description": "The text annotation response.", - "properties": { - "operationId": { - "type": "integer", - "format": "int32", - "description": "The operation id." - }, - "status": { - "type": "string", - "description": "The status." - }, - "error": { - "type": "string", - "description": "The reason of failure." - } - }, - "required": [ - "operationId", - "status" - ] - }, "Versions": { "type": "string", "enum": [