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.
-
Field Summary
Fields inherited from class bg.codexio.ai.openai.api.sdk.images.ImageConfigurationStage
builder, executor -
Method Summary
Modifier and TypeMethodDescriptionvoidonResponse(Consumer<bg.codexio.ai.openai.api.payload.images.response.ImageDataResponse> callback) Subscribe to the result of the HTTP requestvoidwhenDownloaded(File targetFolder, Consumer<File[]> callback) Subscribe to the completion of the download of the image in the response.voidSubscribe to the completion of the download of the image in the response.
-
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 receivesImageDataResponseas a parameter
-
whenDownloaded
Subscribe to the completion of the download of the image in the response.- Parameters:
targetFolder- the desired location for downloading the file from the responsecallback- a consumer function to be executed on successful download that receivesImageDataResponseas 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 responsecallback- a consumer function to be executed on successful download that receivesImageDataResponseas a parametererrorHandler- a consumer function that to be executed on unsuccessful download that receivesThrowableas a parameter
-