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

Adaptive annotation service contract #3

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 77 additions & 0 deletions specification/cognitiveservices/ContentSafety/models.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,80 @@ model AddImageIncidentSamplesResult {
incidentSamples: ListImageIncidentSampleResult[];
}

#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;
// }
32 changes: 29 additions & 3 deletions specification/cognitiveservices/ContentSafety/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ interface TextBlocklists {
>;
}


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


@added(ContentSafety.Versions.v2023_10_30_Preview)
interface TextIncidents {
@summary("Get Text Incident By incidentName")
Expand Down Expand Up @@ -149,7 +147,6 @@ interface ImageIncidentOps
NoConditionalRequests &
NoClientRequestId> {}


@added(ContentSafety.Versions.v2023_10_30_Preview)
interface ImageIncidents {
@summary("Get Image Incident By incidentName")
Expand Down Expand Up @@ -196,3 +193,32 @@ interface ImageIncidents {
>;
}

@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<TextCustomizedCategory>;

getTextCustomizedCategory is ResourceRead<TextCustomizedCategory>;

deleteTextCustomizedCategory is ResourceDelete<TextCustomizedCategory>;

// @route("/text/customizedCategories/operations/{operationId}")
// @get
// getTextCustomizedCategoryOperation(
// @path operationId: string,
// ): TextCustomizedCategoryOperation;
}
Loading