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 @@ -53,7 +53,7 @@ public class AzureOpenAiImageModelIT {

@Test
void imageAsUrlTest() {
var options = ImageOptionsBuilder.builder().withHeight(1024).withWidth(1024).build();
var options = ImageOptionsBuilder.builder().height(1024).width(1024).build();

var instructions = """
A light cream colored mini golden doodle with a sign that contains the message "I'm on my way to BARCADE!".""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class OpenAiImageModelIT extends AbstractIT {

@Test
void imageAsUrlTest() {
var options = ImageOptionsBuilder.builder().withHeight(1024).withWidth(1024).build();
var options = ImageOptionsBuilder.builder().height(1024).width(1024).build();

var instructions = """
A light cream colored mini golden doodle with a sign that contains the message "I'm on my way to BARCADE!".""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class QianFanImageModelIT {

@Test
void imageTest() {
var options = ImageOptionsBuilder.builder().withHeight(1024).withWidth(1024).build();
var options = ImageOptionsBuilder.builder().height(1024).width(1024).build();

var instructions = """
A light cream colored mini golden doodle with a sign that contains the message "I'm on my way to BARCADE!".""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ZhiPuAiImageModelIT {

@Test
void imageAsUrlTest() {
var options = ImageOptionsBuilder.builder().withHeight(1024).withWidth(1024).build();
var options = ImageOptionsBuilder.builder().height(1024).width(1024).build();

var instructions = """
A light cream colored mini golden doodle with a sign that contains the message "I'm on my way to BARCADE!".""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,85 @@ public static ImageOptionsBuilder builder() {
return new ImageOptionsBuilder();
}

public ImageOptionsBuilder N(Integer n) {
this.options.setN(n);
return this;
}

public ImageOptionsBuilder model(String model) {
this.options.setModel(model);
return this;
}

public ImageOptionsBuilder responseFormat(String responseFormat) {
this.options.setResponseFormat(responseFormat);
return this;
}

public ImageOptionsBuilder width(Integer width) {
this.options.setWidth(width);
return this;
}

public ImageOptionsBuilder height(Integer height) {
this.options.setHeight(height);
return this;
}

public ImageOptionsBuilder style(String style) {
this.options.setStyle(style);
return this;
}

/**
* @deprecated use {@link #N(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withN(Integer n) {
this.options.setN(n);
return this;
}

/**
* @deprecated use {@link #model(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withModel(String model) {
this.options.setModel(model);
return this;
}

/**
* @deprecated use {@link #responseFormat(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withResponseFormat(String responseFormat) {
this.options.setResponseFormat(responseFormat);
return this;
}

/**
* @deprecated use {@link #width(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withWidth(Integer width) {
this.options.setWidth(width);
return this;
}

/**
* @deprecated use {@link #height(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withHeight(Integer height) {
this.options.setHeight(height);
return this;
}

/**
* @deprecated use {@link #style(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public ImageOptionsBuilder withStyle(String style) {
this.options.setStyle(style);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void contextualNameWhenModelIsDefined() {
ImageModelObservationContext observationContext = ImageModelObservationContext.builder()
.imagePrompt(generateImagePrompt())
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
assertThat(this.observationConvention.getContextualName(observationContext)).isEqualTo("image mistral");
}
Expand All @@ -66,7 +66,7 @@ void supportsOnlyImageModelObservationContext() {
ImageModelObservationContext observationContext = ImageModelObservationContext.builder()
.imagePrompt(generateImagePrompt())
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
assertThat(this.observationConvention.supportsContext(observationContext)).isTrue();
assertThat(this.observationConvention.supportsContext(new Observation.Context())).isFalse();
Expand All @@ -77,7 +77,7 @@ void shouldHaveLowCardinalityKeyValuesWhenDefined() {
ImageModelObservationContext observationContext = ImageModelObservationContext.builder()
.imagePrompt(generateImagePrompt())
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
assertThat(this.observationConvention.getLowCardinalityKeyValues(observationContext)).contains(
KeyValue.of(AiObservationAttributes.AI_OPERATION_TYPE.value(), "image"),
Expand All @@ -91,12 +91,12 @@ void shouldHaveHighCardinalityKeyValuesWhenDefined() {
.imagePrompt(generateImagePrompt())
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder()
.withModel("mistral")
.withN(1)
.withHeight(1080)
.withWidth(1920)
.withStyle("sketch")
.withResponseFormat("base64")
.model("mistral")
.N(1)
.height(1080)
.width(1920)
.style("sketch")
.responseFormat("base64")
.build())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void whenMandatoryRequestOptionsThenReturn() {
var observationContext = ImageModelObservationContext.builder()
.imagePrompt(generateImagePrompt())
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("supersun").build())
.requestOptions(ImageOptionsBuilder.builder().model("supersun").build())
.build();

assertThat(observationContext).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void whenEmptyPromptThenReturnOriginalContext() {
var expectedContext = ImageModelObservationContext.builder()
.imagePrompt(new ImagePrompt(""))
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
var actualContext = this.observationFilter.map(expectedContext);

Expand All @@ -63,7 +63,7 @@ void whenPromptWithTextThenAugmentContext() {
var originalContext = ImageModelObservationContext.builder()
.imagePrompt(new ImagePrompt("supercalifragilisticexpialidocious"))
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
var augmentedContext = this.observationFilter.map(originalContext);

Expand All @@ -77,7 +77,7 @@ void whenPromptWithMessagesThenAugmentContext() {
.imagePrompt(new ImagePrompt(List.of(new ImageMessage("you're a chimney sweep"),
new ImageMessage("supercalifragilisticexpialidocious"))))
.provider("superprovider")
.requestOptions(ImageOptionsBuilder.builder().withModel("mistral").build())
.requestOptions(ImageOptionsBuilder.builder().model("mistral").build())
.build();
var augmentedContext = this.observationFilter.map(originalContext);

Expand Down
Loading