Skip to content

Commit

Permalink
[Cognitive Services - Azure AI Content Safety] - [Private Preview] - …
Browse files Browse the repository at this point in the history
…Add Image Batch Detection (#27353)

* Add private preview versions to feature branch (#43)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* Add incident response API in 2023-10-30-preview

* compiled

* Adaptive annotation service contract

* Remove operations

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* add

* add

* remove labelName

* Fix route and minor errors

* Change typo

* update

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Update incident contract

* Update contract

* Update

* scenarios to enumerations (#19)

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

* Merge 1015 (#22)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* compiled

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>

* Add list API for Annotation Service (#23)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* compiled

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

* Add list category APIs

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>

* Update contract for incident response (#24)

Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>

* scenarios to enumerations (#25)

* [Cognitive Services - Azure AI Content Safety] - 2023-11-30-preview Private Preview

* update doc

* resolve comments.

* Merge main and recompile swagger

* add explanation for 2023-11-30-preview

* format

* generate swagger

* Optimize contract (#36)

* add 12-30-preview, add explanation spec

* update

* renamed reason -> harmful chunks

* update.

* remove new version enum from GA version

* Remove examples from 1015

* restore examples

* Add examples for jailbreak and protected material

* run prettier for example

* commit add enum to stable

* Add omit-unreachable-types: true to typespec

* compile preview

* Fix readme

* renamed to citation

* UPDATE: add reasoning column and update some docs.

* update doc.

* update api version.

* Fix some typo issues. (#40)

* Update data plane.

* Remove unused versions

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>
Co-authored-by: YUTONG_ZHAI <32332316+zhaiyutong@users.noreply.github.com>
Co-authored-by: Jie Zhou <zhojie@microsoft.com>
Co-authored-by: Yuxiao Wang <yuxiaowang@microsoft.com>
Co-authored-by: Yuxiao Wang <58904990+Sayaka-4987@users.noreply.github.com>
Co-authored-by: jiezhou_microsoft <94604058+JieZhou000@users.noreply.github.com>

* Customized category / customized model related spec changes (#45)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* Add incident response API in 2023-10-30-preview

* compiled

* Adaptive annotation service contract

* Remove operations

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* add

* add

* remove labelName

* Fix route and minor errors

* Change typo

* update

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Update incident contract

* Update contract

* Update

* scenarios to enumerations (#19)

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

* Merge 1015 (#22)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* compiled

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>

* Add list API for Annotation Service (#23)

* 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

* init content safety 2023-10-15-preview

* init content safety 2023-10-15-previwe

* update

* format example

* update read me file

* update

* update

* update contract

* update

* update

* update threshold

* update new contract by add judgement kind enum

* update description

* u

* update

* updat length

* update

* update

* update description for accept severity threshodl

* update

* merge with acs-ga

* Add snippy contract

* remove 8 sev levels for image

* update contentsafety.json

* Update snippy path

* add type spec for jailbreak

* compiled

* update

* update

* refine

* update

* make 0,1,2,3,4,5,6,7 to 0, 1, 2, 3, ... and add comman in last enum value

* update path

* Update NL Snippy path

* Resolve conflict

* Update protected material API

* update project sample

* Change path name

* Update protect material contract

* update jailbreak

* Remove project related contract (#20)

* Remove project related things

* Remove accepted

* Remove examples

* Add list category APIs

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>

* Update contract for incident response (#24)

Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>

* scenarios to enumerations (#25)

* [Cognitive Services - Azure AI Content Safety] - 2023-11-30-preview Private Preview

* update doc

* resolve comments.

* Merge main and recompile swagger

* add explanation for 2023-11-30-preview

* format

* generate swagger

* Optimize contract (#36)

* add 12-30-preview, add explanation spec

* update

* renamed reason -> harmful chunks

* update.

* remove new version enum from GA version

* Remove examples from 1015

* restore examples

* Add examples for jailbreak and protected material

* run prettier for example

* commit add enum to stable

* Add omit-unreachable-types: true to typespec

* compile preview

* Fix readme

* renamed to citation

* UPDATE: add reasoning column and update some docs.

* update doc.

* update api version.

* Fix some typo issues. (#40)

* Update data plane.

* draft

* draft

* draft

* draft

* draft

* draft

* draft

* draft

* draft

* draft

* draft

* update bd draft

* update spec draft

* update spec draft

* update spec draft

---------

Co-authored-by: mengaims <mengai@microsoft.com>
Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>
Co-authored-by: mengaims <50131889+mengaims@users.noreply.github.com>
Co-authored-by: YUTONG_ZHAI <32332316+zhaiyutong@users.noreply.github.com>
Co-authored-by: Jie Zhou <zhojie@microsoft.com>
Co-authored-by: Yuxiao Wang <yuxiaowang@microsoft.com>
Co-authored-by: Yuxiao Wang <58904990+Sayaka-4987@users.noreply.github.com>
Co-authored-by: jiezhou_microsoft <94604058+JieZhou000@users.noreply.github.com>
Co-authored-by: David Liang <liangze@microsoft.com>

* Add async batch image APIs in 2024-01-30-preview (#44)

* Add async batch image APIs in 2024-01-30-preview

* Update

* Update

* Add error message in GET resonse

* Mengai/acs customization (#47)

* Change annotation API

* Add prompt generation APIs

* fix explanation version (#52)

* fix explanation version

* delete 0130 version

* Update async batch image APIs in 2023-10-30-preview (#54)

* Add async batch image APIs in 2024-01-30-preview

* Update

* Update

* Add error message in GET resonse

* Update async batch image APIs in 2023-10-30-preview

* remove customized category (#59)

* Update batch image API contract (#60)

* Mengai/0130 private fix (#61)

* remove customized category

* remove useless definition

* Mengai/0130 private fix (#62)

* remove customized category

* remove useless definition

* change progressPercentage to int32

* Resolve warnings

* Suppress spell check

* Renaming

---------

Co-authored-by: FAREAST\suxi <suxi@microsoft.com>
Co-authored-by: Lixiang Liu <lixiangliu@microsoft.com>
Co-authored-by: Lixiang Liu <liulixiang1988@gmail.com>
Co-authored-by: zhaiyutong <mo.huainian@163.com>
Co-authored-by: YUTONG_ZHAI <32332316+zhaiyutong@users.noreply.github.com>
Co-authored-by: Jie Zhou <zhojie@microsoft.com>
Co-authored-by: Yuxiao Wang <yuxiaowang@microsoft.com>
Co-authored-by: Yuxiao Wang <58904990+Sayaka-4987@users.noreply.github.com>
Co-authored-by: jiezhou_microsoft <94604058+JieZhou000@users.noreply.github.com>
Co-authored-by: David Liang <davidliangze@foxmail.com>
Co-authored-by: David Liang <liangze@microsoft.com>
Co-authored-by: MinjueWu <597922968@qq.com>
  • Loading branch information
13 people authored Feb 12, 2024
1 parent 87e46c2 commit 0a5e52c
Show file tree
Hide file tree
Showing 6 changed files with 561 additions and 3,075 deletions.
11 changes: 10 additions & 1 deletion cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,16 @@
"words": [
"throughputpool"
]
}
},
{
"filename": "**/specification/cognitiveservices/data-plane/ContentSafety/**/*.json",
"words": [
"Ungroundedness",
"ungroundedness",
"Selfharm",
"Withtext"
]
}
],
"enableFiletypes": [
"cadl"
Expand Down
3 changes: 0 additions & 3 deletions specification/cognitiveservices/ContentSafety/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,4 @@ enum Versions {

@useDependency(Azure.Core.Versions.v1_0_Preview_2)
v2023_10_30_Preview: "2023-10-30-preview",

@useDependency(Azure.Core.Versions.v1_0_Preview_2)
v2024_01_30_Preview: "2024-01-30-preview",
}
132 changes: 129 additions & 3 deletions specification/cognitiveservices/ContentSafety/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ enum AnalyzeImageOutputType {
FourSeverityLevels,
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("The type of batch results storage mode.")
enum BatchResultsStorageMode {
@doc("Merge each result into one file.")
CollectiveResultFile,

@doc("Store each result in a single file.")
IndividualResultFiles,
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("The type of batch analysis task status.")
enum BatchTaskStatus {
@doc("The task has not started yet.")
NotStarted,

@doc("The task is in progress.")
Running,

@doc("The task has failed.")
Failed,

@doc("The task has been succeeded.")
Succeeded,
}

@doc("The text analysis request.")
model AnalyzeTextOptions {
@doc("The text needs to be analyzed. We support a maximum of 10k Unicode characters (Unicode code points) in the text of one request.")
Expand Down Expand Up @@ -85,7 +111,7 @@ model AnalyzeTextResult {
@doc("The incident match details.")
incidentMatches?: IncidentMatch[];

@added(ContentSafety.Versions.v2024_01_30_Preview)
@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("Chunks in the original text detected as harmful content. Analysis result and scores are caused by these.")
citation?: string[];
}
Expand Down Expand Up @@ -169,6 +195,90 @@ model ImageCategoriesAnalysis {
severity?: int32;
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("The image batch analysis request.")
model BatchAnalyzeImagesOptions {
@doc("The blob parameters of images to be analyzed.")
images: BatchAnalyzeImages;

@doc("The blob parameters of result files.")
resultsBlob: BatchAnalyzeImagesResultsBlob;

@doc("The storage mode for the batch task results, either 'CollectiveResultFile' or 'IndividualResultFiles'.")
resultsStorageMode?: BatchResultsStorageMode = BatchResultsStorageMode.CollectiveResultFile;

@doc("The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories will be returned.")
categories?: ImageCategory[];

@doc("This refers to the type of image analysis output. If no value is assigned, the default value will be 'FourSeverityLevels'.")
outputType?: AnalyzeImageOutputType = AnalyzeImageOutputType.FourSeverityLevels;

@doc("The incidents to detect.")
incidents?: IncidentOptions;
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("The image batch analysis input.")
model BatchAnalyzeImages {
@doc("The URL to a blob prefix which represents a directory containing all the images to be analyzed in this batch task.")
blobPrefixLocation: url;

@doc("The delimiter character you desire to use in the location URL, typically '/'.")
delimiter: string;

@doc("An array of strings indicating file extensions of desired images within the logical folder.")
extensions: string[];

@doc("The last modified time (in RFC1123 format) of blobs. Only images that were modified before this time will be analyzed.")
lastModified?: utcDateTime;
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("The image batch analysis output.")
model BatchAnalyzeImagesResultsBlob {
@doc("The URL to a blob prefix which represents a directory. The analysis result file(s) will be written to this directory.")
blobPrefixLocation: url;

@doc("The delimiter character you desire to use in the location URL, typically '/'.")
delimiter: string;
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("Image batch analyze task.")
@resource("image/batchAnalyses")
model ImageBatchTaskDetail {
@doc("The id of image batch analysis task.")
@key("operationId")
@visibility("read", "create", "query")
@maxLength(64)
id: string;

@doc("The kind of operation.")
kind: string;

@doc("The status of the batch image analysis task.")
status: BatchTaskStatus;

@doc("Batch task result.")
result: ImageBatchTaskResult;

@doc("Return error detail when the task failed.")
error?: Azure.Core.Foundations.Error;
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
@doc("Image batch task result.")
model ImageBatchTaskResult {
@doc("The timestamp of when batch image analysis task was created.")
createdTime: utcDateTime;

@doc("The progress of the batch image analysis task, represented as a percentage (0-100).")
progressPercentage: int32;

@doc("The blob parameters of result files.")
resultsBlob: BatchAnalyzeImagesResultsBlob;
}

@doc("Text Blocklist.")
@resource("text/blocklists")
model TextBlocklist {
Expand Down Expand Up @@ -450,15 +560,23 @@ model AnnotateTextResult {
@added(Versions.v2023_10_30_Preview)
@doc("Pre-defined concept.")
model PreDefinedConcept {
@doc("The concept name.")
concept: string;

@doc("The concept description.")
description: string;
}

@added(Versions.v2023_10_30_Preview)
@doc("Label definition.")
model SubCategory {
model Subcategory {
@doc("The id of subcategory.")
id: int32;

@doc("The name of subcategory.")
name: string;

@doc("The description of subcategory.")
statements: string[];
}

Expand All @@ -473,9 +591,16 @@ model TextCustomizedCategory {
@maxLength(64)
categoryName: string;

@doc("Some pre defined concepts used in definition.")
preDefinedConcepts?: PreDefinedConcept[];
subCategories: SubCategory[];

@doc("Subcategories in the customized category.")
subcategories: Subcategory[];

@doc("Text customizedCategories emphases.")
emphases?: string[];

@doc("Text url of example jsonl blob.")
exampleBlobUrl?: url;
}

Expand Down Expand Up @@ -539,6 +664,7 @@ enum Task {
QnA,
}

#suppress "@azure-tools/typespec-azure-core/casing-style" "MUST fix in next update"
@added(Versions.v2023_10_30_Preview)
@doc("Connection details for the GPT resource.")
model GptResource {
Expand Down
34 changes: 34 additions & 0 deletions specification/cognitiveservices/ContentSafety/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,40 @@ interface ImageOperations {
>;
}

interface ImageBatchOperations {
#suppress "@azure-tools/typespec-azure-core/no-rpc-path-params" "MUST fix in next update"
@added(ContentSafety.Versions.v2023_10_30_Preview)
@summary("Start Batch Analyze Images")
@doc("An asynchronous API for the batch analysis of potentially harmful image content. Currently, it supports four categories: Hate, SelfHarm, Sexual, and Violence.")
@route("/image/batchAnalyses")
@put
batchAnalyzeImage is Azure.Core.RpcOperation<
{
@path
@doc("The unique operation id.")
operationId: string;

@body
@doc("The image batch analysis request.")
body: BatchAnalyzeImagesOptions;
},
ImageBatchTaskDetail
>;

@added(ContentSafety.Versions.v2023_10_30_Preview)
@summary("Get Image Batch Analysis task Status")
@doc("Check the status of a batch image analysis task.")
getBatchTaskStatus is Azure.Core.ResourceRead<ImageBatchTaskDetail>;

@added(ContentSafety.Versions.v2023_10_30_Preview)
@summary("List All Image Batch Analysis Tasks")
@doc("List all batch image analysis tasks.")
listBatchTasks is Azure.Core.ResourceList<
ImageBatchTaskDetail,
ListQueryParametersTrait<StandardListQueryParameters>
>;
}

interface BlockOps
extends Azure.Core.ResourceOperations<NoRepeatableRequests &
NoConditionalRequests &
Expand Down
Loading

0 comments on commit 0a5e52c

Please sign in to comment.