|
30 | 30 | import com.azure.core.util.IterableStream; |
31 | 31 | import com.azure.core.util.logging.ClientLogger; |
32 | 32 | import com.azure.core.util.polling.SyncPoller; |
33 | | -import java.io.IOException; |
34 | | -import java.io.UncheckedIOException; |
35 | 33 | import java.nio.ByteBuffer; |
36 | | -import reactor.core.Exceptions; |
37 | 34 | import reactor.core.publisher.Flux; |
38 | 35 |
|
39 | 36 | /** Initializes a new instance of the synchronous OpenAIClient type. */ |
@@ -505,27 +502,10 @@ public ImageResponse getImages(ImageGenerationOptions imageGenerationOptions) { |
505 | 502 | .getValue() |
506 | 503 | .toObject(ImageResponse.class); |
507 | 504 | } else { |
508 | | - // TODO: Currently, we use async client block() to avoid a unknown LRO status "notRunning" which Azure Core |
509 | | - // will |
510 | | - // fix the issue in August release and we will reuse the method |
511 | | - // "SyncPoller<BinaryData, BinaryData> beginBeginAzureBatchImageGeneration()" after. |
512 | | - try { |
513 | | - return this.serviceClient |
514 | | - .beginBeginAzureBatchImageGenerationAsync(imageGenerationOptionsBinaryData, requestOptions) |
515 | | - .last() |
516 | | - .flatMap(it -> it.getFinalResult()) |
517 | | - .map(it -> it.toObject(ImageOperationResponse.class).getResult()) |
518 | | - .block(); |
519 | | - } catch (Exception e) { |
520 | | - Throwable unwrapped = Exceptions.unwrap(e); |
521 | | - if (unwrapped instanceof RuntimeException) { |
522 | | - throw LOGGER.logExceptionAsError((RuntimeException) unwrapped); |
523 | | - } else if (unwrapped instanceof IOException) { |
524 | | - throw LOGGER.logExceptionAsError(new UncheckedIOException((IOException) unwrapped)); |
525 | | - } else { |
526 | | - throw LOGGER.logExceptionAsError(new RuntimeException(unwrapped)); |
527 | | - } |
528 | | - } |
| 505 | + return beginBeginAzureBatchImageGeneration(imageGenerationOptionsBinaryData, requestOptions) |
| 506 | + .getFinalResult() |
| 507 | + .toObject(ImageOperationResponse.class) |
| 508 | + .getResult(); |
529 | 509 | } |
530 | 510 | } |
531 | 511 |
|
|
0 commit comments