Skip to content

Commit d147baa

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

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Google.GenAI/Batches.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,11 @@ internal JsonNode ImageConfigToMldev(JsonNode fromObject, JsonObject parentObjec
11861186
Common.GetValueByPath(fromObject, new string[] { "imageSize" }));
11871187
}
11881188

1189+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "personGeneration" }))) {
1190+
throw new NotSupportedException(
1191+
"personGeneration parameter is not supported in Gemini API.");
1192+
}
1193+
11891194
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "outputMimeType" }))) {
11901195
throw new NotSupportedException("outputMimeType parameter is not supported in Gemini API.");
11911196
}

Google.GenAI/Models.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,11 @@ internal JsonNode ImageConfigToMldev(JsonNode fromObject, JsonObject parentObjec
25452545
Common.GetValueByPath(fromObject, new string[] { "imageSize" }));
25462546
}
25472547

2548+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "personGeneration" }))) {
2549+
throw new NotSupportedException(
2550+
"personGeneration parameter is not supported in Gemini API.");
2551+
}
2552+
25482553
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "outputMimeType" }))) {
25492554
throw new NotSupportedException("outputMimeType parameter is not supported in Gemini API.");
25502555
}
@@ -2571,6 +2576,12 @@ internal JsonNode ImageConfigToVertex(JsonNode fromObject, JsonObject parentObje
25712576
Common.GetValueByPath(fromObject, new string[] { "imageSize" }));
25722577
}
25732578

2579+
if (Common.GetValueByPath(fromObject, new string[] { "personGeneration" }) != null) {
2580+
Common.SetValueByPath(
2581+
toObject, new string[] { "personGeneration" },
2582+
Common.GetValueByPath(fromObject, new string[] { "personGeneration" }));
2583+
}
2584+
25742585
if (Common.GetValueByPath(fromObject, new string[] { "outputMimeType" }) != null) {
25752586
Common.SetValueByPath(toObject, new string[] { "imageOutputOptions", "mimeType" },
25762587
Common.GetValueByPath(fromObject, new string[] { "outputMimeType" }));

Google.GenAI/types/ImageConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public string
4646
get; set;
4747
}
4848

49+
/// <summary>
50+
/// Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.
51+
/// </summary>
52+
[JsonPropertyName("personGeneration")]
53+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
54+
public string
55+
? PersonGeneration {
56+
get; set;
57+
}
58+
4959
/// <summary>
5060
/// MIME type of the generated image. This field is not supported in Gemini API.
5161
/// </summary>

0 commit comments

Comments
 (0)