Skip to content

Commit d4558e3

Browse files
authored
Dall-E models code generation (Azure#35549)
1 parent ffd34bb commit d4558e3

17 files changed

+1438
-10
lines changed

sdk/openai/azure-ai-openai/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/openai/azure-ai-openai",
5-
"Tag": "java/openai/azure-ai-openai_6a5c74f82e"
5+
"Tag": "java/openai/azure-ai-openai_ab2dde7d23"
66
}

sdk/openai/azure-ai-openai/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
<artifactId>azure-core-http-netty</artifactId>
6868
<version>1.13.4</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
6969
</dependency>
70+
<dependency>
71+
<groupId>com.azure</groupId>
72+
<artifactId>azure-core-experimental</artifactId>
73+
<version>1.0.0-beta.40</version> <!-- {x-version-update;com.azure:azure-core-experimental;dependency} -->
74+
</dependency>
7075

7176
<!-- provided scope -->
7277
<dependency>

sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIAsyncClient.java

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import com.azure.ai.openai.models.CompletionsOptions;
1414
import com.azure.ai.openai.models.Embeddings;
1515
import com.azure.ai.openai.models.EmbeddingsOptions;
16+
import com.azure.ai.openai.models.ImageGenerationOptions;
17+
import com.azure.ai.openai.models.ImageOperationResponse;
18+
import com.azure.ai.openai.models.ImageOperationStatus;
1619
import com.azure.core.annotation.Generated;
1720
import com.azure.core.annotation.ReturnType;
1821
import com.azure.core.annotation.ServiceClient;
@@ -21,10 +24,12 @@
2124
import com.azure.core.exception.HttpResponseException;
2225
import com.azure.core.exception.ResourceModifiedException;
2326
import com.azure.core.exception.ResourceNotFoundException;
27+
import com.azure.core.experimental.models.PollResult;
2428
import com.azure.core.http.rest.RequestOptions;
2529
import com.azure.core.http.rest.Response;
2630
import com.azure.core.util.BinaryData;
2731
import com.azure.core.util.FluxUtil;
32+
import com.azure.core.util.polling.PollerFlux;
2833
import java.nio.ByteBuffer;
2934
import reactor.core.publisher.Flux;
3035
import reactor.core.publisher.Mono;
@@ -446,4 +451,149 @@ public Flux<ChatCompletions> getChatCompletionsStream(
446451
this.serviceClient = null;
447452
openAIServiceClient = serviceClient;
448453
}
454+
455+
/**
456+
* Returns the status of the images operation.
457+
*
458+
* <p><strong>Response Body Schema</strong>
459+
*
460+
* <pre>{@code
461+
* {
462+
* id: String (Required)
463+
* created: long (Required)
464+
* expires: Long (Optional)
465+
* result (Optional): {
466+
* created: long (Required)
467+
* data (Required): [
468+
* (Required){
469+
* url: String (Optional)
470+
* error (Optional): {
471+
* code: String (Required)
472+
* message: String (Required)
473+
* target: String (Optional)
474+
* details (Optional): [
475+
* (recursive schema, see above)
476+
* ]
477+
* innererror (Optional): {
478+
* code: String (Optional)
479+
* innererror (Optional): (recursive schema, see innererror above)
480+
* }
481+
* }
482+
* }
483+
* ]
484+
* }
485+
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
486+
* error (Optional): (recursive schema, see error above)
487+
* }
488+
* }</pre>
489+
*
490+
* @param operationId .
491+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
492+
* @throws HttpResponseException thrown if the request is rejected by server.
493+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
494+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
495+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
496+
* @return the result of the operation if the operation succeeded along with {@link Response} on successful
497+
* completion of {@link Mono}.
498+
*/
499+
@Generated
500+
@ServiceMethod(returns = ReturnType.SINGLE)
501+
public Mono<Response<BinaryData>> getImageOperationStatusWithResponse(
502+
String operationId, RequestOptions requestOptions) {
503+
return this.serviceClient.getImageOperationStatusWithResponseAsync(operationId, requestOptions);
504+
}
505+
506+
/**
507+
* Starts the generation of a batch of images from a text caption.
508+
*
509+
* <p><strong>Request Body Schema</strong>
510+
*
511+
* <pre>{@code
512+
* {
513+
* prompt: String (Required)
514+
* n: Integer (Optional)
515+
* size: String(256x256/512x512/1024x1024) (Optional)
516+
* user: String (Optional)
517+
* }
518+
* }</pre>
519+
*
520+
* <p><strong>Response Body Schema</strong>
521+
*
522+
* <pre>{@code
523+
* {
524+
* id: String (Required)
525+
* status: String (Required)
526+
* error (Optional): {
527+
* code: String (Required)
528+
* message: String (Required)
529+
* target: String (Optional)
530+
* details (Optional): [
531+
* (recursive schema, see above)
532+
* ]
533+
* innererror (Optional): {
534+
* code: String (Optional)
535+
* innererror (Optional): (recursive schema, see innererror above)
536+
* }
537+
* }
538+
* }
539+
* }</pre>
540+
*
541+
* @param imageGenerationOptions Represents the request data used to generate images.
542+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
543+
* @throws HttpResponseException thrown if the request is rejected by server.
544+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
545+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
546+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
547+
* @return the {@link PollerFlux} for polling of status details for long running operations.
548+
*/
549+
@Generated
550+
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
551+
public PollerFlux<BinaryData, BinaryData> beginStartGenerateImage(
552+
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
553+
return this.serviceClient.beginStartGenerateImageAsync(imageGenerationOptions, requestOptions);
554+
}
555+
556+
/**
557+
* Returns the status of the images operation.
558+
*
559+
* @param operationId .
560+
* @throws IllegalArgumentException thrown if parameters fail the validation.
561+
* @throws HttpResponseException thrown if the request is rejected by server.
562+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
563+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
564+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
565+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
566+
* @return the result of the operation if the operation succeeded on successful completion of {@link Mono}.
567+
*/
568+
@Generated
569+
@ServiceMethod(returns = ReturnType.SINGLE)
570+
public Mono<ImageOperationResponse> getImageOperationStatus(String operationId) {
571+
// Generated convenience method for getImageOperationStatusWithResponse
572+
RequestOptions requestOptions = new RequestOptions();
573+
return getImageOperationStatusWithResponse(operationId, requestOptions)
574+
.flatMap(FluxUtil::toMono)
575+
.map(protocolMethodData -> protocolMethodData.toObject(ImageOperationResponse.class));
576+
}
577+
578+
/**
579+
* Starts the generation of a batch of images from a text caption.
580+
*
581+
* @param imageGenerationOptions Represents the request data used to generate images.
582+
* @throws IllegalArgumentException thrown if parameters fail the validation.
583+
* @throws HttpResponseException thrown if the request is rejected by server.
584+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
585+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
586+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
587+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
588+
* @return the {@link PollerFlux} for polling of status details for long running operations.
589+
*/
590+
@Generated
591+
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
592+
public PollerFlux<PollResult, ImageOperationStatus> beginStartGenerateImage(
593+
ImageGenerationOptions imageGenerationOptions) {
594+
// Generated convenience method for beginStartGenerateImageWithModel
595+
RequestOptions requestOptions = new RequestOptions();
596+
return serviceClient.beginStartGenerateImageWithModelAsync(
597+
BinaryData.fromObject(imageGenerationOptions), requestOptions);
598+
}
449599
}

sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIClient.java

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import com.azure.ai.openai.models.CompletionsOptions;
1414
import com.azure.ai.openai.models.Embeddings;
1515
import com.azure.ai.openai.models.EmbeddingsOptions;
16+
import com.azure.ai.openai.models.ImageGenerationOptions;
17+
import com.azure.ai.openai.models.ImageOperationResponse;
18+
import com.azure.ai.openai.models.ImageOperationStatus;
1619
import com.azure.core.annotation.Generated;
1720
import com.azure.core.annotation.ReturnType;
1821
import com.azure.core.annotation.ServiceClient;
@@ -21,10 +24,12 @@
2124
import com.azure.core.exception.HttpResponseException;
2225
import com.azure.core.exception.ResourceModifiedException;
2326
import com.azure.core.exception.ResourceNotFoundException;
27+
import com.azure.core.experimental.models.PollResult;
2428
import com.azure.core.http.rest.RequestOptions;
2529
import com.azure.core.http.rest.Response;
2630
import com.azure.core.util.BinaryData;
2731
import com.azure.core.util.IterableStream;
32+
import com.azure.core.util.polling.SyncPoller;
2833
import java.nio.ByteBuffer;
2934
import reactor.core.publisher.Flux;
3035

@@ -438,4 +443,147 @@ public IterableStream<ChatCompletions> getChatCompletionsStream(
438443
this.serviceClient = null;
439444
openAIServiceClient = serviceClient;
440445
}
446+
447+
/**
448+
* Returns the status of the images operation.
449+
*
450+
* <p><strong>Response Body Schema</strong>
451+
*
452+
* <pre>{@code
453+
* {
454+
* id: String (Required)
455+
* created: long (Required)
456+
* expires: Long (Optional)
457+
* result (Optional): {
458+
* created: long (Required)
459+
* data (Required): [
460+
* (Required){
461+
* url: String (Optional)
462+
* error (Optional): {
463+
* code: String (Required)
464+
* message: String (Required)
465+
* target: String (Optional)
466+
* details (Optional): [
467+
* (recursive schema, see above)
468+
* ]
469+
* innererror (Optional): {
470+
* code: String (Optional)
471+
* innererror (Optional): (recursive schema, see innererror above)
472+
* }
473+
* }
474+
* }
475+
* ]
476+
* }
477+
* status: String(notRunning/running/succeeded/canceled/failed/deleted) (Required)
478+
* error (Optional): (recursive schema, see error above)
479+
* }
480+
* }</pre>
481+
*
482+
* @param operationId .
483+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
484+
* @throws HttpResponseException thrown if the request is rejected by server.
485+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
486+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
487+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
488+
* @return the result of the operation if the operation succeeded along with {@link Response}.
489+
*/
490+
@Generated
491+
@ServiceMethod(returns = ReturnType.SINGLE)
492+
public Response<BinaryData> getImageOperationStatusWithResponse(String operationId, RequestOptions requestOptions) {
493+
return this.serviceClient.getImageOperationStatusWithResponse(operationId, requestOptions);
494+
}
495+
496+
/**
497+
* Starts the generation of a batch of images from a text caption.
498+
*
499+
* <p><strong>Request Body Schema</strong>
500+
*
501+
* <pre>{@code
502+
* {
503+
* prompt: String (Required)
504+
* n: Integer (Optional)
505+
* size: String(256x256/512x512/1024x1024) (Optional)
506+
* user: String (Optional)
507+
* }
508+
* }</pre>
509+
*
510+
* <p><strong>Response Body Schema</strong>
511+
*
512+
* <pre>{@code
513+
* {
514+
* id: String (Required)
515+
* status: String (Required)
516+
* error (Optional): {
517+
* code: String (Required)
518+
* message: String (Required)
519+
* target: String (Optional)
520+
* details (Optional): [
521+
* (recursive schema, see above)
522+
* ]
523+
* innererror (Optional): {
524+
* code: String (Optional)
525+
* innererror (Optional): (recursive schema, see innererror above)
526+
* }
527+
* }
528+
* }
529+
* }</pre>
530+
*
531+
* @param imageGenerationOptions Represents the request data used to generate images.
532+
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
533+
* @throws HttpResponseException thrown if the request is rejected by server.
534+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
535+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
536+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
537+
* @return the {@link SyncPoller} for polling of status details for long running operations.
538+
*/
539+
@Generated
540+
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
541+
public SyncPoller<BinaryData, BinaryData> beginStartGenerateImage(
542+
BinaryData imageGenerationOptions, RequestOptions requestOptions) {
543+
return this.serviceClient.beginStartGenerateImage(imageGenerationOptions, requestOptions);
544+
}
545+
546+
/**
547+
* Returns the status of the images operation.
548+
*
549+
* @param operationId .
550+
* @throws IllegalArgumentException thrown if parameters fail the validation.
551+
* @throws HttpResponseException thrown if the request is rejected by server.
552+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
553+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
554+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
555+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
556+
* @return the result of the operation if the operation succeeded.
557+
*/
558+
@Generated
559+
@ServiceMethod(returns = ReturnType.SINGLE)
560+
public ImageOperationResponse getImageOperationStatus(String operationId) {
561+
// Generated convenience method for getImageOperationStatusWithResponse
562+
RequestOptions requestOptions = new RequestOptions();
563+
return getImageOperationStatusWithResponse(operationId, requestOptions)
564+
.getValue()
565+
.toObject(ImageOperationResponse.class);
566+
}
567+
568+
/**
569+
* Starts the generation of a batch of images from a text caption.
570+
*
571+
* @param imageGenerationOptions Represents the request data used to generate images.
572+
* @throws IllegalArgumentException thrown if parameters fail the validation.
573+
* @throws HttpResponseException thrown if the request is rejected by server.
574+
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
575+
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
576+
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
577+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
578+
* @return the {@link SyncPoller} for polling of status details for long running operations.
579+
*/
580+
@Generated
581+
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
582+
public SyncPoller<PollResult, ImageOperationStatus> beginStartGenerateImage(
583+
ImageGenerationOptions imageGenerationOptions) {
584+
// Generated convenience method for beginStartGenerateImageWithModel
585+
RequestOptions requestOptions = new RequestOptions();
586+
return serviceClient.beginStartGenerateImageWithModel(
587+
BinaryData.fromObject(imageGenerationOptions), requestOptions);
588+
}
441589
}

sdk/openai/azure-ai-openai/src/main/java/com/azure/ai/openai/OpenAIServiceVersion.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ public enum OpenAIServiceVersion implements ServiceVersion {
1111
/** Enum value 2022-12-01. */
1212
V2022_12_01("2022-12-01"),
1313

14-
/** Enum value 2023-03-15-preview. */
15-
V2023_03_15_PREVIEW("2023-03-15-preview");
14+
/** Enum value 2023-05-15. */
15+
V2023_05_15("2023-05-15"),
16+
17+
/** Enum value 2023-06-01-preview. */
18+
V2023_06_01_PREVIEW("2023-06-01-preview");
1619

1720
private final String version;
1821

@@ -32,6 +35,6 @@ public String getVersion() {
3235
* @return The latest {@link OpenAIServiceVersion}.
3336
*/
3437
public static OpenAIServiceVersion getLatest() {
35-
return V2023_03_15_PREVIEW;
38+
return V2023_06_01_PREVIEW;
3639
}
3740
}

0 commit comments

Comments
 (0)