Skip to content

Commit 2e17d8f

Browse files
sasha-gitgcopybara-github
authored andcommitted
feat: Add support for enhance_prompt to model.generate_image
PiperOrigin-RevId: 719466587
1 parent 32363e1 commit 2e17d8f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/main/java/com/google/genai/Models.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,13 @@ ObjectNode GenerateImagesConfigToMldev(
15811581
Common.getValueByPath(fromObject, new String[] {"aspectRatio"}));
15821582
}
15831583

1584+
if (Common.getValueByPath(fromObject, new String[] {"enhancePrompt"}) != null) {
1585+
Common.setValueByPath(
1586+
parentObject,
1587+
new String[] {"parameters", "enhancePrompt"},
1588+
Common.getValueByPath(fromObject, new String[] {"enhancePrompt"}));
1589+
}
1590+
15841591
return toObject;
15851592
}
15861593

@@ -1686,6 +1693,13 @@ ObjectNode GenerateImagesConfigToVertex(
16861693
Common.getValueByPath(fromObject, new String[] {"aspectRatio"}));
16871694
}
16881695

1696+
if (Common.getValueByPath(fromObject, new String[] {"enhancePrompt"}) != null) {
1697+
Common.setValueByPath(
1698+
parentObject,
1699+
new String[] {"parameters", "enhancePrompt"},
1700+
Common.getValueByPath(fromObject, new String[] {"enhancePrompt"}));
1701+
}
1702+
16891703
return toObject;
16901704
}
16911705

src/main/java/com/google/genai/types/GenerateImagesConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public abstract class GenerateImagesConfig extends JsonSerializable {
6262
/** Aspect ratio of the generated images. */
6363
public abstract Optional<String> getAspectRatio();
6464

65+
/** Whether to use the prompt rewriting logic. */
66+
public abstract Optional<Boolean> getEnhancePrompt();
67+
6568
/** Instantiates a builder for GenerateImagesConfig. */
6669
public static Builder builder() {
6770
return new AutoValue_GenerateImagesConfig.Builder();
@@ -115,6 +118,9 @@ public abstract static class Builder {
115118
@JsonProperty("aspectRatio")
116119
public abstract Builder setAspectRatio(String aspectRatio);
117120

121+
@JsonProperty("enhancePrompt")
122+
public abstract Builder setEnhancePrompt(boolean enhancePrompt);
123+
118124
public abstract GenerateImagesConfig build();
119125
}
120126

0 commit comments

Comments
 (0)