diff --git a/sdk/openai/azure-ai-openai/assets.json b/sdk/openai/azure-ai-openai/assets.json index 48bec78b13ca..e89c070ac0bc 100644 --- a/sdk/openai/azure-ai-openai/assets.json +++ b/sdk/openai/azure-ai-openai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/openai/azure-ai-openai", - "Tag": "java/openai/azure-ai-openai_6a5c74f82e" + "Tag": "java/openai/azure-ai-openai_ab2dde7d23" } diff --git a/sdk/openai/azure-ai-openai/pom.xml b/sdk/openai/azure-ai-openai/pom.xml index c6abf9a3ca53..3eb8a888f6fb 100644 --- a/sdk/openai/azure-ai-openai/pom.xml +++ b/sdk/openai/azure-ai-openai/pom.xml @@ -67,6 +67,11 @@ azure-core-http-netty 1.13.4 + + com.azure + azure-core-experimental + 1.0.0-beta.40 + 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 ab5ffb779cdf..5e19032203e1 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,6 +13,9 @@ 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; @@ -21,10 +24,12 @@ 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; import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; import java.nio.ByteBuffer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -446,4 +451,149 @@ public Flux getChatCompletionsStream( this.serviceClient = null; openAIServiceClient = serviceClient; } + + /** + * Returns the status of the images operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     created: long (Required)
+     *     expires: Long (Optional)
+     *     result (Optional): {
+     *         created: long (Required)
+     *         data (Required): [
+     *              (Required){
+     *                 url: String (Optional)
+     *                 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)
+     *                     }
+     *                 }
+     *             }
+     *         ]
+     *     }
+     *     status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
+     *     error (Optional): (recursive schema, see error above)
+     * }
+     * }
+ * + * @param operationId . + * @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 result of the operation if the operation succeeded along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getImageOperationStatusWithResponse( + String operationId, RequestOptions requestOptions) { + return this.serviceClient.getImageOperationStatusWithResponseAsync(operationId, requestOptions); + } + + /** + * 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginStartGenerateImage( + BinaryData imageGenerationOptions, RequestOptions requestOptions) { + return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions); + } + + /** + * Returns the status of the images operation. + * + * @param operationId . + * @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 result of the operation if the operation succeeded on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getImageOperationStatus(String operationId) { + // Generated convenience method for getImageOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getImageOperationStatusWithResponse(operationId, requestOptions) + .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 6b28bd4142e1..257f0022261f 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,6 +13,9 @@ 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; @@ -21,10 +24,12 @@ 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; import com.azure.core.util.IterableStream; +import com.azure.core.util.polling.SyncPoller; import java.nio.ByteBuffer; import reactor.core.publisher.Flux; @@ -438,4 +443,147 @@ public IterableStream getChatCompletionsStream( this.serviceClient = null; openAIServiceClient = serviceClient; } + + /** + * Returns the status of the images operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     created: long (Required)
+     *     expires: Long (Optional)
+     *     result (Optional): {
+     *         created: long (Required)
+     *         data (Required): [
+     *              (Required){
+     *                 url: String (Optional)
+     *                 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)
+     *                     }
+     *                 }
+     *             }
+     *         ]
+     *     }
+     *     status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
+     *     error (Optional): (recursive schema, see error above)
+     * }
+     * }
+ * + * @param operationId . + * @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 result of the operation if the operation succeeded along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getImageOperationStatusWithResponse(String operationId, RequestOptions requestOptions) { + return this.serviceClient.getImageOperationStatusWithResponse(operationId, requestOptions); + } + + /** + * 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. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginStartGenerateImage( + BinaryData imageGenerationOptions, RequestOptions requestOptions) { + return this.serviceClient.beginStartGenerateImage(imageGenerationOptions, requestOptions); + } + + /** + * Returns the status of the images operation. + * + * @param operationId . + * @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 result of the operation if the operation succeeded. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ImageOperationResponse getImageOperationStatus(String operationId) { + // Generated convenience method for getImageOperationStatusWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getImageOperationStatusWithResponse(operationId, requestOptions) + .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/OpenAIServiceVersion.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java index ba7e3fac2e85..8d15584caf4d 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java @@ -11,8 +11,11 @@ public enum OpenAIServiceVersion implements ServiceVersion { /** Enum value 2022-12-01. */ V2022_12_01("2022-12-01"), - /** Enum value 2023-03-15-preview. */ - V2023_03_15_PREVIEW("2023-03-15-preview"); + /** Enum value 2023-05-15. */ + V2023_05_15("2023-05-15"), + + /** Enum value 2023-06-01-preview. */ + V2023_06_01_PREVIEW("2023-06-01-preview"); private final String version; @@ -32,6 +35,6 @@ public String getVersion() { * @return The latest {@link OpenAIServiceVersion}. */ public static OpenAIServiceVersion getLatest() { - return V2023_03_15_PREVIEW; + return V2023_06_01_PREVIEW; } } 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 abbbfa2c134a..4f2ee8fe0b2a 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,8 +5,10 @@ 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; import com.azure.core.annotation.HeaderParam; import com.azure.core.annotation.Host; import com.azure.core.annotation.HostParam; @@ -21,6 +23,7 @@ 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; @@ -32,8 +35,15 @@ import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.DefaultPollingStrategy; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncDefaultPollingStrategy; +import com.azure.core.util.polling.SyncPoller; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; import reactor.core.publisher.Mono; /** Initializes a new instance of the OpenAIClient type. */ @@ -274,6 +284,86 @@ Response getChatCompletionsSync( @BodyParam("application/json") BinaryData chatCompletionsOptions, RequestOptions requestOptions, Context context); + + @Get("/operations/images/{operationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getImageOperationStatus( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("operationId") String operationId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/operations/images/{operationId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getImageOperationStatusSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("operationId") String operationId, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Post("/images/generations:submit") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> startGenerateImage( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData imageGenerationOptions, + RequestOptions requestOptions, + Context context); + + @Post("/images/generations:submit") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response startGenerateImageSync( + @HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData imageGenerationOptions, + RequestOptions requestOptions, + Context context); } /** @@ -757,4 +847,473 @@ public Response getChatCompletionsWithResponse( requestOptions, Context.NONE); } + + /** + * Returns the status of the images operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     created: long (Required)
+     *     expires: Long (Optional)
+     *     result (Optional): {
+     *         created: long (Required)
+     *         data (Required): [
+     *              (Required){
+     *                 url: String (Optional)
+     *                 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)
+     *                     }
+     *                 }
+     *             }
+     *         ]
+     *     }
+     *     status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
+     *     error (Optional): (recursive schema, see error above)
+     * }
+     * }
+ * + * @param operationId . + * @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 result of the operation if the operation succeeded along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getImageOperationStatusWithResponseAsync( + String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.getImageOperationStatus( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + operationId, + accept, + requestOptions, + context)); + } + + /** + * Returns the status of the images operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     created: long (Required)
+     *     expires: Long (Optional)
+     *     result (Optional): {
+     *         created: long (Required)
+     *         data (Required): [
+     *              (Required){
+     *                 url: String (Optional)
+     *                 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)
+     *                     }
+     *                 }
+     *             }
+     *         ]
+     *     }
+     *     status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
+     *     error (Optional): (recursive schema, see error above)
+     * }
+     * }
+ * + * @param operationId . + * @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 result of the operation if the operation succeeded along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getImageOperationStatusWithResponse(String operationId, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getImageOperationStatusSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + operationId, + accept, + requestOptions, + Context.NONE); + } + + /** + * 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 status details for long running operations along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> startGenerateImageWithResponseAsync( + BinaryData imageGenerationOptions, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.startGenerateImage( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + imageGenerationOptions, + requestOptions, + context)); + } + + /** + * 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 status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response startGenerateImageWithResponse( + BinaryData imageGenerationOptions, RequestOptions requestOptions) { + final String accept = "application/json"; + return service.startGenerateImageSync( + this.getEndpoint(), + this.getServiceVersion().getVersion(), + accept, + imageGenerationOptions, + requestOptions, + Context.NONE); + } + + /** + * 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 beginStartGenerateImageAsync( + 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(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 SyncPoller} for polling of status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginStartGenerateImage( + 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(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/ImageGenerationOptions.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationOptions.java new file mode 100644 index 000000000000..6dd82f096730 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageGenerationOptions.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Represents the request data used to generate images. */ +@Fluent +public final class ImageGenerationOptions { + + /* + * A description of the desired images. + */ + @Generated + @JsonProperty(value = "prompt") + private String prompt; + + /* + * The number of images to generate (defaults to 1). + */ + @Generated + @JsonProperty(value = "n") + private Integer n; + + /* + * The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 (defaults to 1024x1024). + */ + @Generated + @JsonProperty(value = "size") + private ImageSize size; + + /* + * A unique identifier representing your end-user, which can help to monitor and detect abuse. + */ + @Generated + @JsonProperty(value = "user") + private String user; + + /** + * Creates an instance of ImageGenerationOptions class. + * + * @param prompt the prompt value to set. + */ + @Generated + @JsonCreator + public ImageGenerationOptions(@JsonProperty(value = "prompt") String prompt) { + this.prompt = prompt; + } + + /** + * Get the prompt property: A description of the desired images. + * + * @return the prompt value. + */ + @Generated + public String getPrompt() { + return this.prompt; + } + + /** + * Get the n property: The number of images to generate (defaults to 1). + * + * @return the n value. + */ + @Generated + public Integer getN() { + return this.n; + } + + /** + * Set the n property: The number of images to generate (defaults to 1). + * + * @param n the n value to set. + * @return the ImageGenerationOptions object itself. + */ + @Generated + public ImageGenerationOptions setN(Integer n) { + this.n = n; + return this; + } + + /** + * Get the size property: The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 + * (defaults to 1024x1024). + * + * @return the size value. + */ + @Generated + public ImageSize getSize() { + return this.size; + } + + /** + * Set the size property: The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 + * (defaults to 1024x1024). + * + * @param size the size value to set. + * @return the ImageGenerationOptions object itself. + */ + @Generated + public ImageGenerationOptions setSize(ImageSize size) { + this.size = size; + return this; + } + + /** + * Get the user property: A unique identifier representing your end-user, which can help to monitor and detect + * abuse. + * + * @return the user value. + */ + @Generated + public String getUser() { + return this.user; + } + + /** + * Set the user property: A unique identifier representing your end-user, which can help to monitor and detect + * abuse. + * + * @param user the user value to set. + * @return the ImageGenerationOptions object itself. + */ + @Generated + public ImageGenerationOptions setUser(String user) { + this.user = user; + return this; + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageLocation.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageLocation.java new file mode 100644 index 000000000000..967a0021b0b8 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageLocation.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The image url if successful, and an error otherwise. */ +@Immutable +public final class ImageLocation { + + /* + * The URL that provides temporary access to download the generated image. + */ + @Generated + @JsonProperty(value = "url") + private String url; + + /* + * The error if the operation failed. + */ + @Generated + @JsonProperty(value = "error") + private ResponseError error; + + /** Creates an instance of ImageLocation class. */ + @Generated + private ImageLocation() {} + + /** + * Get the url property: The URL that provides temporary access to download the generated image. + * + * @return the url value. + */ + @Generated + public String getUrl() { + return this.url; + } + + /** + * Get the error property: The error if the operation failed. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationResponse.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationResponse.java new file mode 100644 index 000000000000..e00c9555085b --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationResponse.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.models.ResponseError; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The result of the operation if the operation succeeded. */ +@Immutable +public final class ImageOperationResponse { + + /* + * The ID of the operation. + */ + @Generated + @JsonProperty(value = "id") + private String id; + + /* + * A timestamp when this job or item was created (in unix epochs). + */ + @Generated + @JsonProperty(value = "created") + private long created; + + /* + * A timestamp when this operation and its associated images expire and will be deleted (in unix epochs). + */ + @Generated + @JsonProperty(value = "expires") + private Long expires; + + /* + * The result of the operation if the operation succeeded. + */ + @Generated + @JsonProperty(value = "result") + private ImageResponse result; + + /* + * The status of the operation + */ + @Generated + @JsonProperty(value = "status") + private State status; + + /* + * The error if the operation failed. + */ + @Generated + @JsonProperty(value = "error") + private ResponseError error; + + /** + * Creates an instance of ImageOperationResponse class. + * + * @param id the id value to set. + * @param created the created value to set. + * @param status the status value to set. + */ + @Generated + @JsonCreator + private ImageOperationResponse( + @JsonProperty(value = "id") String id, + @JsonProperty(value = "created") long created, + @JsonProperty(value = "status") State status) { + this.id = id; + this.created = created; + this.status = status; + } + + /** + * Get the id property: The ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the created property: A timestamp when this job or item was created (in unix epochs). + * + * @return the created value. + */ + @Generated + public long getCreated() { + return this.created; + } + + /** + * Get the expires property: A timestamp when this operation and its associated images expire and will be deleted + * (in unix epochs). + * + * @return the expires value. + */ + @Generated + public Long getExpires() { + return this.expires; + } + + /** + * Get the result property: The result of the operation if the operation succeeded. + * + * @return the result value. + */ + @Generated + public ImageResponse getResult() { + return this.result; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public State getStatus() { + return this.status; + } + + /** + * Get the error property: The error if the operation failed. + * + * @return the error value. + */ + @Generated + public ResponseError getError() { + return this.error; + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationStatus.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationStatus.java new file mode 100644 index 000000000000..ca3f50c065ee --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageOperationStatus.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Provides status details for long running operations. */ +@Immutable +public final class ImageOperationStatus { + + /* + * The unique ID of the operation. + */ + @Generated + @JsonProperty(value = "id") + private String id; + + /* + * The status of the operation + */ + @Generated + @JsonProperty(value = "status") + private State status; + + /** + * Creates an instance of ImageOperationStatus class. + * + * @param id the id value to set. + * @param status the status value to set. + */ + @Generated + @JsonCreator + private ImageOperationStatus(@JsonProperty(value = "id") String id, @JsonProperty(value = "status") State status) { + this.id = id; + this.status = status; + } + + /** + * Get the id property: The unique ID of the operation. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the status property: The status of the operation. + * + * @return the status value. + */ + @Generated + public State getStatus() { + return this.status; + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageResponse.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageResponse.java new file mode 100644 index 000000000000..dd9eee65e2b1 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageResponse.java @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The result of the operation if the operation succeeded. */ +@Immutable +public final class ImageResponse { + + /* + * A timestamp when this job or item was created (in unix epochs). + */ + @Generated + @JsonProperty(value = "created") + private long created; + + /* + * The images generated by the operator. + */ + @Generated + @JsonProperty(value = "data") + private List data; + + /** + * Creates an instance of ImageResponse class. + * + * @param created the created value to set. + * @param data the data value to set. + */ + @Generated + @JsonCreator + private ImageResponse( + @JsonProperty(value = "created") long created, @JsonProperty(value = "data") List data) { + this.created = created; + this.data = data; + } + + /** + * Get the created property: A timestamp when this job or item was created (in unix epochs). + * + * @return the created value. + */ + @Generated + public long getCreated() { + return this.created; + } + + /** + * Get the data property: The images generated by the operator. + * + * @return the data value. + */ + @Generated + public List getData() { + return this.data; + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageSize.java b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageSize.java new file mode 100644 index 000000000000..ff84856a6347 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/ImageSize.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024. */ +public final class ImageSize extends ExpandableStringEnum { + + /** Image size of 256x256. */ + @Generated public static final ImageSize SIZE256X256 = fromString("256x256"); + + /** Image size of 512x512. */ + @Generated public static final ImageSize SIZE512X512 = fromString("512x512"); + + /** Image size of 1024x1024. */ + @Generated public static final ImageSize SIZE1024X1024 = fromString("1024x1024"); + + /** + * Creates a new instance of ImageSize value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public ImageSize() {} + + /** + * Creates or finds a ImageSize from its string representation. + * + * @param name a name to look for. + * @return the corresponding ImageSize. + */ + @Generated + @JsonCreator + public static ImageSize fromString(String name) { + return fromString(name, ImageSize.class); + } + + /** + * Gets known ImageSize values. + * + * @return known ImageSize values. + */ + @Generated + public static Collection values() { + return values(ImageSize.class); + } +} 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 new file mode 100644 index 000000000000..7662a08ca9a6 --- /dev/null +++ b/sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/models/State.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.ai.openai.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** The state of a job or item. */ +public final class State extends ExpandableStringEnum { + + /** The operation was created and is queued to be processed in the future. */ + @Generated public static final State NOT_RUNNING = fromString("notRunning"); + + /** The operation has started to be processed. */ + @Generated public static final State RUNNING = fromString("running"); + + /** The operation has successfully be processed and is ready for consumption. */ + @Generated public static final State SUCCEEDED = fromString("succeeded"); + + /** The operation has been canceled and is incomplete. */ + @Generated public static final State CANCELED = fromString("canceled"); + + /** 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. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public State() {} + + /** + * Creates or finds a State from its string representation. + * + * @param name a name to look for. + * @return the corresponding State. + */ + @Generated + @JsonCreator + public static State fromString(String name) { + return fromString(name, State.class); + } + + /** + * Gets known State values. + * + * @return known State values. + */ + @Generated + public static Collection values() { + return values(State.class); + } +} diff --git a/sdk/openai/azure-ai-openai/src/main/java/module-info.java b/sdk/openai/azure-ai-openai/src/main/java/module-info.java index 0a087eb7a709..590e8b4f6dfd 100644 --- a/sdk/openai/azure-ai-openai/src/main/java/module-info.java +++ b/sdk/openai/azure-ai-openai/src/main/java/module-info.java @@ -4,6 +4,7 @@ module com.azure.ai.openai { requires transitive com.azure.core; + requires transitive com.azure.core.experimental; exports com.azure.ai.openai; exports com.azure.ai.openai.models; diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java index 487e8f2ca697..4c96f53e2b92 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIAsyncClientTest.java @@ -51,7 +51,8 @@ public void testGetCompletions(HttpClient httpClient, OpenAIServiceVersion servi @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") public void testGetCompletionsStream(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { - client = getOpenAIAsyncClient(httpClient, serviceVersion); + // TODO: use the parameterized serviceVersion once we have a service release that responds with valid data + client = getOpenAIAsyncClient(httpClient, OpenAIServiceVersion.V2023_05_15); getCompletionsRunner((deploymentId, prompt) -> { StepVerifier.create(client.getCompletionsStream(deploymentId, new CompletionsOptions(prompt))) .recordWith(ArrayList::new) @@ -160,7 +161,8 @@ public void testGetChatCompletions(HttpClient httpClient, OpenAIServiceVersion s @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.ai.openai.TestUtils#getTestParameters") public void testGetChatCompletionsStream(HttpClient httpClient, OpenAIServiceVersion serviceVersion) { - client = getOpenAIAsyncClient(httpClient, serviceVersion); + // TODO: use the parameterized serviceVersion once we have a service release that responds with valid data + client = getOpenAIAsyncClient(httpClient, OpenAIServiceVersion.V2023_05_15); getChatCompletionsRunner((deploymentId, chatMessages) -> { StepVerifier.create(client.getChatCompletionsStream(deploymentId, new ChatCompletionsOptions(chatMessages))) .recordWith(ArrayList::new) diff --git a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java index 543121496f69..c9601aac002c 100644 --- a/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java +++ b/sdk/openai/azure-ai-openai/src/test/java/com/azure/ai/openai/OpenAIClientTestBase.java @@ -73,10 +73,10 @@ OpenAIClientBuilder getNonAzureOpenAIClientBuilder(HttpClient httpClient) { } else if (getTestMode() == TestMode.RECORD) { builder .addPolicy(interceptorManager.getRecordPolicy()) - .credential(new NonAzureOpenAIKeyCredential(Configuration.getGlobalConfiguration().get("NON_AZURE_OPEN_AI_KEY"))); + .credential(new NonAzureOpenAIKeyCredential(Configuration.getGlobalConfiguration().get("NON_AZURE_OPENAI_KEY"))); } else { builder - .credential(new NonAzureOpenAIKeyCredential(Configuration.getGlobalConfiguration().get("NON_AZURE_OPEN_AI_KEY"))); + .credential(new NonAzureOpenAIKeyCredential(Configuration.getGlobalConfiguration().get("NON_AZURE_OPENAI_KEY"))); } return builder; } @@ -122,7 +122,7 @@ void getChatCompletionsForNonAzureRunner(BiConsumer> t } void getEmbeddingRunner(BiConsumer testRunner) { - testRunner.accept("embedding", new EmbeddingsOptions(Arrays.asList("Your text string goes here"))); + testRunner.accept("text-embedding-ada-002", new EmbeddingsOptions(Arrays.asList("Your text string goes here"))); } void getEmbeddingNonAzureRunner(BiConsumer testRunner) { diff --git a/sdk/openai/azure-ai-openai/tsp-location.yaml b/sdk/openai/azure-ai-openai/tsp-location.yaml index 2c0698ce5560..a8e2785e61e8 100644 --- a/sdk/openai/azure-ai-openai/tsp-location.yaml +++ b/sdk/openai/azure-ai-openai/tsp-location.yaml @@ -1,5 +1,5 @@ directory: specification/cognitiveservices/OpenAI.Inference additionalDirectories: - specification/cognitiveservices/OpenAI.Authoring -commit: 741fb79ae6786f0e8da78b61acd6c57fd0420325 +commit: fe056966cf070be84e92dd2dc1b566bae35002cf repo: Azure/azure-rest-api-specs