From ab6f3bef3e3c010b81d34edad2f0e68e022bea67 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 26 Jun 2023 23:15:49 +0000 Subject: [PATCH] CodeGen from PR 24541 in Azure/azure-rest-api-specs Re-enabling Java checks for Azure OpenAI (#24541) * Renabled java checks * Empty commit to re-trigger CI --- .../azure/ai/openai/OpenAIAsyncClient.java | 29 +--- .../com/azure/ai/openai/OpenAIClient.java | 29 +--- .../implementation/OpenAIClientImpl.java | 134 +----------------- .../models/CompletionsFinishReason.java | 6 +- .../com/azure/ai/openai/models/State.java | 3 - sdk/openai/azure-ai-openai/tsp-location.yaml | 6 +- 6 files changed, 16 insertions(+), 191 deletions(-) diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java index 5e19032203e1..bf87cb5f7bcc 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java @@ -13,9 +13,7 @@ import com.azure.ai.openai.models.CompletionsOptions; import com.azure.ai.openai.models.Embeddings; import com.azure.ai.openai.models.EmbeddingsOptions; -import com.azure.ai.openai.models.ImageGenerationOptions; import com.azure.ai.openai.models.ImageOperationResponse; -import com.azure.ai.openai.models.ImageOperationStatus; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -24,7 +22,6 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.experimental.models.PollResult; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; @@ -482,7 +479,7 @@ public Flux getChatCompletionsStream( * } * ] * } - * status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required) + * status: String(notRunning/running/succeeded/canceled/failed) (Required) * error (Optional): (recursive schema, see error above) * } * } @@ -548,7 +545,7 @@ public Mono> getImageOperationStatusWithResponse( */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginStartGenerateImage( + PollerFlux beginStartGenerateImage( BinaryData imageGenerationOptions, RequestOptions requestOptions) { return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions); } @@ -574,26 +571,4 @@ public Mono getImageOperationStatus(String operationId) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ImageOperationResponse.class)); } - - /** - * Starts the generation of a batch of images from a text caption. - * - * @param imageGenerationOptions Represents the request data used to generate images. - * @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 {@link PollerFlux} for polling of status details for long running operations. - */ - @Generated - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginStartGenerateImage( - ImageGenerationOptions imageGenerationOptions) { - // Generated convenience method for beginStartGenerateImageWithModel - RequestOptions requestOptions = new RequestOptions(); - return serviceClient.beginStartGenerateImageWithModelAsync( - BinaryData.fromObject(imageGenerationOptions), requestOptions); - } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java index 257f0022261f..49be4d675e87 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java @@ -13,9 +13,7 @@ import com.azure.ai.openai.models.CompletionsOptions; import com.azure.ai.openai.models.Embeddings; import com.azure.ai.openai.models.EmbeddingsOptions; -import com.azure.ai.openai.models.ImageGenerationOptions; import com.azure.ai.openai.models.ImageOperationResponse; -import com.azure.ai.openai.models.ImageOperationStatus; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceClient; @@ -24,7 +22,6 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.experimental.models.PollResult; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; @@ -474,7 +471,7 @@ public IterableStream getChatCompletionsStream( * } * ] * } - * status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required) + * status: String(notRunning/running/succeeded/canceled/failed) (Required) * error (Optional): (recursive schema, see error above) * } * } @@ -538,7 +535,7 @@ public Response getImageOperationStatusWithResponse(String operation */ @Generated @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginStartGenerateImage( + SyncPoller beginStartGenerateImage( BinaryData imageGenerationOptions, RequestOptions requestOptions) { return this.serviceClient.beginStartGenerateImage(imageGenerationOptions, requestOptions); } @@ -564,26 +561,4 @@ public ImageOperationResponse getImageOperationStatus(String operationId) { .getValue() .toObject(ImageOperationResponse.class); } - - /** - * Starts the generation of a batch of images from a text caption. - * - * @param imageGenerationOptions Represents the request data used to generate images. - * @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 {@link SyncPoller} for polling of status details for long running operations. - */ - @Generated - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginStartGenerateImage( - ImageGenerationOptions imageGenerationOptions) { - // Generated convenience method for beginStartGenerateImageWithModel - RequestOptions requestOptions = new RequestOptions(); - return serviceClient.beginStartGenerateImageWithModel( - BinaryData.fromObject(imageGenerationOptions), requestOptions); - } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java index 4f2ee8fe0b2a..1035b16362ee 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/implementation/OpenAIClientImpl.java @@ -5,7 +5,6 @@ package com.azure.ai.openai.implementation; import com.azure.ai.openai.OpenAIServiceVersion; -import com.azure.ai.openai.models.ImageOperationStatus; import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; import com.azure.core.annotation.Get; @@ -23,7 +22,6 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.experimental.models.PollResult; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.policy.CookiePolicy; @@ -548,7 +546,7 @@ public Response getEmbeddingsWithResponse( * int (Required) * ] * } - * finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) + * finish_reason: String(stop/length/content_filter) (Required) * } * ] * usage (Required): { @@ -645,7 +643,7 @@ public Mono> getCompletionsWithResponseAsync( * int (Required) * ] * } - * finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) + * finish_reason: String(stop/length/content_filter) (Required) * } * ] * usage (Required): { @@ -726,7 +724,7 @@ public Response getCompletionsWithResponse( * content: String (Optional) * } * index: int (Required) - * finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) + * finish_reason: String(stop/length/content_filter) (Required) * delta (Optional): (recursive schema, see delta above) * } * ] @@ -811,7 +809,7 @@ public Mono> getChatCompletionsWithResponseAsync( * content: String (Optional) * } * index: int (Required) - * finish_reason: String(stopped/tokenLimitReached/contentFiltered) (Required) + * finish_reason: String(stop/length/content_filter) (Required) * delta (Optional): (recursive schema, see delta above) * } * ] @@ -878,7 +876,7 @@ public Response getChatCompletionsWithResponse( * } * ] * } - * status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required) + * status: String(notRunning/running/succeeded/canceled/failed) (Required) * error (Optional): (recursive schema, see error above) * } * } @@ -937,7 +935,7 @@ public Mono> getImageOperationStatusWithResponseAsync( * } * ] * } - * status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required) + * status: String(notRunning/running/succeeded/canceled/failed) (Required) * error (Optional): (recursive schema, see error above) * } * } @@ -1196,124 +1194,4 @@ public SyncPoller beginStartGenerateImage( TypeReference.createInstance(BinaryData.class), TypeReference.createInstance(BinaryData.class)); } - - /** - * Starts the generation of a batch of images from a text caption. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     prompt: String (Required)
-     *     n: Integer (Optional)
-     *     size: String(256x256/512x512/1024x1024) (Optional)
-     *     user: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     id: String (Required)
-     *     status: String (Required)
-     *     error (Optional): {
-     *         code: String (Required)
-     *         message: String (Required)
-     *         target: String (Optional)
-     *         details (Optional): [
-     *             (recursive schema, see above)
-     *         ]
-     *         innererror (Optional): {
-     *             code: String (Optional)
-     *             innererror (Optional): (recursive schema, see innererror above)
-     *         }
-     *     }
-     * }
-     * }
- * - * @param imageGenerationOptions Represents the request data used to generate images. - * @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 {@link PollerFlux} for polling of status details for long running operations. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginStartGenerateImageWithModelAsync( - BinaryData imageGenerationOptions, RequestOptions requestOptions) { - return PollerFlux.create( - Duration.ofSeconds(1), - () -> this.startGenerateImageWithResponseAsync(imageGenerationOptions, requestOptions), - new DefaultPollingStrategy<>( - new PollingStrategyOptions(this.getHttpPipeline()) - .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.getEndpoint())) - .setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE)), - TypeReference.createInstance(PollResult.class), - TypeReference.createInstance(ImageOperationStatus.class)); - } - - /** - * Starts the generation of a batch of images from a text caption. - * - *

Request Body Schema - * - *

{@code
-     * {
-     *     prompt: String (Required)
-     *     n: Integer (Optional)
-     *     size: String(256x256/512x512/1024x1024) (Optional)
-     *     user: String (Optional)
-     * }
-     * }
- * - *

Response Body Schema - * - *

{@code
-     * {
-     *     id: String (Required)
-     *     status: String (Required)
-     *     error (Optional): {
-     *         code: String (Required)
-     *         message: String (Required)
-     *         target: String (Optional)
-     *         details (Optional): [
-     *             (recursive schema, see above)
-     *         ]
-     *         innererror (Optional): {
-     *             code: String (Optional)
-     *             innererror (Optional): (recursive schema, see innererror above)
-     *         }
-     *     }
-     * }
-     * }
- * - * @param imageGenerationOptions Represents the request data used to generate images. - * @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 {@link SyncPoller} for polling of status details for long running operations. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginStartGenerateImageWithModel( - BinaryData imageGenerationOptions, RequestOptions requestOptions) { - return SyncPoller.createPoller( - Duration.ofSeconds(1), - () -> this.startGenerateImageWithResponse(imageGenerationOptions, requestOptions), - new SyncDefaultPollingStrategy<>( - new PollingStrategyOptions(this.getHttpPipeline()) - .setEndpoint("{endpoint}/openai".replace("{endpoint}", this.getEndpoint())) - .setContext( - requestOptions != null && requestOptions.getContext() != null - ? requestOptions.getContext() - : Context.NONE)), - TypeReference.createInstance(PollResult.class), - TypeReference.createInstance(ImageOperationStatus.class)); - } } diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/CompletionsFinishReason.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/CompletionsFinishReason.java index f82f7226e851..c267098eca5b 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/CompletionsFinishReason.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/CompletionsFinishReason.java @@ -12,15 +12,15 @@ public final class CompletionsFinishReason extends ExpandableStringEnum { /** Completions ended normally and reached its end of token generation. */ - @Generated public static final CompletionsFinishReason STOPPED = fromString("stopped"); + @Generated public static final CompletionsFinishReason STOPPED = fromString("stop"); /** Completions exhausted available token limits before generation could complete. */ - @Generated public static final CompletionsFinishReason TOKEN_LIMIT_REACHED = fromString("tokenLimitReached"); + @Generated public static final CompletionsFinishReason TOKEN_LIMIT_REACHED = fromString("length"); /** * Completions generated a response that was identified as potentially sensitive per content moderation policies. */ - @Generated public static final CompletionsFinishReason CONTENT_FILTERED = fromString("contentFiltered"); + @Generated public static final CompletionsFinishReason CONTENT_FILTERED = fromString("content_filter"); /** * Creates a new instance of CompletionsFinishReason value. diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/State.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/State.java index 7662a08ca9a6..94ef70482c83 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/State.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/State.java @@ -26,9 +26,6 @@ public final class State extends ExpandableStringEnum { /** The operation has completed processing with a failure and cannot be further consumed. */ @Generated public static final State FAILED = fromString("failed"); - /** The entity has been deleted but may still be referenced by other entities predating the deletion. */ - @Generated public static final State DELETED = fromString("deleted"); - /** * Creates a new instance of State value. * diff --git a/sdk/openai/azure-ai-openai/tsp-location.yaml b/sdk/openai/azure-ai-openai/tsp-location.yaml index a8e2785e61e8..5c36be9eea1f 100644 --- a/sdk/openai/azure-ai-openai/tsp-location.yaml +++ b/sdk/openai/azure-ai-openai/tsp-location.yaml @@ -1,5 +1,5 @@ +commit: baab681702af69fd815cd7dc9310ed1438bd0ef7 directory: specification/cognitiveservices/OpenAI.Inference -additionalDirectories: - - specification/cognitiveservices/OpenAI.Authoring -commit: fe056966cf070be84e92dd2dc1b566bae35002cf repo: Azure/azure-rest-api-specs +additionalDirectories: [] +