Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -446,4 +451,149 @@ public Flux<ChatCompletions> getChatCompletionsStream(
this.serviceClient = null;
openAIServiceClient = serviceClient;
}

/**
* Returns the status of the images operation.
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@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)
* }
* }</pre>
*
* @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<Response<BinaryData>> getImageOperationStatusWithResponse(
String operationId, RequestOptions requestOptions) {
return this.serviceClient.getImageOperationStatusWithResponseAsync(operationId, requestOptions);
}

/**
* Starts the generation of a batch of images from a text caption.
*
* <p><strong>Request Body Schema</strong>
*
* <pre>{@code
* {
* prompt: String (Required)
* n: Integer (Optional)
* size: String(256x256/512x512/1024x1024) (Optional)
* user: String (Optional)
* }
* }</pre>
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@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)
* }
* }
* }
* }</pre>
*
* @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<BinaryData, BinaryData> 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<ImageOperationResponse> 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<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModelAsync(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -438,4 +443,147 @@ public IterableStream<ChatCompletions> getChatCompletionsStream(
this.serviceClient = null;
openAIServiceClient = serviceClient;
}

/**
* Returns the status of the images operation.
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@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)
* }
* }</pre>
*
* @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<BinaryData> getImageOperationStatusWithResponse(String operationId, RequestOptions requestOptions) {
return this.serviceClient.getImageOperationStatusWithResponse(operationId, requestOptions);
}

/**
* Starts the generation of a batch of images from a text caption.
*
* <p><strong>Request Body Schema</strong>
*
* <pre>{@code
* {
* prompt: String (Required)
* n: Integer (Optional)
* size: String(256x256/512x512/1024x1024) (Optional)
* user: String (Optional)
* }
* }</pre>
*
* <p><strong>Response Body Schema</strong>
*
* <pre>{@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)
* }
* }
* }
* }</pre>
*
* @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<BinaryData, BinaryData> 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<PollResult, ImageOperationStatus> beginStartGenerateImage(
ImageGenerationOptions imageGenerationOptions) {
// Generated convenience method for beginStartGenerateImageWithModel
RequestOptions requestOptions = new RequestOptions();
return serviceClient.beginStartGenerateImageWithModel(
BinaryData.fromObject(imageGenerationOptions), requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
Loading