Skip to content

Commit d8a4c43

Browse files
matthew29tangcopybara-github
authored andcommitted
feat: Add PersonGeneration to ImageConfig for Vertex Gempix
PiperOrigin-RevId: 845492961
1 parent ecfadfe commit d8a4c43

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,11 @@ ObjectNode imageConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
14001400
Common.getValueByPath(fromObject, new String[] {"imageSize"}));
14011401
}
14021402

1403+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"personGeneration"}))) {
1404+
throw new IllegalArgumentException(
1405+
"personGeneration parameter is not supported in Gemini API.");
1406+
}
1407+
14031408
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"outputMimeType"}))) {
14041409
throw new IllegalArgumentException(
14051410
"outputMimeType parameter is not supported in Gemini API.");

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,11 @@ ObjectNode imageConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
31113111
Common.getValueByPath(fromObject, new String[] {"imageSize"}));
31123112
}
31133113

3114+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"personGeneration"}))) {
3115+
throw new IllegalArgumentException(
3116+
"personGeneration parameter is not supported in Gemini API.");
3117+
}
3118+
31143119
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"outputMimeType"}))) {
31153120
throw new IllegalArgumentException(
31163121
"outputMimeType parameter is not supported in Gemini API.");
@@ -3142,6 +3147,13 @@ ObjectNode imageConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
31423147
Common.getValueByPath(fromObject, new String[] {"imageSize"}));
31433148
}
31443149

3150+
if (Common.getValueByPath(fromObject, new String[] {"personGeneration"}) != null) {
3151+
Common.setValueByPath(
3152+
toObject,
3153+
new String[] {"personGeneration"},
3154+
Common.getValueByPath(fromObject, new String[] {"personGeneration"}));
3155+
}
3156+
31453157
if (Common.getValueByPath(fromObject, new String[] {"outputMimeType"}) != null) {
31463158
Common.setValueByPath(
31473159
toObject,

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public abstract class ImageConfig extends JsonSerializable {
4444
@JsonProperty("imageSize")
4545
public abstract Optional<String> imageSize();
4646

47+
/**
48+
* Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.
49+
*/
50+
@JsonProperty("personGeneration")
51+
public abstract Optional<String> personGeneration();
52+
4753
/** MIME type of the generated image. This field is not supported in Gemini API. */
4854
@JsonProperty("outputMimeType")
4955
public abstract Optional<String> outputMimeType();
@@ -111,6 +117,25 @@ public Builder clearImageSize() {
111117
return imageSize(Optional.empty());
112118
}
113119

120+
/**
121+
* Setter for personGeneration.
122+
*
123+
* <p>personGeneration: Controls the generation of people. Supported values are: ALLOW_ALL,
124+
* ALLOW_ADULT, ALLOW_NONE.
125+
*/
126+
@JsonProperty("personGeneration")
127+
public abstract Builder personGeneration(String personGeneration);
128+
129+
@ExcludeFromGeneratedCoverageReport
130+
abstract Builder personGeneration(Optional<String> personGeneration);
131+
132+
/** Clears the value of personGeneration field. */
133+
@ExcludeFromGeneratedCoverageReport
134+
@CanIgnoreReturnValue
135+
public Builder clearPersonGeneration() {
136+
return personGeneration(Optional.empty());
137+
}
138+
114139
/**
115140
* Setter for outputMimeType.
116141
*

0 commit comments

Comments
 (0)