Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
}
120 changes: 119 additions & 1 deletion specification/cognitiveservices/ContentSafety/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,47 @@ 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,
}

@added(ContentSafety.Versions.v2023_10_30_Preview)
enum ModelStatus {
Created,
Training,
mengaims marked this conversation as resolved.
Show resolved Hide resolved
Ready,
Failed,
}

@added(ContentSafety.Versions.v2023_10_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.")
Expand Down Expand Up @@ -85,7 +126,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 +210,83 @@ 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.")
analysisResults: BatchAnalyzeImagesResults;
Copy link
Member

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.

Copy link
Contributor Author

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.


@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 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/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("The timestamp of when batch image analysis task was created.")
createdTime: utcDateTime;

@doc("The blob parameters of result files.")
analysisResults: BatchAnalyzeImagesResults;
lemonicetea marked this conversation as resolved.
Show resolved Hide resolved

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

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

@doc("Text Blocklist.")
@resource("text/blocklists")
model TextBlocklist {
Expand Down
48 changes: 48 additions & 0 deletions specification/cognitiveservices/ContentSafety/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,54 @@ interface ImageOperations {
>;
}

interface ImageBatchOperations {
@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 ContentSafetyLongRunningRpcOperation<
{
@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>
>;
}

@doc("Long running RPC operation template")
op ContentSafetyLongRunningRpcOperation<
TParams extends TypeSpec.Reflection.Model,
TResponse extends TypeSpec.Reflection.Model
> is Azure.Core.Foundations.Operation<
TParams,
Azure.Core.Foundations.AcceptedResponse & TResponse,
mengaims marked this conversation as resolved.
Show resolved Hide resolved
Azure.Core.Foundations.ErrorResponse
>;

interface BatchOps
extends Azure.Core.ResourceOperations<NoRepeatableRequests &
NoConditionalRequests &
NoClientRequestId> {}

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