Skip to content

[AutoPR azure-ai-contentsafety] [test fork] Remove properties in model for testing purpose #13088

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

Closed
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
147 changes: 144 additions & 3 deletions sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,155 @@

## 1.1.0-beta.1 (Unreleased)

### Breaking Changes

#### `models.AnalyzeTextResult` was modified* `getCategoriesAnalysis()` was removed

#### `models.TextBlocklistMatch` was modified* `getBlocklistItemText()` was removed

#### `implementation.ContentSafetyClientImpl$ContentSafetyClientService` was modified* `analyzeText(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeImageSync(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeImage(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `analyzeTextSync(java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed

#### `implementation.BlocklistClientImpl$BlocklistClientService` was modified* `removeBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `addOrUpdateBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `addOrUpdateBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed
* `removeBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was removed

### Features Added

### Breaking Changes
* `models.DocumentInjectionAnalysisResult` was added

### Bugs Fixed
* `models.TextProtectedMaterialAnalysisResult` was added

### Other Changes
* `models.ShieldPromptResult` was added

* `models.UserPromptInjectionAnalysisResult` was added

* `models.DetectTextProtectedMaterialResult` was added

* `models.ShieldPromptOptions` was added

* `models.DetectTextProtectedMaterialOptions` was added

#### `models.AddOrUpdateTextBlocklistItemsResult` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `BlocklistAsyncClient` was modified

* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added

#### `models.AnalyzeTextResult` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.TextBlocklistMatch` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AnalyzeImageOptions` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `implementation.ContentSafetyClientImpl$ContentSafetyClientService` was modified

* `analyzeImageSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `detectTextProtectedMaterial(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeImage(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `detectTextProtectedMaterialSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeTextSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `shieldPromptSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `analyzeText(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `shieldPrompt(java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added

#### `models.TextBlocklistItem` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `setIsRegex(java.lang.Boolean)` was added
* `isRegex()` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.RemoveTextBlocklistItemsOptions` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `implementation.ContentSafetyClientImpl` was modified

* `detectTextProtectedMaterialWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added
* `shieldPromptWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added
* `detectTextProtectedMaterialWithResponseAsync(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added
* `shieldPromptWithResponseAsync(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added

#### `implementation.BlocklistClientImpl$BlocklistClientService` was modified

* `addOrUpdateBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `removeBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `removeBlocklistItemsSync(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added
* `addOrUpdateBlocklistItems(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions,com.azure.core.util.Context)` was added

#### `models.TextBlocklist` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `models.AnalyzeTextOptions` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `ContentSafetyAsyncClient` was modified

* `detectTextProtectedMaterial(models.DetectTextProtectedMaterialOptions)` was added
* `detectTextProtectedMaterialWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added
* `shieldPrompt(models.ShieldPromptOptions)` was added
* `shieldPromptWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added

#### `ContentSafetyClient` was modified

* `shieldPrompt(models.ShieldPromptOptions)` was added
* `detectTextProtectedMaterialWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added
* `detectTextProtectedMaterial(models.DetectTextProtectedMaterialOptions)` was added
* `shieldPromptWithResponse(com.azure.core.util.BinaryData,com.azure.core.http.rest.RequestOptions)` was added

#### `implementation.JsonMergePatchHelper$TextBlocklistAccessor` was modified

* `isJsonMergePatch(models.TextBlocklist)` was added

#### `models.ImageCategoriesAnalysis` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AnalyzeImageResult` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.AddOrUpdateTextBlocklistItemsOptions` was modified

* `toJson(com.azure.json.JsonWriter)` was added
* `fromJson(com.azure.json.JsonReader)` was added

#### `models.ContentSafetyImageData` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `models.TextCategoriesAnalysis` was modified

* `fromJson(com.azure.json.JsonReader)` was added
* `toJson(com.azure.json.JsonWriter)` was added

#### `BlocklistClient` was modified

* `createOrUpdateTextBlocklist(java.lang.String,models.TextBlocklist)` was added

## 1.0.7 (2024-09-27)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public final class BlocklistAsyncClient {
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* ]
* }
Expand All @@ -79,6 +80,7 @@ public final class BlocklistAsyncClient {
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* ]
* }
Expand Down Expand Up @@ -206,6 +208,7 @@ public Mono<Response<BinaryData>> getTextBlocklistWithResponse(String name, Requ
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* }
* </pre>
Expand Down Expand Up @@ -250,6 +253,7 @@ public Mono<Response<BinaryData>> getTextBlocklistItemWithResponse(String name,
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public final class BlocklistClient {
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* ]
* }
Expand All @@ -73,6 +74,7 @@ public final class BlocklistClient {
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* ]
* }
Expand Down Expand Up @@ -199,6 +201,7 @@ public Response<BinaryData> getTextBlocklistWithResponse(String name, RequestOpt
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* }
* </pre>
Expand Down Expand Up @@ -242,6 +245,7 @@ public Response<BinaryData> getTextBlocklistItemWithResponse(String name, String
* blocklistItemId: String (Required)
* description: String (Optional)
* text: String (Required)
* isRegex: Boolean (Optional)
* }
* }
* </pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import com.azure.ai.contentsafety.models.AnalyzeTextOptions;
import com.azure.ai.contentsafety.models.AnalyzeTextResult;
import com.azure.ai.contentsafety.models.ContentSafetyImageData;
import com.azure.ai.contentsafety.models.DetectTextProtectedMaterialOptions;
import com.azure.ai.contentsafety.models.DetectTextProtectedMaterialResult;
import com.azure.ai.contentsafety.models.ShieldPromptOptions;
import com.azure.ai.contentsafety.models.ShieldPromptResult;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down Expand Up @@ -74,13 +78,6 @@ public final class ContentSafetyAsyncClient {
* (Optional){
* blocklistName: String (Required)
* blocklistItemId: String (Required)
* blocklistItemText: String (Required)
* }
* ]
* categoriesAnalysis (Required): [
* (Required){
* category: String(Hate/SelfHarm/Sexual/Violence) (Required)
* severity: Integer (Optional)
* }
* ]
* }
Expand Down Expand Up @@ -265,4 +262,144 @@ public Mono<AnalyzeImageResult> analyzeImage(BinaryData content) {
AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData().setContent(content));
return analyzeImage(options);
}

/**
* Detect Protected Material for Text
*
* A synchronous API for detecting protected material in the given text.
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
* {@code
* {
* text: String (Required)
* }
* }
* </pre>
*
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* protectedMaterialAnalysis (Required): {
* detected: boolean (Required)
* }
* }
* }
* </pre>
*
* @param options The request body to be detected, which may contain protected material.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return the combined detection results of potential protected material along with {@link Response} on successful
* completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> detectTextProtectedMaterialWithResponse(BinaryData options,
RequestOptions requestOptions) {
return this.serviceClient.detectTextProtectedMaterialWithResponseAsync(options, requestOptions);
}

/**
* Shield Prompt
*
* A synchronous API for shielding prompt from direct and indirect injection attacks.
* <p><strong>Request Body Schema</strong></p>
*
* <pre>
* {@code
* {
* userPrompt: String (Optional)
* documents (Optional): [
* String (Optional)
* ]
* }
* }
* </pre>
*
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* userPromptAnalysis (Optional): {
* attackDetected: boolean (Required)
* }
* documentsAnalysis (Optional): [
* (Optional){
* attackDetected: boolean (Required)
* }
* ]
* }
* }
* </pre>
*
* @param options The request body to be detected, which may contain direct or indirect injection attacks.
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return the combined analysis results of potential direct or indirect injection attacks along with
* {@link Response} on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> shieldPromptWithResponse(BinaryData options, RequestOptions requestOptions) {
return this.serviceClient.shieldPromptWithResponseAsync(options, requestOptions);
}

/**
* Detect Protected Material for Text
*
* A synchronous API for detecting protected material in the given text.
*
* @param options The request body to be detected, which may contain protected material.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the combined detection results of potential protected material on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DetectTextProtectedMaterialResult>
detectTextProtectedMaterial(DetectTextProtectedMaterialOptions options) {
// Generated convenience method for detectTextProtectedMaterialWithResponse
RequestOptions requestOptions = new RequestOptions();
return detectTextProtectedMaterialWithResponse(BinaryData.fromObject(options), requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(DetectTextProtectedMaterialResult.class));
}

/**
* Shield Prompt
*
* A synchronous API for shielding prompt from direct and indirect injection attacks.
*
* @param options The request body to be detected, which may contain direct or indirect injection attacks.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the combined analysis results of potential direct or indirect injection attacks on successful completion
* of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<ShieldPromptResult> shieldPrompt(ShieldPromptOptions options) {
// Generated convenience method for shieldPromptWithResponse
RequestOptions requestOptions = new RequestOptions();
return shieldPromptWithResponse(BinaryData.fromObject(options), requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(ShieldPromptResult.class));
}
}
Loading