Skip to content

Commit 4aa4bec

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Clean up internal configurations
PiperOrigin-RevId: 845882194
1 parent d147baa commit 4aa4bec

13 files changed

+222
-250
lines changed

Google.GenAI/Batches.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -854,17 +854,17 @@ internal JsonNode FunctionCallToMldev(JsonNode fromObject, JsonObject parentObje
854854
internal JsonNode FunctionCallingConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
855855
JsonObject toObject = new JsonObject();
856856

857-
if (Common.GetValueByPath(fromObject, new string[] { "mode" }) != null) {
858-
Common.SetValueByPath(toObject, new string[] { "mode" },
859-
Common.GetValueByPath(fromObject, new string[] { "mode" }));
860-
}
861-
862857
if (Common.GetValueByPath(fromObject, new string[] { "allowedFunctionNames" }) != null) {
863858
Common.SetValueByPath(
864859
toObject, new string[] { "allowedFunctionNames" },
865860
Common.GetValueByPath(fromObject, new string[] { "allowedFunctionNames" }));
866861
}
867862

863+
if (Common.GetValueByPath(fromObject, new string[] { "mode" }) != null) {
864+
Common.SetValueByPath(toObject, new string[] { "mode" },
865+
Common.GetValueByPath(fromObject, new string[] { "mode" }));
866+
}
867+
868868
if (!Common.IsZero(
869869
Common.GetValueByPath(fromObject, new string[] { "streamFunctionCallArguments" }))) {
870870
throw new NotSupportedException(
@@ -1487,6 +1487,12 @@ internal JsonNode SafetySettingToMldev(JsonNode fromObject, JsonObject parentObj
14871487
internal JsonNode ToolConfigToMldev(JsonNode fromObject, JsonObject parentObject) {
14881488
JsonObject toObject = new JsonObject();
14891489

1490+
if (Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }) != null) {
1491+
Common.SetValueByPath(
1492+
toObject, new string[] { "retrievalConfig" },
1493+
Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }));
1494+
}
1495+
14901496
if (Common.GetValueByPath(fromObject, new string[] { "functionCallingConfig" }) != null) {
14911497
Common.SetValueByPath(toObject, new string[] { "functionCallingConfig" },
14921498
FunctionCallingConfigToMldev(
@@ -1495,34 +1501,16 @@ internal JsonNode ToolConfigToMldev(JsonNode fromObject, JsonObject parentObject
14951501
toObject));
14961502
}
14971503

1498-
if (Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }) != null) {
1499-
Common.SetValueByPath(
1500-
toObject, new string[] { "retrievalConfig" },
1501-
Common.GetValueByPath(fromObject, new string[] { "retrievalConfig" }));
1502-
}
1503-
15041504
return toObject;
15051505
}
15061506

15071507
internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
15081508
JsonObject toObject = new JsonObject();
15091509

1510-
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1511-
Common.SetValueByPath(
1512-
toObject, new string[] { "functionDeclarations" },
1513-
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
1514-
}
1515-
15161510
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "retrieval" }))) {
15171511
throw new NotSupportedException("retrieval parameter is not supported in Gemini API.");
15181512
}
15191513

1520-
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1521-
Common.SetValueByPath(
1522-
toObject, new string[] { "googleSearchRetrieval" },
1523-
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1524-
}
1525-
15261514
if (Common.GetValueByPath(fromObject, new string[] { "computerUse" }) != null) {
15271515
Common.SetValueByPath(toObject, new string[] { "computerUse" },
15281516
Common.GetValueByPath(fromObject, new string[] { "computerUse" }));
@@ -1539,6 +1527,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
15391527
"enterpriseWebSearch parameter is not supported in Gemini API.");
15401528
}
15411529

1530+
if (Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }) != null) {
1531+
Common.SetValueByPath(
1532+
toObject, new string[] { "functionDeclarations" },
1533+
Common.GetValueByPath(fromObject, new string[] { "functionDeclarations" }));
1534+
}
1535+
15421536
if (Common.GetValueByPath(fromObject, new string[] { "googleMaps" }) != null) {
15431537
Common.SetValueByPath(
15441538
toObject, new string[] { "googleMaps" },
@@ -1555,6 +1549,12 @@ internal JsonNode ToolToMldev(JsonNode fromObject, JsonObject parentObject) {
15551549
toObject));
15561550
}
15571551

1552+
if (Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }) != null) {
1553+
Common.SetValueByPath(
1554+
toObject, new string[] { "googleSearchRetrieval" },
1555+
Common.GetValueByPath(fromObject, new string[] { "googleSearchRetrieval" }));
1556+
}
1557+
15581558
if (Common.GetValueByPath(fromObject, new string[] { "urlContext" }) != null) {
15591559
Common.SetValueByPath(toObject, new string[] { "urlContext" },
15601560
Common.GetValueByPath(fromObject, new string[] { "urlContext" }));

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" }));

0 commit comments

Comments
 (0)