Skip to content

Commit 625da52

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Clean up internal configurations
PiperOrigin-RevId: 845882194
1 parent 83eadf0 commit 625da52

14 files changed

+432
-507
lines changed

src/main/java/com/google/genai/Batches.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,18 +1013,18 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) {
10131013
@ExcludeFromGeneratedCoverageReport
10141014
ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
10151015
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1016-
if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) {
1016+
if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) {
10171017
Common.setValueByPath(
10181018
toObject,
1019-
new String[] {"mode"},
1020-
Common.getValueByPath(fromObject, new String[] {"mode"}));
1019+
new String[] {"allowedFunctionNames"},
1020+
Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}));
10211021
}
10221022

1023-
if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) {
1023+
if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) {
10241024
Common.setValueByPath(
10251025
toObject,
1026-
new String[] {"allowedFunctionNames"},
1027-
Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}));
1026+
new String[] {"mode"},
1027+
Common.getValueByPath(fromObject, new String[] {"mode"}));
10281028
}
10291029

10301030
if (!Common.isZero(
@@ -1756,6 +1756,13 @@ ObjectNode safetySettingToMldev(JsonNode fromObject, ObjectNode parentObject) {
17561756
@ExcludeFromGeneratedCoverageReport
17571757
ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
17581758
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1759+
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
1760+
Common.setValueByPath(
1761+
toObject,
1762+
new String[] {"retrievalConfig"},
1763+
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
1764+
}
1765+
17591766
if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) {
17601767
Common.setValueByPath(
17611768
toObject,
@@ -1766,37 +1773,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
17661773
toObject));
17671774
}
17681775

1769-
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
1770-
Common.setValueByPath(
1771-
toObject,
1772-
new String[] {"retrievalConfig"},
1773-
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
1774-
}
1775-
17761776
return toObject;
17771777
}
17781778

17791779
@ExcludeFromGeneratedCoverageReport
17801780
ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
17811781
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1782-
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
1783-
Common.setValueByPath(
1784-
toObject,
1785-
new String[] {"functionDeclarations"},
1786-
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
1787-
}
1788-
17891782
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) {
17901783
throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API.");
17911784
}
17921785

1793-
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
1794-
Common.setValueByPath(
1795-
toObject,
1796-
new String[] {"googleSearchRetrieval"},
1797-
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
1798-
}
1799-
18001786
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
18011787
Common.setValueByPath(
18021788
toObject,
@@ -1823,6 +1809,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
18231809
"enterpriseWebSearch parameter is not supported in Gemini API.");
18241810
}
18251811

1812+
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
1813+
Common.setValueByPath(
1814+
toObject,
1815+
new String[] {"functionDeclarations"},
1816+
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
1817+
}
1818+
18261819
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
18271820
Common.setValueByPath(
18281821
toObject,
@@ -1843,6 +1836,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
18431836
toObject));
18441837
}
18451838

1839+
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
1840+
Common.setValueByPath(
1841+
toObject,
1842+
new String[] {"googleSearchRetrieval"},
1843+
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
1844+
}
1845+
18461846
if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) {
18471847
Common.setValueByPath(
18481848
toObject,

src/main/java/com/google/genai/Caches.java

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,18 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) {
414414
@ExcludeFromGeneratedCoverageReport
415415
ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
416416
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
417-
if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) {
417+
if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) {
418418
Common.setValueByPath(
419419
toObject,
420-
new String[] {"mode"},
421-
Common.getValueByPath(fromObject, new String[] {"mode"}));
420+
new String[] {"allowedFunctionNames"},
421+
Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}));
422422
}
423423

424-
if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) {
424+
if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) {
425425
Common.setValueByPath(
426426
toObject,
427-
new String[] {"allowedFunctionNames"},
428-
Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}));
427+
new String[] {"mode"},
428+
Common.getValueByPath(fromObject, new String[] {"mode"}));
429429
}
430430

431431
if (!Common.isZero(
@@ -440,10 +440,6 @@ ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentOb
440440
@ExcludeFromGeneratedCoverageReport
441441
ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObject) {
442442
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
443-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) {
444-
throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI.");
445-
}
446-
447443
if (Common.getValueByPath(fromObject, new String[] {"description"}) != null) {
448444
Common.setValueByPath(
449445
toObject,
@@ -486,6 +482,10 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj
486482
Common.getValueByPath(fromObject, new String[] {"responseJsonSchema"}));
487483
}
488484

485+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) {
486+
throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI.");
487+
}
488+
489489
return toObject;
490490
}
491491

@@ -778,6 +778,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
778778
@ExcludeFromGeneratedCoverageReport
779779
ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
780780
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
781+
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
782+
Common.setValueByPath(
783+
toObject,
784+
new String[] {"retrievalConfig"},
785+
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
786+
}
787+
781788
if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) {
782789
Common.setValueByPath(
783790
toObject,
@@ -788,37 +795,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
788795
toObject));
789796
}
790797

791-
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
792-
Common.setValueByPath(
793-
toObject,
794-
new String[] {"retrievalConfig"},
795-
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
796-
}
797-
798798
return toObject;
799799
}
800800

801801
@ExcludeFromGeneratedCoverageReport
802802
ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
803803
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
804-
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
805-
Common.setValueByPath(
806-
toObject,
807-
new String[] {"functionDeclarations"},
808-
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
809-
}
810-
811804
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) {
812805
throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API.");
813806
}
814807

815-
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
816-
Common.setValueByPath(
817-
toObject,
818-
new String[] {"googleSearchRetrieval"},
819-
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
820-
}
821-
822808
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
823809
Common.setValueByPath(
824810
toObject,
@@ -845,6 +831,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
845831
"enterpriseWebSearch parameter is not supported in Gemini API.");
846832
}
847833

834+
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
835+
Common.setValueByPath(
836+
toObject,
837+
new String[] {"functionDeclarations"},
838+
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
839+
}
840+
848841
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
849842
Common.setValueByPath(
850843
toObject,
@@ -865,6 +858,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
865858
toObject));
866859
}
867860

861+
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
862+
Common.setValueByPath(
863+
toObject,
864+
new String[] {"googleSearchRetrieval"},
865+
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
866+
}
867+
868868
if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) {
869869
Common.setValueByPath(
870870
toObject,
@@ -878,32 +878,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
878878
@ExcludeFromGeneratedCoverageReport
879879
ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
880880
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
881-
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
882-
ArrayNode keyArray =
883-
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"});
884-
ObjectMapper objectMapper = new ObjectMapper();
885-
ArrayNode result = objectMapper.createArrayNode();
886-
887-
for (JsonNode item : keyArray) {
888-
result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject));
889-
}
890-
Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result);
891-
}
892-
893881
if (Common.getValueByPath(fromObject, new String[] {"retrieval"}) != null) {
894882
Common.setValueByPath(
895883
toObject,
896884
new String[] {"retrieval"},
897885
Common.getValueByPath(fromObject, new String[] {"retrieval"}));
898886
}
899887

900-
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
901-
Common.setValueByPath(
902-
toObject,
903-
new String[] {"googleSearchRetrieval"},
904-
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
905-
}
906-
907888
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
908889
Common.setValueByPath(
909890
toObject,
@@ -929,6 +910,18 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
929910
Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}));
930911
}
931912

913+
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
914+
ArrayNode keyArray =
915+
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"});
916+
ObjectMapper objectMapper = new ObjectMapper();
917+
ArrayNode result = objectMapper.createArrayNode();
918+
919+
for (JsonNode item : keyArray) {
920+
result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject));
921+
}
922+
Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result);
923+
}
924+
932925
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
933926
Common.setValueByPath(
934927
toObject,
@@ -943,6 +936,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
943936
Common.getValueByPath(fromObject, new String[] {"googleSearch"}));
944937
}
945938

939+
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
940+
Common.setValueByPath(
941+
toObject,
942+
new String[] {"googleSearchRetrieval"},
943+
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
944+
}
945+
946946
if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) {
947947
Common.setValueByPath(
948948
toObject,

0 commit comments

Comments
 (0)