Skip to content

Commit 6c4f902

Browse files
jscudcopybara-github
authored andcommitted
feat: Update data types from discovery doc.
FUTURE_COPYBARA_INTEGRATE_REVIEW=#111 from googleapis:release-please--branches--main--components--Google.GenAI d22c938 PiperOrigin-RevId: 840429835
1 parent 2f59ba0 commit 6c4f902

File tree

86 files changed

+2740
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2740
-538
lines changed

Google.GenAI.E2E.Tests/GenerateContent/GenerateContentStreamErrorHandlingTest.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -142,48 +142,6 @@ public async Task GenerateContentStreamEnterpriseWebSearchGeminiTest() {
142142
Assert.AreEqual(ex.Message, "enterpriseWebSearch parameter is not supported in Gemini API.");
143143
}
144144

145-
[TestMethod]
146-
public async Task GenerateContentStreamMultiSpeakerVoiceConfigVertexTest() {
147-
var ex =
148-
await Assert.ThrowsExceptionAsync<NotSupportedException>(async () => {
149-
await foreach (var chunk in vertexClient.Models.GenerateContentStreamAsync(
150-
model: "gemini-2.0-flash-exp",
151-
contents: "Alice says 'Hi', Bob replies with 'what\'s up?'",
152-
config: new GenerateContentConfig {
153-
ResponseModalities = new List<string> { "AUDIO" },
154-
SpeechConfig =
155-
new SpeechConfig {
156-
MultiSpeakerVoiceConfig =
157-
new MultiSpeakerVoiceConfig {
158-
SpeakerVoiceConfigs =
159-
new List<SpeakerVoiceConfig> {
160-
new SpeakerVoiceConfig {
161-
Speaker = "Alice",
162-
VoiceConfig =
163-
new VoiceConfig {
164-
PrebuiltVoiceConfig =
165-
new PrebuiltVoiceConfig { VoiceName =
166-
"leda" }
167-
}
168-
},
169-
new SpeakerVoiceConfig {
170-
Speaker = "Bob",
171-
VoiceConfig =
172-
new VoiceConfig {
173-
PrebuiltVoiceConfig =
174-
new PrebuiltVoiceConfig { VoiceName =
175-
"kore" }
176-
}
177-
}
178-
}
179-
}
180-
}
181-
})) {}
182-
});
183-
184-
Assert.AreEqual(ex.Message, "multiSpeakerVoiceConfig parameter is not supported in Vertex AI.");
185-
}
186-
187145
[TestMethod]
188146
public async Task GenerateContentStreamLabelsVertexTest() {
189147
await foreach (var chunk in vertexClient.Models.GenerateContentStreamAsync(

Google.GenAI/Batches.cs

Lines changed: 115 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,17 @@ internal JsonNode CandidateFromMldev(JsonNode fromObject, JsonObject parentObjec
423423
Common.GetValueByPath(fromObject, new string[] { "finishReason" }));
424424
}
425425

426-
if (Common.GetValueByPath(fromObject, new string[] { "avgLogprobs" }) != null) {
427-
Common.SetValueByPath(toObject, new string[] { "avgLogprobs" },
428-
Common.GetValueByPath(fromObject, new string[] { "avgLogprobs" }));
429-
}
430-
431426
if (Common.GetValueByPath(fromObject, new string[] { "groundingMetadata" }) != null) {
432427
Common.SetValueByPath(
433428
toObject, new string[] { "groundingMetadata" },
434429
Common.GetValueByPath(fromObject, new string[] { "groundingMetadata" }));
435430
}
436431

432+
if (Common.GetValueByPath(fromObject, new string[] { "avgLogprobs" }) != null) {
433+
Common.SetValueByPath(toObject, new string[] { "avgLogprobs" },
434+
Common.GetValueByPath(fromObject, new string[] { "avgLogprobs" }));
435+
}
436+
437437
if (Common.GetValueByPath(fromObject, new string[] { "index" }) != null) {
438438
Common.SetValueByPath(toObject, new string[] { "index" },
439439
Common.GetValueByPath(fromObject, new string[] { "index" }));
@@ -1031,9 +1031,12 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro
10311031
}
10321032

10331033
if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) {
1034-
Common.SetValueByPath(toObject, new string[] { "speechConfig" },
1035-
Transformers.TSpeechConfig(Common.GetValueByPath(
1036-
fromObject, new string[] { "speechConfig" })));
1034+
Common.SetValueByPath(
1035+
toObject, new string[] { "speechConfig" },
1036+
SpeechConfigToMldev(
1037+
JsonNode.Parse(JsonSerializer.Serialize(Transformers.TSpeechConfig(
1038+
Common.GetValueByPath(fromObject, new string[] { "speechConfig" })))),
1039+
toObject));
10371040
}
10381041

10391042
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }))) {
@@ -1129,34 +1132,19 @@ internal JsonNode GetBatchJobParametersToVertex(ApiClient apiClient, JsonNode fr
11291132
return toObject;
11301133
}
11311134

1132-
internal JsonNode GoogleMapsToMldev(JsonNode fromObject, JsonObject parentObject) {
1133-
JsonObject toObject = new JsonObject();
1134-
1135-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "authConfig" }))) {
1136-
throw new NotSupportedException("authConfig parameter is not supported in Gemini API.");
1137-
}
1138-
1139-
if (Common.GetValueByPath(fromObject, new string[] { "enableWidget" }) != null) {
1140-
Common.SetValueByPath(toObject, new string[] { "enableWidget" },
1141-
Common.GetValueByPath(fromObject, new string[] { "enableWidget" }));
1142-
}
1143-
1144-
return toObject;
1145-
}
1146-
11471135
internal JsonNode GoogleSearchToMldev(JsonNode fromObject, JsonObject parentObject) {
11481136
JsonObject toObject = new JsonObject();
11491137

1150-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "excludeDomains" }))) {
1151-
throw new NotSupportedException("excludeDomains parameter is not supported in Gemini API.");
1152-
}
1153-
11541138
if (!Common.IsZero(
11551139
Common.GetValueByPath(fromObject, new string[] { "blockingConfidence" }))) {
11561140
throw new NotSupportedException(
11571141
"blockingConfidence parameter is not supported in Gemini API.");
11581142
}
11591143

1144+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "excludeDomains" }))) {
1145+
throw new NotSupportedException("excludeDomains parameter is not supported in Gemini API.");
1146+
}
1147+
11601148
if (Common.GetValueByPath(fromObject, new string[] { "timeRangeFilter" }) != null) {
11611149
Common.SetValueByPath(
11621150
toObject, new string[] { "timeRangeFilter" },
@@ -1189,6 +1177,17 @@ internal JsonNode ImageConfigToMldev(JsonNode fromObject, JsonObject parentObjec
11891177
"outputCompressionQuality parameter is not supported in Gemini API.");
11901178
}
11911179

1180+
if (!Common.IsZero(
1181+
Common.GetValueByPath(fromObject, new string[] { "imageOutputOptions" }))) {
1182+
throw new NotSupportedException(
1183+
"imageOutputOptions parameter is not supported in Gemini API.");
1184+
}
1185+
1186+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "personGeneration" }))) {
1187+
throw new NotSupportedException(
1188+
"personGeneration parameter is not supported in Gemini API.");
1189+
}
1190+
11921191
return toObject;
11931192
}
11941193

@@ -1378,6 +1377,24 @@ internal JsonNode ListBatchJobsResponseFromVertex(JsonNode fromObject,
13781377
return toObject;
13791378
}
13801379

1380+
internal JsonNode MultiSpeakerVoiceConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
1381+
JsonObject toObject = new JsonObject();
1382+
1383+
if (Common.GetValueByPath(fromObject, new string[] { "speakerVoiceConfigs" }) != null) {
1384+
JsonArray keyArray =
1385+
(JsonArray)Common.GetValueByPath(fromObject, new string[] { "speakerVoiceConfigs" });
1386+
JsonArray result = new JsonArray();
1387+
1388+
foreach (var record in keyArray) {
1389+
result.Add(SpeakerVoiceConfigToMldev(JsonNode.Parse(JsonSerializer.Serialize(record)),
1390+
toObject));
1391+
}
1392+
Common.SetValueByPath(toObject, new string[] { "speakerVoiceConfigs" }, result);
1393+
}
1394+
1395+
return toObject;
1396+
}
1397+
13811398
internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
13821399
JsonObject toObject = new JsonObject();
13831400

@@ -1449,6 +1466,11 @@ internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
14491466
Common.GetValueByPath(fromObject, new string[] { "videoMetadata" }));
14501467
}
14511468

1469+
if (Common.GetValueByPath(fromObject, new string[] { "partMetadata" }) != null) {
1470+
Common.SetValueByPath(toObject, new string[] { "partMetadata" },
1471+
Common.GetValueByPath(fromObject, new string[] { "partMetadata" }));
1472+
}
1473+
14521474
return toObject;
14531475
}
14541476

@@ -1472,6 +1494,52 @@ internal JsonNode SafetySettingToMldev(JsonNode fromObject, JsonObject parentObj
14721494
return toObject;
14731495
}
14741496

1497+
internal JsonNode SpeakerVoiceConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
1498+
JsonObject toObject = new JsonObject();
1499+
1500+
if (Common.GetValueByPath(fromObject, new string[] { "speaker" }) != null) {
1501+
Common.SetValueByPath(toObject, new string[] { "speaker" },
1502+
Common.GetValueByPath(fromObject, new string[] { "speaker" }));
1503+
}
1504+
1505+
if (Common.GetValueByPath(fromObject, new string[] { "voiceConfig" }) != null) {
1506+
Common.SetValueByPath(
1507+
toObject, new string[] { "voiceConfig" },
1508+
VoiceConfigToMldev(JsonNode.Parse(JsonSerializer.Serialize(Common.GetValueByPath(
1509+
fromObject, new string[] { "voiceConfig" }))),
1510+
toObject));
1511+
}
1512+
1513+
return toObject;
1514+
}
1515+
1516+
internal JsonNode SpeechConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
1517+
JsonObject toObject = new JsonObject();
1518+
1519+
if (Common.GetValueByPath(fromObject, new string[] { "languageCode" }) != null) {
1520+
Common.SetValueByPath(toObject, new string[] { "languageCode" },
1521+
Common.GetValueByPath(fromObject, new string[] { "languageCode" }));
1522+
}
1523+
1524+
if (Common.GetValueByPath(fromObject, new string[] { "multiSpeakerVoiceConfig" }) != null) {
1525+
Common.SetValueByPath(toObject, new string[] { "multiSpeakerVoiceConfig" },
1526+
MultiSpeakerVoiceConfigToMldev(
1527+
JsonNode.Parse(JsonSerializer.Serialize(Common.GetValueByPath(
1528+
fromObject, new string[] { "multiSpeakerVoiceConfig" }))),
1529+
toObject));
1530+
}
1531+
1532+
if (Common.GetValueByPath(fromObject, new string[] { "voiceConfig" }) != null) {
1533+
Common.SetValueByPath(
1534+
toObject, new string[] { "voiceConfig" },
1535+
VoiceConfigToMldev(JsonNode.Parse(JsonSerializer.Serialize(Common.GetValueByPath(
1536+
fromObject, new string[] { "voiceConfig" }))),
1537+
toObject));
1538+
}
1539+
1540+
return toObject;
1541+
}
1542+
14751543
internal JsonNode ToolConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
14761544
JsonObject toObject = new JsonObject();
14771545

@@ -1528,11 +1596,8 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
15281596
}
15291597

15301598
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
1531-
Common.SetValueByPath(
1532-
toObject, new string[] { "googleMaps" },
1533-
GoogleMapsToMldev(JsonNode.Parse(JsonSerializer.Serialize(Common.GetValueByPath(
1534-
fromObject, new string[] { "googleMaps" }))),
1535-
toObject));
1599+
Common.SetValueByPath(toObject, new string[] { "googleMaps" },
1600+
Common.GetValueByPath(fromObject, new string[] { "googleMaps" }));
15361601
}
15371602

15381603
if (Common.GetValueByPath(fromObject, new string[] { "googleSearch" }) != null) {
@@ -1551,6 +1616,24 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
15511616
return toObject;
15521617
}
15531618

1619+
internal JsonNode VoiceConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
1620+
JsonObject toObject = new JsonObject();
1621+
1622+
if (Common.GetValueByPath(fromObject, new string[] { "prebuiltVoiceConfig" }) != null) {
1623+
Common.SetValueByPath(
1624+
toObject, new string[] { "prebuiltVoiceConfig" },
1625+
Common.GetValueByPath(fromObject, new string[] { "prebuiltVoiceConfig" }));
1626+
}
1627+
1628+
if (!Common.IsZero(
1629+
Common.GetValueByPath(fromObject, new string[] { "replicatedVoiceConfig" }))) {
1630+
throw new NotSupportedException(
1631+
"replicatedVoiceConfig parameter is not supported in Gemini API.");
1632+
}
1633+
1634+
return toObject;
1635+
}
1636+
15541637
public Batches(ApiClient apiClient) {
15551638
_apiClient = apiClient;
15561639
}

0 commit comments

Comments
 (0)