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 @@ -55,20 +55,20 @@ public StabilityAiImageModel(StabilityAiApi stabilityAiApi, StabilityAiImageOpti
private static StabilityAiApi.GenerateImageRequest getGenerateImageRequest(ImagePrompt stabilityAiImagePrompt,
StabilityAiImageOptions optionsToUse) {
return new StabilityAiApi.GenerateImageRequest.Builder()
.withTextPrompts(stabilityAiImagePrompt.getInstructions()
.textPrompts(stabilityAiImagePrompt.getInstructions()
.stream()
.map(message -> new StabilityAiApi.GenerateImageRequest.TextPrompts(message.getText(),
message.getWeight()))
.collect(Collectors.toList()))
.withHeight(optionsToUse.getHeight())
.withWidth(optionsToUse.getWidth())
.withCfgScale(optionsToUse.getCfgScale())
.withClipGuidancePreset(optionsToUse.getClipGuidancePreset())
.withSampler(optionsToUse.getSampler())
.withSamples(optionsToUse.getN())
.withSeed(optionsToUse.getSeed())
.withSteps(optionsToUse.getSteps())
.withStylePreset(optionsToUse.getStylePreset())
.height(optionsToUse.getHeight())
.width(optionsToUse.getWidth())
.cfgScale(optionsToUse.getCfgScale())
.clipGuidancePreset(optionsToUse.getClipGuidancePreset())
.sampler(optionsToUse.getSampler())
.samples(optionsToUse.getN())
.seed(optionsToUse.getSeed())
.steps(optionsToUse.getSteps())
.stylePreset(optionsToUse.getStylePreset())
.build();
}

Expand Down Expand Up @@ -124,32 +124,31 @@ StabilityAiImageOptions mergeOptions(ImageOptions runtimeOptions, StabilityAiIma
}
StabilityAiImageOptions.Builder builder = StabilityAiImageOptions.builder()
// Handle portable image options
.withModel(ModelOptionsUtils.mergeOption(runtimeOptions.getModel(), defaultOptions.getModel()))
.withN(ModelOptionsUtils.mergeOption(runtimeOptions.getN(), defaultOptions.getN()))
.withResponseFormat(ModelOptionsUtils.mergeOption(runtimeOptions.getResponseFormat(),
.model(ModelOptionsUtils.mergeOption(runtimeOptions.getModel(), defaultOptions.getModel()))
.N(ModelOptionsUtils.mergeOption(runtimeOptions.getN(), defaultOptions.getN()))
.responseFormat(ModelOptionsUtils.mergeOption(runtimeOptions.getResponseFormat(),
defaultOptions.getResponseFormat()))
.withWidth(ModelOptionsUtils.mergeOption(runtimeOptions.getWidth(), defaultOptions.getWidth()))
.withHeight(ModelOptionsUtils.mergeOption(runtimeOptions.getHeight(), defaultOptions.getHeight()))
.withStylePreset(ModelOptionsUtils.mergeOption(runtimeOptions.getStyle(), defaultOptions.getStyle()))
.width(ModelOptionsUtils.mergeOption(runtimeOptions.getWidth(), defaultOptions.getWidth()))
.height(ModelOptionsUtils.mergeOption(runtimeOptions.getHeight(), defaultOptions.getHeight()))
.stylePreset(ModelOptionsUtils.mergeOption(runtimeOptions.getStyle(), defaultOptions.getStyle()))
// Always set the stability-specific defaults
.withCfgScale(defaultOptions.getCfgScale())
.withClipGuidancePreset(defaultOptions.getClipGuidancePreset())
.withSampler(defaultOptions.getSampler())
.withSeed(defaultOptions.getSeed())
.withSteps(defaultOptions.getSteps())
.withStylePreset(defaultOptions.getStylePreset());
.cfgScale(defaultOptions.getCfgScale())
.clipGuidancePreset(defaultOptions.getClipGuidancePreset())
.sampler(defaultOptions.getSampler())
.seed(defaultOptions.getSeed())
.steps(defaultOptions.getSteps())
.stylePreset(defaultOptions.getStylePreset());
if (runtimeOptions instanceof StabilityAiImageOptions) {
StabilityAiImageOptions stabilityOptions = (StabilityAiImageOptions) runtimeOptions;
// Handle Stability AI specific image options
builder
.withCfgScale(
ModelOptionsUtils.mergeOption(stabilityOptions.getCfgScale(), defaultOptions.getCfgScale()))
.withClipGuidancePreset(ModelOptionsUtils.mergeOption(stabilityOptions.getClipGuidancePreset(),
.cfgScale(ModelOptionsUtils.mergeOption(stabilityOptions.getCfgScale(), defaultOptions.getCfgScale()))
.clipGuidancePreset(ModelOptionsUtils.mergeOption(stabilityOptions.getClipGuidancePreset(),
defaultOptions.getClipGuidancePreset()))
.withSampler(ModelOptionsUtils.mergeOption(stabilityOptions.getSampler(), defaultOptions.getSampler()))
.withSeed(ModelOptionsUtils.mergeOption(stabilityOptions.getSeed(), defaultOptions.getSeed()))
.withSteps(ModelOptionsUtils.mergeOption(stabilityOptions.getSteps(), defaultOptions.getSteps()))
.withStylePreset(ModelOptionsUtils.mergeOption(stabilityOptions.getStylePreset(),
.sampler(ModelOptionsUtils.mergeOption(stabilityOptions.getSampler(), defaultOptions.getSampler()))
.seed(ModelOptionsUtils.mergeOption(stabilityOptions.getSeed(), defaultOptions.getSeed()))
.steps(ModelOptionsUtils.mergeOption(stabilityOptions.getSteps(), defaultOptions.getSteps()))
.stylePreset(ModelOptionsUtils.mergeOption(stabilityOptions.getStylePreset(),
defaultOptions.getStylePreset()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,51 +137,141 @@ public Builder() {

}

public Builder textPrompts(List<TextPrompts> textPrompts) {
this.textPrompts = textPrompts;
return this;
}

public Builder height(Integer height) {
this.height = height;
return this;
}

public Builder width(Integer width) {
this.width = width;
return this;
}

public Builder cfgScale(Float cfgScale) {
this.cfgScale = cfgScale;
return this;
}

public Builder clipGuidancePreset(String clipGuidancePreset) {
this.clipGuidancePreset = clipGuidancePreset;
return this;
}

public Builder sampler(String sampler) {
this.sampler = sampler;
return this;
}

public Builder samples(Integer samples) {
this.samples = samples;
return this;
}

public Builder seed(Long seed) {
this.seed = seed;
return this;
}

public Builder steps(Integer steps) {
this.steps = steps;
return this;
}

public Builder stylePreset(String stylePreset) {
this.stylePreset = stylePreset;
return this;
}

/**
* @deprecated use {@link #textPrompts(List)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withTextPrompts(List<TextPrompts> textPrompts) {
this.textPrompts = textPrompts;
return this;
}

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

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

/**
* @deprecated use {@link #cfgScale(Float)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withCfgScale(Float cfgScale) {
this.cfgScale = cfgScale;
return this;
}

/**
* @deprecated use {@link #clipGuidancePreset(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withClipGuidancePreset(String clipGuidancePreset) {
this.clipGuidancePreset = clipGuidancePreset;
return this;
}

/**
* @deprecated use {@link #sampler(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSampler(String sampler) {
this.sampler = sampler;
return this;
}

/**
* @deprecated use {@link #samples(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSamples(Integer samples) {
this.samples = samples;
return this;
}

/**
* @deprecated use {@link #seed(Long)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSeed(Long seed) {
this.seed = seed;
return this;
}

/**
* @deprecated use {@link #steps(Integer)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withSteps(Integer steps) {
this.steps = steps;
return this;
}

/**
* @deprecated use {@link #stylePreset(String)} instead.
*/
@Deprecated(forRemoval = true, since = "1.0.0-M5")
public Builder withStylePreset(String stylePreset) {
this.stylePreset = stylePreset;
return this;
Expand Down
Loading
Loading