Skip to content

Commit df48f5e

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Clean up internal configurations
PiperOrigin-RevId: 826154054
1 parent dce6173 commit df48f5e

File tree

12 files changed

+199
-227
lines changed

12 files changed

+199
-227
lines changed

Google.GenAI/Caches.cs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,17 @@ internal JsonNode FunctionCallToMldev(JsonNode fromObject, JsonObject parentObje
351351
internal JsonNode FunctionCallingConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
352352
JsonObject toObject = new JsonObject();
353353

354-
if (Common.GetValueByPath(fromObject, new string[] { "mode" }) != null) {
355-
Common.SetValueByPath(toObject, new string[] { "mode" },
356-
Common.GetValueByPath(fromObject, new string[] { "mode" }));
357-
}
358-
359354
if (Common.GetValueByPath(fromObject, new string[] { "allowedFunctionNames" }) != null) {
360355
Common.SetValueByPath(
361356
toObject, new string[] { "allowedFunctionNames" },
362357
Common.GetValueByPath(fromObject, new string[] { "allowedFunctionNames" }));
363358
}
364359

360+
if (Common.GetValueByPath(fromObject, new string[] { "mode" }) != null) {
361+
Common.SetValueByPath(toObject, new string[] { "mode" },
362+
Common.GetValueByPath(fromObject, new string[] { "mode" }));
363+
}
364+
365365
if (!Common.IsZero(
366366
Common.GetValueByPath(fromObject, new string[] { "streamFunctionCallArguments" }))) {
367367
throw new NotSupportedException(
@@ -374,10 +374,6 @@ internal JsonNode FunctionCallingConfigToMldev(JsonNode fromObject, JsonObject p
374374
internal JsonNode FunctionDeclarationToVertex(JsonNode fromObject, JsonObject parentObject) {
375375
JsonObject toObject = new JsonObject();
376376

377-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "behavior" }))) {
378-
throw new NotSupportedException("behavior parameter is not supported in Vertex AI.");
379-
}
380-
381377
if (Common.GetValueByPath(fromObject, new string[] { "description" }) != null) {
382378
Common.SetValueByPath(toObject, new string[] { "description" },
383379
Common.GetValueByPath(fromObject, new string[] { "description" }));
@@ -410,6 +406,10 @@ internal JsonNode FunctionDeclarationToVertex(JsonNode fromObject, JsonObject pa
410406
Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }));
411407
}
412408

409+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "behavior" }))) {
410+
throw new NotSupportedException("behavior parameter is not supported in Vertex AI.");
411+
}
412+
413413
return toObject;
414414
}
415415

@@ -663,6 +663,12 @@ internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
663663
internal JsonNode ToolConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
664664
JsonObject toObject = new JsonObject();
665665

666+
if (Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }) != null) {
667+
Common.SetValueByPath(
668+
toObject, new string[] { "retrievalConfig" },
669+
Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }));
670+
}
671+
666672
if (Common.GetValueByPath(fromObject, new string[] { "functionCallingConfig" }) != null) {
667673
Common.SetValueByPath(toObject, new string[] { "functionCallingConfig" },
668674
FunctionCallingConfigToMldev(
@@ -671,34 +677,16 @@ internal JsonNode ToolConfigToMldev(JsonNode fromObject, JsonObject parentObject
671677
toObject));
672678
}
673679

674-
if (Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }) != null) {
675-
Common.SetValueByPath(
676-
toObject, new string[] { "retrievalConfig" },
677-
Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }));
678-
}
679-
680680
return toObject;
681681
}
682682

683683
internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
684684
JsonObject toObject = new JsonObject();
685685

686-
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
687-
Common.SetValueByPath(
688-
toObject, new string[] { "functionDeclarations" },
689-
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
690-
}
691-
692686
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "retrieval" }))) {
693687
throw new NotSupportedException("retrieval parameter is not supported in Gemini API.");
694688
}
695689

696-
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
697-
Common.SetValueByPath(
698-
toObject, new string[] { "googleSearchRetrieval" },
699-
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
700-
}
701-
702690
if (Common.GetValueByPath(fromObject, new string[] { "computerUse" }) != null) {
703691
Common.SetValueByPath(toObject, new string[] { "computerUse" },
704692
Common.GetValueByPath(fromObject, new string[] { "computerUse" }));
@@ -715,6 +703,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
715703
"enterpriseWebSearch parameter is not supported in Gemini API.");
716704
}
717705

706+
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
707+
Common.SetValueByPath(
708+
toObject, new string[] { "functionDeclarations" },
709+
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
710+
}
711+
718712
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
719713
Common.SetValueByPath(
720714
toObject, new string[] { "googleMaps" },
@@ -731,6 +725,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
731725
toObject));
732726
}
733727

728+
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
729+
Common.SetValueByPath(
730+
toObject, new string[] { "googleSearchRetrieval" },
731+
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
732+
}
733+
734734
if (Common.GetValueByPath(fromObject, new string[] { "urlContext" }) != null) {
735735
Common.SetValueByPath(toObject, new string[] { "urlContext" },
736736
Common.GetValueByPath(fromObject, new string[] { "urlContext" }));
@@ -742,29 +742,11 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
742742
internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
743743
JsonObject toObject = new JsonObject();
744744

745-
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
746-
JsonArray keyArray =
747-
(JsonArray)Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" });
748-
JsonArray result = new JsonArray();
749-
750-
foreach (var record in keyArray) {
751-
result.Add(FunctionDeclarationToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)),
752-
toObject));
753-
}
754-
Common.SetValueByPath(toObject, new string[] { "functionDeclarations" }, result);
755-
}
756-
757745
if (Common.GetValueByPath(fromObject, new string[] { "retrieval" }) != null) {
758746
Common.SetValueByPath(toObject, new string[] { "retrieval" },
759747
Common.GetValueByPath(fromObject, new string[] { "retrieval" }));
760748
}
761749

762-
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
763-
Common.SetValueByPath(
764-
toObject, new string[] { "googleSearchRetrieval" },
765-
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
766-
}
767-
768750
if (Common.GetValueByPath(fromObject, new string[] { "computerUse" }) != null) {
769751
Common.SetValueByPath(toObject, new string[] { "computerUse" },
770752
Common.GetValueByPath(fromObject, new string[] { "computerUse" }));
@@ -781,6 +763,18 @@ internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
781763
Common.GetValueByPath(fromObject, new string[] { "enterpriseWebSearch" }));
782764
}
783765

766+
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
767+
JsonArray keyArray =
768+
(JsonArray)Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" });
769+
JsonArray result = new JsonArray();
770+
771+
foreach (var record in keyArray) {
772+
result.Add(FunctionDeclarationToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)),
773+
toObject));
774+
}
775+
Common.SetValueByPath(toObject, new string[] { "functionDeclarations" }, result);
776+
}
777+
784778
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
785779
Common.SetValueByPath(toObject, new string[] { "googleMaps" },
786780
Common.GetValueByPath(fromObject, new string[] { "googleMaps" }));
@@ -791,6 +785,12 @@ internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
791785
Common.GetValueByPath(fromObject, new string[] { "googleSearch" }));
792786
}
793787

788+
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
789+
Common.SetValueByPath(
790+
toObject, new string[] { "googleSearchRetrieval" },
791+
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
792+
}
793+
794794
if (Common.GetValueByPath(fromObject, new string[] { "urlContext" }) != null) {
795795
Common.SetValueByPath(toObject, new string[] { "urlContext" },
796796
Common.GetValueByPath(fromObject, new string[] { "urlContext" }));

Google.GenAI/LiveConverters.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ internal JsonNode FunctionCallToMldev(JsonNode fromObject, JsonObject parentObje
138138
internal JsonNode FunctionDeclarationToVertex(JsonNode fromObject, JsonObject parentObject) {
139139
JsonObject toObject = new JsonObject();
140140

141-
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "behavior" }))) {
142-
throw new NotSupportedException("behavior parameter is not supported in Vertex AI.");
143-
}
144-
145141
if (Common.GetValueByPath(fromObject, new string[] { "description" }) != null) {
146142
Common.SetValueByPath(toObject, new string[] { "description" },
147143
Common.GetValueByPath(fromObject, new string[] { "description" }));
@@ -174,6 +170,10 @@ internal JsonNode FunctionDeclarationToVertex(JsonNode fromObject, JsonObject pa
174170
Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }));
175171
}
176172

173+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "behavior" }))) {
174+
throw new NotSupportedException("behavior parameter is not supported in Vertex AI.");
175+
}
176+
177177
return toObject;
178178
}
179179

@@ -1247,22 +1247,10 @@ internal JsonNode SpeechConfigToVertex(JsonNode fromObject, JsonObject parentObj
12471247
internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
12481248
JsonObject toObject = new JsonObject();
12491249

1250-
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1251-
Common.SetValueByPath(
1252-
toObject, new string[] { "functionDeclarations" },
1253-
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
1254-
}
1255-
12561250
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "retrieval" }))) {
12571251
throw new NotSupportedException("retrieval parameter is not supported in Gemini API.");
12581252
}
12591253

1260-
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1261-
Common.SetValueByPath(
1262-
toObject, new string[] { "googleSearchRetrieval" },
1263-
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1264-
}
1265-
12661254
if (Common.GetValueByPath(fromObject, new string[] { "computerUse" }) != null) {
12671255
Common.SetValueByPath(toObject, new string[] { "computerUse" },
12681256
Common.GetValueByPath(fromObject, new string[] { "computerUse" }));
@@ -1279,6 +1267,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
12791267
"enterpriseWebSearch parameter is not supported in Gemini API.");
12801268
}
12811269

1270+
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1271+
Common.SetValueByPath(
1272+
toObject, new string[] { "functionDeclarations" },
1273+
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
1274+
}
1275+
12821276
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
12831277
Common.SetValueByPath(
12841278
toObject, new string[] { "googleMaps" },
@@ -1295,6 +1289,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
12951289
toObject));
12961290
}
12971291

1292+
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1293+
Common.SetValueByPath(
1294+
toObject, new string[] { "googleSearchRetrieval" },
1295+
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1296+
}
1297+
12981298
if (Common.GetValueByPath(fromObject, new string[] { "urlContext" }) != null) {
12991299
Common.SetValueByPath(toObject, new string[] { "urlContext" },
13001300
Common.GetValueByPath(fromObject, new string[] { "urlContext" }));
@@ -1306,29 +1306,11 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
13061306
internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
13071307
JsonObject toObject = new JsonObject();
13081308

1309-
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1310-
JsonArray keyArray =
1311-
(JsonArray)Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" });
1312-
JsonArray result = new JsonArray();
1313-
1314-
foreach (var record in keyArray) {
1315-
result.Add(FunctionDeclarationToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)),
1316-
toObject));
1317-
}
1318-
Common.SetValueByPath(toObject, new string[] { "functionDeclarations" }, result);
1319-
}
1320-
13211309
if (Common.GetValueByPath(fromObject, new string[] { "retrieval" }) != null) {
13221310
Common.SetValueByPath(toObject, new string[] { "retrieval" },
13231311
Common.GetValueByPath(fromObject, new string[] { "retrieval" }));
13241312
}
13251313

1326-
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1327-
Common.SetValueByPath(
1328-
toObject, new string[] { "googleSearchRetrieval" },
1329-
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1330-
}
1331-
13321314
if (Common.GetValueByPath(fromObject, new string[] { "computerUse" }) != null) {
13331315
Common.SetValueByPath(toObject, new string[] { "computerUse" },
13341316
Common.GetValueByPath(fromObject, new string[] { "computerUse" }));
@@ -1345,6 +1327,18 @@ internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
13451327
Common.GetValueByPath(fromObject, new string[] { "enterpriseWebSearch" }));
13461328
}
13471329

1330+
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1331+
JsonArray keyArray =
1332+
(JsonArray)Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" });
1333+
JsonArray result = new JsonArray();
1334+
1335+
foreach (var record in keyArray) {
1336+
result.Add(FunctionDeclarationToVertex(JsonNode.Parse(JsonSerializer.Serialize(record)),
1337+
toObject));
1338+
}
1339+
Common.SetValueByPath(toObject, new string[] { "functionDeclarations" }, result);
1340+
}
1341+
13481342
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
13491343
Common.SetValueByPath(toObject, new string[] { "googleMaps" },
13501344
Common.GetValueByPath(fromObject, new string[] { "googleMaps" }));
@@ -1355,6 +1349,12 @@ internal JsonNode ToolToVertex(JsonNode fromObject, JsonObject parentObject) {
13551349
Common.GetValueByPath(fromObject, new string[] { "googleSearch" }));
13561350
}
13571351

1352+
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1353+
Common.SetValueByPath(
1354+
toObject, new string[] { "googleSearchRetrieval" },
1355+
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1356+
}
1357+
13581358
if (Common.GetValueByPath(fromObject, new string[] { "urlContext" }) != null) {
13591359
Common.SetValueByPath(toObject, new string[] { "urlContext" },
13601360
Common.GetValueByPath(fromObject, new string[] { "urlContext" }));

0 commit comments

Comments
 (0)