Skip to content

Commit

Permalink
Add comments in OpenAiImageModel
Browse files Browse the repository at this point in the history
* Add comments in OpenAiImageModel like OpenAiChatModel
  • Loading branch information
devholic22 authored and markpollack committed May 24, 2024
1 parent c26d5f6 commit d6c1b03
Showing 1 changed file with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,55 @@
*
* @author Mark Pollack
* @author Christian Tzolov
* @author Hyunjoon Choi
* @since 0.8.0
*/
public class OpenAiImageModel implements ImageModel {

private final static Logger logger = LoggerFactory.getLogger(OpenAiImageModel.class);

/**
* The default options used for the image completion requests.
*/
private OpenAiImageOptions defaultOptions;

private final OpenAiImageApi openAiImageApi;
/**
* The retry template used to retry the OpenAI Image API calls.
*/
private final RetryTemplate retryTemplate;

public final RetryTemplate retryTemplate;
/**
* Low-level access to the OpenAI Image API.
*/
private final OpenAiImageApi openAiImageApi;

/**
* Creates an instance of the OpenAiImageModel.
* @param openAiImageApi The OpenAiImageApi instance to be used for interacting with the OpenAI
* Image API.
* @throws IllegalArgumentException if openAiImageApi is null
*/
public OpenAiImageModel(OpenAiImageApi openAiImageApi) {
this(openAiImageApi, OpenAiImageOptions.builder().build(), RetryUtils.DEFAULT_RETRY_TEMPLATE);
}

public OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions defaultOptions,
/**
* Initializes a new instance of the OpenAiImageModel.
* @param openAiImageApi The OpenAiImageApi instance to be used for interacting with the OpenAI
* Image API.
* @param options The OpenAiImageOptions to configure the image model.
* @param retryTemplate The retry template.
*/
public OpenAiImageModel(OpenAiImageApi openAiImageApi, OpenAiImageOptions options,
RetryTemplate retryTemplate) {
Assert.notNull(openAiImageApi, "OpenAiImageApi must not be null");
Assert.notNull(defaultOptions, "defaultOptions must not be null");
Assert.notNull(options, "options must not be null");
Assert.notNull(retryTemplate, "retryTemplate must not be null");
this.openAiImageApi = openAiImageApi;
this.defaultOptions = defaultOptions;
this.defaultOptions = options;
this.retryTemplate = retryTemplate;
}

public OpenAiImageOptions getDefaultOptions() {
return this.defaultOptions;
}

@Override
public ImageResponse call(ImagePrompt imagePrompt) {
return this.retryTemplate.execute(ctx -> {
Expand Down Expand Up @@ -158,4 +177,7 @@ private OpenAiImageOptions toOpenAiImageOptions(ImageOptions runtimeImageOptions
return openAiImageOptionsBuilder.build();
}

public OpenAiImageOptions getDefaultOptions() {
return this.defaultOptions;
}
}

0 comments on commit d6c1b03

Please sign in to comment.