Class AsyncExecutor<R extends bg.codexio.ai.openai.api.payload.images.request.ImageRequest>

java.lang.Object
bg.codexio.ai.openai.api.sdk.images.ImageConfigurationStage<R>
bg.codexio.ai.openai.api.sdk.images.AsyncExecutor<R>
All Implemented Interfaces:
RuntimeExecutor

public class AsyncExecutor<R extends bg.codexio.ai.openai.api.payload.images.request.ImageRequest> extends ImageConfigurationStage<R> implements RuntimeExecutor
Promise abstraction. Accepts callbacks which will be called when response is received.
  • Method Details

    • onResponse

      public void onResponse(Consumer<bg.codexio.ai.openai.api.payload.images.response.ImageDataResponse> callback)
      Subscribe to the result of the HTTP request
      Parameters:
      callback - a consumer function that receives ImageDataResponse as a parameter
    • whenDownloaded

      public void whenDownloaded(File targetFolder, Consumer<File[]> callback)
      Subscribe to the completion of the download of the image in the response.
      Parameters:
      targetFolder - the desired location for downloading the file from the response
      callback - a consumer function to be executed on successful download that receives ImageDataResponse as a parameter In this case we have a default error handler that simply logs the error data
    • whenDownloaded

      public void whenDownloaded(File targetFolder, Consumer<File[]> callback, Consumer<Throwable> errorHandler)
      Subscribe to the completion of the download of the image in the response.
      Parameters:
      targetFolder - the desired location for downloading the file from the response
      callback - a consumer function to be executed on successful download that receives ImageDataResponse as a parameter
      errorHandler - a consumer function that to be executed on unsuccessful download that receives Throwable as a parameter