Skip to content

Commit b94fe68

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 b94fe68

File tree

84 files changed

+2664
-535
lines changed

Some content is hidden

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

84 files changed

+2664
-535
lines changed

Google.GenAI/Batches.cs

Lines changed: 110 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Google.GenAI/Caches.cs

Lines changed: 115 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ internal JsonNode ContentToMldev(JsonNode fromObject, JsonObject parentObject) {
6969
return toObject;
7070
}
7171

72+
internal JsonNode ContentToVertex(JsonNode fromObject, JsonObject parentObject) {
73+
JsonObject toObject = new JsonObject();
74+
75+
if (Common.GetValueByPath(fromObject, new string[] { "parts" }) != null) {
76+
JsonArray keyArray = (JsonArray)Common.GetValueByPath(fromObject, new string[] { "parts" });
77+
JsonArray result = new JsonArray();
78+
79+
foreach (var record in keyArray) {
80+
result.Add(PartToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)), toObject));
81+
}
82+
Common.SetValueByPath(toObject, new string[] { "parts" }, result);
83+
}
84+
85+
if (Common.GetValueByPath(fromObject, new string[] { "role" }) != null) {
86+
Common.SetValueByPath(toObject, new string[] { "role" },
87+
Common.GetValueByPath(fromObject, new string[] { "role" }));
88+
}
89+
90+
return toObject;
91+
}
92+
7293
internal JsonNode CreateCachedContentConfigToMldev(JsonNode fromObject,
7394
JsonObject parentObject) {
7495
JsonObject toObject = new JsonObject();
@@ -153,15 +174,23 @@ internal JsonNode CreateCachedContentConfigToVertex(JsonNode fromObject,
153174
}
154175

155176
if (Common.GetValueByPath(fromObject, new string[] { "contents" }) != null) {
156-
Common.SetValueByPath(
157-
parentObject, new string[] { "contents" },
158-
Transformers.TContents(Common.GetValueByPath(fromObject, new string[] { "contents" })));
177+
var keyList =
178+
Transformers.TContents(Common.GetValueByPath(fromObject, new string[] { "contents" }));
179+
JsonArray result = new JsonArray();
180+
181+
foreach (var record in keyList) {
182+
result.Add(ContentToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)), toObject));
183+
}
184+
Common.SetValueByPath(parentObject, new string[] { "contents" }, result);
159185
}
160186

161187
if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) {
162-
Common.SetValueByPath(parentObject, new string[] { "systemInstruction" },
163-
Transformers.TContent(Common.GetValueByPath(
164-
fromObject, new string[] { "systemInstruction" })));
188+
Common.SetValueByPath(
189+
parentObject, new string[] { "systemInstruction" },
190+
ContentToVertex(
191+
JsonNode.Parse(JsonSerializer.Serialize(Transformers.TContent(
192+
Common.GetValueByPath(fromObject, new string[] { "systemInstruction" })))),
193+
toObject));
165194
}
166195

167196
if (Common.GetValueByPath(fromObject, new string[] { "tools" }) != null) {
@@ -441,34 +470,19 @@ internal JsonNode GetCachedContentParametersToVertex(ApiClient apiClient, JsonNo
441470
return toObject;
442471
}
443472

444-
internal JsonNode GoogleMapsToMldev(JsonNode fromObject, JsonObject parentObject) {
445-
JsonObject toObject = new JsonObject();
446-
447-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "authConfig" }))) {
448-
throw new NotSupportedException("authConfig parameter is not supported in Gemini API.");
449-
}
450-
451-
if (Common.GetValueByPath(fromObject, new string[] { "enableWidget" }) != null) {
452-
Common.SetValueByPath(toObject, new string[] { "enableWidget" },
453-
Common.GetValueByPath(fromObject, new string[] { "enableWidget" }));
454-
}
455-
456-
return toObject;
457-
}
458-
459473
internal JsonNode GoogleSearchToMldev(JsonNode fromObject, JsonObject parentObject) {
460474
JsonObject toObject = new JsonObject();
461475

462-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "excludeDomains" }))) {
463-
throw new NotSupportedException("excludeDomains parameter is not supported in Gemini API.");
464-
}
465-
466476
if (!Common.IsZero(
467477
Common.GetValueByPath(fromObject, new string[] { "blockingConfidence" }))) {
468478
throw new NotSupportedException(
469479
"blockingConfidence parameter is not supported in Gemini API.");
470480
}
471481

482+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "excludeDomains" }))) {
483+
throw new NotSupportedException("excludeDomains parameter is not supported in Gemini API.");
484+
}
485+
472486
if (Common.GetValueByPath(fromObject, new string[] { "timeRangeFilter" }) != null) {
473487
Common.SetValueByPath(
474488
toObject, new string[] { "timeRangeFilter" },
@@ -657,6 +671,80 @@ internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
657671
Common.GetValueByPath(fromObject, new string[] { "videoMetadata" }));
658672
}
659673

674+
if (Common.GetValueByPath(fromObject, new string[] { "partMetadata" }) != null) {
675+
Common.SetValueByPath(toObject, new string[] { "partMetadata" },
676+
Common.GetValueByPath(fromObject, new string[] { "partMetadata" }));
677+
}
678+
679+
return toObject;
680+
}
681+
682+
internal JsonNode PartToVertex(JsonNode fromObject, JsonObject parentObject) {
683+
JsonObject toObject = new JsonObject();
684+
685+
if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) {
686+
Common.SetValueByPath(
687+
toObject, new string[] { "mediaResolution" },
688+
Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }));
689+
}
690+
691+
if (Common.GetValueByPath(fromObject, new string[] { "codeExecutionResult" }) != null) {
692+
Common.SetValueByPath(
693+
toObject, new string[] { "codeExecutionResult" },
694+
Common.GetValueByPath(fromObject, new string[] { "codeExecutionResult" }));
695+
}
696+
697+
if (Common.GetValueByPath(fromObject, new string[] { "executableCode" }) != null) {
698+
Common.SetValueByPath(toObject, new string[] { "executableCode" },
699+
Common.GetValueByPath(fromObject, new string[] { "executableCode" }));
700+
}
701+
702+
if (Common.GetValueByPath(fromObject, new string[] { "fileData" }) != null) {
703+
Common.SetValueByPath(toObject, new string[] { "fileData" },
704+
Common.GetValueByPath(fromObject, new string[] { "fileData" }));
705+
}
706+
707+
if (Common.GetValueByPath(fromObject, new string[] { "functionCall" }) != null) {
708+
Common.SetValueByPath(toObject, new string[] { "functionCall" },
709+
Common.GetValueByPath(fromObject, new string[] { "functionCall" }));
710+
}
711+
712+
if (Common.GetValueByPath(fromObject, new string[] { "functionResponse" }) != null) {
713+
Common.SetValueByPath(
714+
toObject, new string[] { "functionResponse" },
715+
Common.GetValueByPath(fromObject, new string[] { "functionResponse" }));
716+
}
717+
718+
if (Common.GetValueByPath(fromObject, new string[] { "inlineData" }) != null) {
719+
Common.SetValueByPath(toObject, new string[] { "inlineData" },
720+
Common.GetValueByPath(fromObject, new string[] { "inlineData" }));
721+
}
722+
723+
if (Common.GetValueByPath(fromObject, new string[] { "text" }) != null) {
724+
Common.SetValueByPath(toObject, new string[] { "text" },
725+
Common.GetValueByPath(fromObject, new string[] { "text" }));
726+
}
727+
728+
if (Common.GetValueByPath(fromObject, new string[] { "thought" }) != null) {
729+
Common.SetValueByPath(toObject, new string[] { "thought" },
730+
Common.GetValueByPath(fromObject, new string[] { "thought" }));
731+
}
732+
733+
if (Common.GetValueByPath(fromObject, new string[] { "thoughtSignature" }) != null) {
734+
Common.SetValueByPath(
735+
toObject, new string[] { "thoughtSignature" },
736+
Common.GetValueByPath(fromObject, new string[] { "thoughtSignature" }));
737+
}
738+
739+
if (Common.GetValueByPath(fromObject, new string[] { "videoMetadata" }) != null) {
740+
Common.SetValueByPath(toObject, new string[] { "videoMetadata" },
741+
Common.GetValueByPath(fromObject, new string[] { "videoMetadata" }));
742+
}
743+
744+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "partMetadata" }))) {
745+
throw new NotSupportedException("partMetadata parameter is not supported in Vertex AI.");
746+
}
747+
660748
return toObject;
661749
}
662750

@@ -716,11 +804,8 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
716804
}
717805

718806
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
719-
Common.SetValueByPath(
720-
toObject, new string[] { "googleMaps" },
721-
GoogleMapsToMldev(JsonNode.Parse(JsonSerializer.Serialize(Common.GetValueByPath(
722-
fromObject, new string[] { "googleMaps" }))),
723-
toObject));
807+
Common.SetValueByPath(toObject, new string[] { "googleMaps" },
808+
Common.GetValueByPath(fromObject, new string[] { "googleMaps" }));
724809
}
725810

726811
if (Common.GetValueByPath(fromObject, new string[] { "googleSearch" }) != null) {

0 commit comments

Comments
 (0)