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

[AutoPR azure-ai-contentsafety] Add private preview versions to azure-ai-content-safety feature branch #8990

Closed
wants to merge 1 commit into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Mono<Response<BinaryData>> addOrUpdateBlocklistItemsWithResponse(String n
public Mono<Response<BinaryData>> createOrUpdateTextBlocklistWithResponse(String name, BinaryData options,
RequestOptions requestOptions) {
// Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is
// 'application/merge-patch+json'
// 'application/merge-patch+json' and stream-style-serialization is not enabled
return this.serviceClient.createOrUpdateTextBlocklistWithResponseAsync(name, options, requestOptions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Response<BinaryData> addOrUpdateBlocklistItemsWithResponse(String name, B
public Response<BinaryData> createOrUpdateTextBlocklistWithResponse(String name, BinaryData options,
RequestOptions requestOptions) {
// Convenience API is not generated, as operation 'createOrUpdateTextBlocklist' is
// 'application/merge-patch+json'
// 'application/merge-patch+json' and stream-style-serialization is not enabled
return this.serviceClient.createOrUpdateTextBlocklistWithResponse(name, options, requestOptions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private HttpPipeline createHttpPipeline() {
this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient).clientOptions(localClientOptions).build();
return httpPipeline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import com.azure.ai.contentsafety.implementation.ContentSafetyClientImpl;
import com.azure.ai.contentsafety.models.AnalyzeImageOptions;
import com.azure.ai.contentsafety.models.AnalyzeImageResult;
import com.azure.ai.contentsafety.models.AnalyzeTextJailbreakOptions;
import com.azure.ai.contentsafety.models.AnalyzeTextJailbreakResult;
import com.azure.ai.contentsafety.models.AnalyzeTextOptions;
import com.azure.ai.contentsafety.models.AnalyzeTextProtectedMaterialOptions;
import com.azure.ai.contentsafety.models.AnalyzeTextProtectedMaterialResult;
import com.azure.ai.contentsafety.models.AnalyzeTextResult;
import com.azure.ai.contentsafety.models.ContentSafetyImageData;
import com.azure.core.annotation.Generated;
Expand Down Expand Up @@ -61,6 +65,12 @@ public final class ContentSafetyAsyncClient {
* ]
* haltOnBlocklistHit: Boolean (Optional)
* outputType: String(FourSeverityLevels/EightSeverityLevels) (Optional)
* incidents (Optional): {
* incidentNames (Optional): [
* String (Optional)
* ]
* haltOnIncidentHit: Boolean (Optional)
* }
* }
* }</pre>
* <p>
Expand All @@ -81,6 +91,14 @@ public final class ContentSafetyAsyncClient {
* severity: Integer (Optional)
* }
* ]
* incidentMatches (Optional): [
* (Optional){
* incidentName: String (Required)
* }
* ]
* citation (Optional): [
* String (Optional)
* ]
* }
* }</pre>
*
Expand Down Expand Up @@ -116,6 +134,12 @@ public Mono<Response<BinaryData>> analyzeTextWithResponse(BinaryData options, Re
* String(Hate/SelfHarm/Sexual/Violence) (Optional)
* ]
* outputType: String(FourSeverityLevels) (Optional)
* incidents (Optional): {
* incidentNames (Optional): [
* String (Optional)
* ]
* haltOnIncidentHit: Boolean (Optional)
* }
* }
* }</pre>
* <p>
Expand All @@ -129,6 +153,11 @@ public Mono<Response<BinaryData>> analyzeTextWithResponse(BinaryData options, Re
* severity: Integer (Optional)
* }
* ]
* incidentMatches (Optional): [
* (Optional){
* incidentName: String (Required)
* }
* ]
* }
* }</pre>
*
Expand Down Expand Up @@ -259,4 +288,129 @@ public Mono<AnalyzeImageResult> analyzeImage(BinaryData content) {
AnalyzeImageOptions options = new AnalyzeImageOptions(new ContentSafetyImageData().setContent(content));
return analyzeImage(options);
}

/**
* Analyze Text Jailbreak
*
* A synchronous API for the analysis of text jailbreak.
* <p>
* <strong>Request Body Schema</strong>
* </p>
* <pre>{@code
* {
* text: String (Required)
* }
* }</pre>
* <p>
* <strong>Response Body Schema</strong>
* </p>
* <pre>{@code
* {
* jailbreakAnalysis (Required): {
* detected: boolean (Required)
* }
* }
* }</pre>
*
* @param options The text jailbreak analysis request.
* @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 text jailbreak analysis request along with {@link Response} on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> detectTextJailbreakWithResponse(BinaryData options,
RequestOptions requestOptions) {
return this.serviceClient.detectTextJailbreakWithResponseAsync(options, requestOptions);
}

/**
* Analyze Protected Material
*
* A synchronous API for the analysis of protected material.
* <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 text protected material analysis request.
* @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 protected material analysis response 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);
}

/**
* Analyze Text Jailbreak
*
* A synchronous API for the analysis of text jailbreak.
*
* @param options The text jailbreak analysis request.
* @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 text jailbreak analysis request on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<AnalyzeTextJailbreakResult> detectTextJailbreak(AnalyzeTextJailbreakOptions options) {
// Generated convenience method for detectTextJailbreakWithResponse
RequestOptions requestOptions = new RequestOptions();
return detectTextJailbreakWithResponse(BinaryData.fromObject(options), requestOptions).flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(AnalyzeTextJailbreakResult.class));
}

/**
* Analyze Protected Material
*
* A synchronous API for the analysis of protected material.
*
* @param options The text protected material analysis request.
* @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 protected material analysis response on successful completion of {@link Mono}.
*/
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<AnalyzeTextProtectedMaterialResult>
detectTextProtectedMaterial(AnalyzeTextProtectedMaterialOptions options) {
// Generated convenience method for detectTextProtectedMaterialWithResponse
RequestOptions requestOptions = new RequestOptions();
return detectTextProtectedMaterialWithResponse(BinaryData.fromObject(options), requestOptions)
.flatMap(FluxUtil::toMono)
.map(protocolMethodData -> protocolMethodData.toObject(AnalyzeTextProtectedMaterialResult.class));
}
}
Loading