Skip to content

Commit 0a340fc

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

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(
@@ -1751,6 +1751,13 @@ ObjectNode safetySettingToMldev(JsonNode fromObject, ObjectNode parentObject) {
17511751
@ExcludeFromGeneratedCoverageReport
17521752
ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
17531753
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1754+
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
1755+
Common.setValueByPath(
1756+
toObject,
1757+
new String[] {"retrievalConfig"},
1758+
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
1759+
}
1760+
17541761
if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) {
17551762
Common.setValueByPath(
17561763
toObject,
@@ -1761,37 +1768,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
17611768
toObject));
17621769
}
17631770

1764-
if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
1765-
Common.setValueByPath(
1766-
toObject,
1767-
new String[] {"retrievalConfig"},
1768-
Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}));
1769-
}
1770-
17711771
return toObject;
17721772
}
17731773

17741774
@ExcludeFromGeneratedCoverageReport
17751775
ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
17761776
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1777-
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
1778-
Common.setValueByPath(
1779-
toObject,
1780-
new String[] {"functionDeclarations"},
1781-
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
1782-
}
1783-
17841777
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) {
17851778
throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API.");
17861779
}
17871780

1788-
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
1789-
Common.setValueByPath(
1790-
toObject,
1791-
new String[] {"googleSearchRetrieval"},
1792-
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
1793-
}
1794-
17951781
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
17961782
Common.setValueByPath(
17971783
toObject,
@@ -1818,6 +1804,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
18181804
"enterpriseWebSearch parameter is not supported in Gemini API.");
18191805
}
18201806

1807+
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
1808+
Common.setValueByPath(
1809+
toObject,
1810+
new String[] {"functionDeclarations"},
1811+
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
1812+
}
1813+
18211814
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
18221815
Common.setValueByPath(
18231816
toObject,
@@ -1838,6 +1831,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
18381831
toObject));
18391832
}
18401833

1834+
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
1835+
Common.setValueByPath(
1836+
toObject,
1837+
new String[] {"googleSearchRetrieval"},
1838+
Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}));
1839+
}
1840+
18411841
if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) {
18421842
Common.setValueByPath(
18431843
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)