-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Cognitive Services - Azure AI Content Safety] - [Private Preview] - Add Image Batch Detection #27353
[Cognitive Services - Azure AI Content Safety] - [Private Preview] - Add Image Batch Detection #27353
Changes from 8 commits
8775b51
f76e444
cd1c274
f6d9bb4
429adca
f2dc0f5
4681f0b
10b3271
5766d32
9a375d4
5757924
12d34b1
967700a
835312a
e54dd6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,7 +40,7 @@ enum AnalyzeImageOutputType { | |||||
FourSeverityLevels, | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("The type of batch results storage mode.") | ||||||
enum BatchResultsStorageMode { | ||||||
@doc("Merge each result into one file.") | ||||||
|
@@ -50,7 +50,7 @@ enum BatchResultsStorageMode { | |||||
IndividualResultFiles, | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("The type of batch analysis task status.") | ||||||
enum BatchTaskStatus { | ||||||
@doc("The task has not started yet.") | ||||||
|
@@ -66,21 +66,6 @@ enum BatchTaskStatus { | |||||
Succeeded, | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
enum ModelStatus { | ||||||
Created, | ||||||
Training, | ||||||
Ready, | ||||||
Failed, | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
enum GeneratePromptStatus { | ||||||
Running, | ||||||
Ready, | ||||||
Failed, | ||||||
} | ||||||
|
||||||
@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.") | ||||||
|
@@ -102,20 +87,6 @@ model AnalyzeTextOptions { | |||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("The incidents to detect.") | ||||||
incidents?: IncidentOptions; | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("The customized categories will be analyzed. If they are not assigned, the analysis results for all available customized categories will be returned.") | ||||||
customizedCategories?: CustomizedCategory[]; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("Customized category for inference.") | ||||||
model CustomizedCategory { | ||||||
@doc("Category name") | ||||||
categoryName: string; | ||||||
|
||||||
@doc("Model ID for the category. If not provided, the latest available model will be used.") | ||||||
modelId: string; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
|
@@ -140,32 +111,9 @@ 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[]; | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("Analysis result for customized categories.") | ||||||
customizedCategoriesAnalysis: TextCustomizedCategoryAnalysis[]; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("Text customized category analysis result.") | ||||||
model TextCustomizedCategoryAnalysis { | ||||||
@doc("Customized category name") | ||||||
categoryName: string; | ||||||
|
||||||
@doc("customized category analysis") | ||||||
customizedCategoriesAnalysis: TextCustomizedCategoryClassResult[]; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("customized category analysis result") | ||||||
model TextCustomizedCategoryClassResult { | ||||||
id: int32; | ||||||
|
||||||
@renamedFrom(Versions.v2024_01_30_Preview, "name") | ||||||
className: string; | ||||||
} | ||||||
|
||||||
@doc("The result of blocklist match.") | ||||||
|
@@ -247,51 +195,90 @@ model ImageCategoriesAnalysis { | |||||
severity?: int32; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("The image batch analysis request.") | ||||||
model BatchAnalyzeImagesOptions { | ||||||
@doc("The URL of the Azure Storage Blob containing all the images to be analyzed in the batch task.") | ||||||
imagesBlobFolderUrl: url; | ||||||
@doc("The blob parameters of images to be analyzed.") | ||||||
images: BatchAnalyzeImages; | ||||||
|
||||||
@doc("The URL of the Azure Storage Blob where the batch task results will be written.") | ||||||
analysisResultsBlobFolderUrl: url; | ||||||
@doc("The blob parameters of result files.") | ||||||
analysisResults: BatchAnalyzeImagesResults; | ||||||
|
||||||
@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\".") | ||||||
@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.v2024_01_30_Preview) | ||||||
@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 BatchAnalyzeImagesResults { | ||||||
@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/batchAnalyzeTasks") | ||||||
@resource("image/batchAnalyses") | ||||||
model ImageBatchTaskDetail { | ||||||
@doc("The id of image batch analysis task.") | ||||||
@key("taskId") | ||||||
@visibility("read") | ||||||
@key("operationId") | ||||||
@visibility("read", "create", "query") | ||||||
@maxLength(64) | ||||||
taskId: string; | ||||||
id: string; | ||||||
|
||||||
@doc("The kind of operation.") | ||||||
kind: string; | ||||||
|
||||||
@doc("The status of the batch image analysis task.") | ||||||
status: BatchTaskStatus; | ||||||
|
||||||
@doc("The progress of the batch image analysis task, represented as a percentage (0-100).") | ||||||
progressPercentage: float64; | ||||||
|
||||||
@doc("The timestamp of when batch image analysis task was created.") | ||||||
taskCreatedTime: utcDateTime; | ||||||
@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.") | ||||||
analysisResults: BatchAnalyzeImagesResults; | ||||||
} | ||||||
|
||||||
@doc("Text Blocklist.") | ||||||
@resource("text/blocklists") | ||||||
model TextBlocklist { | ||||||
|
@@ -573,19 +560,20 @@ 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.") | ||||||
@renamedFrom(Versions.v2024_01_30_Preview, "SubCategory") | ||||||
model Class { | ||||||
model SubCategory { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Subcategory is a single word. This is not going to look good in a public-facing API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You even use it as such below in docs. Be consistent. Use single word casing everywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing out! Changed it to Subcategory |
||||||
@doc("The id of subcategory.") | ||||||
id: int32; | ||||||
|
||||||
@renamedFrom(Versions.v2024_01_30_Preview, "name") | ||||||
className: string; | ||||||
|
||||||
@doc("The name of subcategory.") | ||||||
name: string; | ||||||
@doc("The description of subcategory.") | ||||||
statements: string[]; | ||||||
} | ||||||
|
||||||
|
@@ -600,55 +588,19 @@ model TextCustomizedCategory { | |||||
@maxLength(64) | ||||||
categoryName: string; | ||||||
|
||||||
@doc("A predefined concept with its definition can be used directly in the subcategories.") | ||||||
@added(Versions.v2023_10_30_Preview) | ||||||
@removed(Versions.v2024_01_30_Preview) | ||||||
@doc("Some pre defined concepts used in definition.") | ||||||
preDefinedConcepts?: PreDefinedConcept[]; | ||||||
|
||||||
@doc("Subcategories are detailed classes of the category. It is required there is a class 'safe' with id=0.") | ||||||
@renamedFrom(Versions.v2024_01_30_Preview, "subCategories") | ||||||
classes: Class[]; | ||||||
@doc("Subcategories in the customized category.") | ||||||
subCategories: SubCategory[]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's a single word. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||
|
||||||
@added(Versions.v2023_10_30_Preview) | ||||||
@removed(Versions.v2024_01_30_Preview) | ||||||
@doc("Text customizedCategories emphases.") | ||||||
emphases?: string[]; | ||||||
|
||||||
@doc("Blob that stores the examples.") | ||||||
@doc("Text url of example jsonl blob.") | ||||||
exampleBlobUrl?: url; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@doc("The response for async training triggering.") | ||||||
model SubmitModelTrainingResponse { | ||||||
...AcceptedResponse; | ||||||
|
||||||
@header("operation-location") | ||||||
@doc("The location of the status API for monitoring the triggered model.") | ||||||
modelUrl: string; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
model AsyncJobWarning { | ||||||
code: string; | ||||||
messgae: string; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@resource("text/generatePromptTasks") | ||||||
model GeneratePromptTaskDetail { | ||||||
@doc("The id of image batch analysis task.") | ||||||
@key("taskId") | ||||||
@visibility("read") | ||||||
@maxLength(64) | ||||||
taskId: string; | ||||||
|
||||||
@doc("The status of the batch image analysis task.") | ||||||
status: GeneratePromptStatus; | ||||||
|
||||||
@doc("Return error detail when the task failed.") | ||||||
error?: Azure.Core.Foundations.Error; | ||||||
} | ||||||
|
||||||
#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update" | ||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("ImageWithText analyze category.") | ||||||
|
@@ -659,20 +611,6 @@ enum ImageWithTextCategory { | |||||
Violence, | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2024_01_30_Preview) | ||||||
@parentResource(TextCustomizedCategory) | ||||||
@resource("models") | ||||||
model TextTrainedModel { | ||||||
@key | ||||||
modelId: string; | ||||||
|
||||||
status: ModelStatus; | ||||||
createdTime: utcDateTime; | ||||||
lastUpdateTime: utcDateTime; | ||||||
warnings?: AsyncJobWarning[]; | ||||||
errors?: string[]; | ||||||
} | ||||||
|
||||||
@added(ContentSafety.Versions.v2023_10_30_Preview) | ||||||
@doc("The analysis request of the image with text.") | ||||||
model AnalyzeImageWithTextOptions { | ||||||
|
@@ -723,6 +661,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 { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very confusing name. Even I had to review this several times over again. You might consider not putting anything called "results" in a request model, or at least something like
saveResultsLocation
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the name to "resultsBlob" as ChatGPT suggested. I did not use the word "location" because there is one "blobPrefixLocation" under this concept.