diff --git a/src/main/java/com/google/genai/Batches.java b/src/main/java/com/google/genai/Batches.java index ab4e021f1c7..192faa17f65 100644 --- a/src/main/java/com/google/genai/Batches.java +++ b/src/main/java/com/google/genai/Batches.java @@ -1013,18 +1013,18 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { Common.setValueByPath( toObject, - new String[] {"mode"}, - Common.getValueByPath(fromObject, new String[] {"mode"})); + new String[] {"allowedFunctionNames"}, + Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); } - if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { Common.setValueByPath( toObject, - new String[] {"allowedFunctionNames"}, - Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); + new String[] {"mode"}, + Common.getValueByPath(fromObject, new String[] {"mode"})); } if (!Common.isZero( @@ -1756,6 +1756,13 @@ ObjectNode safetySettingToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"retrievalConfig"}, + Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); + } + if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) { Common.setValueByPath( toObject, @@ -1766,37 +1773,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } - if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"retrievalConfig"}, - Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); - } - return toObject; } @ExcludeFromGeneratedCoverageReport ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"functionDeclarations"}, - Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); - } - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) { throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API."); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -1823,6 +1809,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { "enterpriseWebSearch parameter is not supported in Gemini API."); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"functionDeclarations"}, + Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -1843,6 +1836,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/Caches.java b/src/main/java/com/google/genai/Caches.java index 3a1a0552975..ebaca35a322 100644 --- a/src/main/java/com/google/genai/Caches.java +++ b/src/main/java/com/google/genai/Caches.java @@ -414,18 +414,18 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { Common.setValueByPath( toObject, - new String[] {"mode"}, - Common.getValueByPath(fromObject, new String[] {"mode"})); + new String[] {"allowedFunctionNames"}, + Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); } - if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { Common.setValueByPath( toObject, - new String[] {"allowedFunctionNames"}, - Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); + new String[] {"mode"}, + Common.getValueByPath(fromObject, new String[] {"mode"})); } if (!Common.isZero( @@ -440,10 +440,6 @@ ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentOb @ExcludeFromGeneratedCoverageReport ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { - throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); - } - if (Common.getValueByPath(fromObject, new String[] {"description"}) != null) { Common.setValueByPath( toObject, @@ -486,6 +482,10 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj Common.getValueByPath(fromObject, new String[] {"responseJsonSchema"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { + throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); + } + return toObject; } @@ -778,6 +778,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"retrievalConfig"}, + Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); + } + if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) { Common.setValueByPath( toObject, @@ -788,37 +795,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } - if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"retrievalConfig"}, - Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); - } - return toObject; } @ExcludeFromGeneratedCoverageReport ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"functionDeclarations"}, - Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); - } - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) { throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API."); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -845,6 +831,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { "enterpriseWebSearch parameter is not supported in Gemini API."); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"functionDeclarations"}, + Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -865,6 +858,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, @@ -878,18 +878,6 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - ArrayNode keyArray = - (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); - ObjectMapper objectMapper = new ObjectMapper(); - ArrayNode result = objectMapper.createArrayNode(); - - for (JsonNode item : keyArray) { - result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); - } - Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); - } - if (Common.getValueByPath(fromObject, new String[] {"retrieval"}) != null) { Common.setValueByPath( toObject, @@ -897,13 +885,6 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"retrieval"})); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -929,6 +910,18 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + ArrayNode keyArray = + (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode result = objectMapper.createArrayNode(); + + for (JsonNode item : keyArray) { + result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); + } + Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -943,6 +936,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"googleSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index 06fdf230d47..9e31bb32129 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -139,10 +139,6 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { - throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); - } - if (Common.getValueByPath(fromObject, new String[] {"description"}) != null) { Common.setValueByPath( toObject, @@ -185,6 +181,10 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj Common.getValueByPath(fromObject, new String[] {"responseJsonSchema"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { + throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); + } + return toObject; } @@ -1477,24 +1477,10 @@ ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parent @ExcludeFromGeneratedCoverageReport ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"functionDeclarations"}, - Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); - } - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) { throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API."); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -1521,6 +1507,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { "enterpriseWebSearch parameter is not supported in Gemini API."); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"functionDeclarations"}, + Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -1541,6 +1534,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, @@ -1554,18 +1554,6 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - ArrayNode keyArray = - (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); - ObjectMapper objectMapper = new ObjectMapper(); - ArrayNode result = objectMapper.createArrayNode(); - - for (JsonNode item : keyArray) { - result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); - } - Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); - } - if (Common.getValueByPath(fromObject, new String[] {"retrieval"}) != null) { Common.setValueByPath( toObject, @@ -1573,13 +1561,6 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"retrieval"})); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -1605,6 +1586,18 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + ArrayNode keyArray = + (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode result = objectMapper.createArrayNode(); + + for (JsonNode item : keyArray) { + result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); + } + Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -1619,6 +1612,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"googleSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java index 8f3cd43be4d..156c48e8891 100644 --- a/src/main/java/com/google/genai/Models.java +++ b/src/main/java/com/google/genai/Models.java @@ -1083,18 +1083,18 @@ ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { Common.setValueByPath( toObject, - new String[] {"mode"}, - Common.getValueByPath(fromObject, new String[] {"mode"})); + new String[] {"allowedFunctionNames"}, + Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); } - if (Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"mode"}) != null) { Common.setValueByPath( toObject, - new String[] {"allowedFunctionNames"}, - Common.getValueByPath(fromObject, new String[] {"allowedFunctionNames"})); + new String[] {"mode"}, + Common.getValueByPath(fromObject, new String[] {"mode"})); } if (!Common.isZero( @@ -1109,10 +1109,6 @@ ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentOb @ExcludeFromGeneratedCoverageReport ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { - throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); - } - if (Common.getValueByPath(fromObject, new String[] {"description"}) != null) { Common.setValueByPath( toObject, @@ -1155,6 +1151,10 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj Common.getValueByPath(fromObject, new String[] {"responseJsonSchema"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"behavior"}))) { + throw new IllegalArgumentException("behavior parameter is not supported in Vertex AI."); + } + return toObject; } @@ -4217,6 +4217,13 @@ ObjectNode segmentImageSourceToVertex(JsonNode fromObject, ObjectNode parentObje @ExcludeFromGeneratedCoverageReport ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"retrievalConfig"}, + Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); + } + if (Common.getValueByPath(fromObject, new String[] {"functionCallingConfig"}) != null) { Common.setValueByPath( toObject, @@ -4227,37 +4234,16 @@ ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } - if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"retrievalConfig"}, - Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})); - } - return toObject; } @ExcludeFromGeneratedCoverageReport ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"functionDeclarations"}, - Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); - } - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) { throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API."); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -4284,6 +4270,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { "enterpriseWebSearch parameter is not supported in Gemini API."); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"functionDeclarations"}, + Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -4304,6 +4297,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, @@ -4317,18 +4317,6 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { @ExcludeFromGeneratedCoverageReport ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - ArrayNode keyArray = - (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); - ObjectMapper objectMapper = new ObjectMapper(); - ArrayNode result = objectMapper.createArrayNode(); - - for (JsonNode item : keyArray) { - result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); - } - Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); - } - if (Common.getValueByPath(fromObject, new String[] {"retrieval"}) != null) { Common.setValueByPath( toObject, @@ -4336,13 +4324,6 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"retrieval"})); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -4368,6 +4349,18 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + ArrayNode keyArray = + (ArrayNode) Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}); + ObjectMapper objectMapper = new ObjectMapper(); + ArrayNode result = objectMapper.createArrayNode(); + + for (JsonNode item : keyArray) { + result.add(functionDeclarationToVertex(JsonSerializable.toJsonNode(item), toObject)); + } + Common.setValueByPath(toObject, new String[] {"functionDeclarations"}, result); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -4382,6 +4375,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"googleSearch"})); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/TokensConverters.java b/src/main/java/com/google/genai/TokensConverters.java index b1e3cbbd00f..a3fca5225b7 100644 --- a/src/main/java/com/google/genai/TokensConverters.java +++ b/src/main/java/com/google/genai/TokensConverters.java @@ -540,24 +540,10 @@ ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parent @ExcludeFromGeneratedCoverageReport ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"functionDeclarations"}, - Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); - } - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrieval"}))) { throw new IllegalArgumentException("retrieval parameter is not supported in Gemini API."); } - if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"googleSearchRetrieval"}, - Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); - } - if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) { Common.setValueByPath( toObject, @@ -584,6 +570,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { "enterpriseWebSearch parameter is not supported in Gemini API."); } + if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"functionDeclarations"}, + Common.getValueByPath(fromObject, new String[] {"functionDeclarations"})); + } + if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) { Common.setValueByPath( toObject, @@ -604,6 +597,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { toObject)); } + if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"googleSearchRetrieval"}, + Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"})); + } + if (Common.getValueByPath(fromObject, new String[] {"urlContext"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/types/Behavior.java b/src/main/java/com/google/genai/types/Behavior.java index 4b043a4484e..b260415ee87 100644 --- a/src/main/java/com/google/genai/types/Behavior.java +++ b/src/main/java/com/google/genai/types/Behavior.java @@ -23,7 +23,10 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** Defines the function behavior. Defaults to `BLOCKING`. */ +/** + * Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This + * enum is not supported in Vertex AI. + */ public class Behavior { /** Enum representing the known values for Behavior. */ diff --git a/src/main/java/com/google/genai/types/DynamicRetrievalConfig.java b/src/main/java/com/google/genai/types/DynamicRetrievalConfig.java index a73df775427..f8a2953a540 100644 --- a/src/main/java/com/google/genai/types/DynamicRetrievalConfig.java +++ b/src/main/java/com/google/genai/types/DynamicRetrievalConfig.java @@ -30,10 +30,6 @@ @AutoValue @JsonDeserialize(builder = DynamicRetrievalConfig.Builder.class) public abstract class DynamicRetrievalConfig extends JsonSerializable { - /** The mode of the predictor to be used in dynamic retrieval. */ - @JsonProperty("mode") - public abstract Optional mode(); - /** * Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is * used. @@ -41,6 +37,10 @@ public abstract class DynamicRetrievalConfig extends JsonSerializable { @JsonProperty("dynamicThreshold") public abstract Optional dynamicThreshold(); + /** The mode of the predictor to be used in dynamic retrieval. */ + @JsonProperty("mode") + public abstract Optional mode(); + /** Instantiates a builder for DynamicRetrievalConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -59,6 +59,25 @@ private static Builder create() { return new AutoValue_DynamicRetrievalConfig.Builder(); } + /** + * Setter for dynamicThreshold. + * + *

dynamicThreshold: Optional. The threshold to be used in dynamic retrieval. If not set, a + * system default value is used. + */ + @JsonProperty("dynamicThreshold") + public abstract Builder dynamicThreshold(Float dynamicThreshold); + + @ExcludeFromGeneratedCoverageReport + abstract Builder dynamicThreshold(Optional dynamicThreshold); + + /** Clears the value of dynamicThreshold field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDynamicThreshold() { + return dynamicThreshold(Optional.empty()); + } + /** * Setter for mode. * @@ -97,25 +116,6 @@ public Builder mode(String mode) { return mode(new DynamicRetrievalConfigMode(mode)); } - /** - * Setter for dynamicThreshold. - * - *

dynamicThreshold: Optional. The threshold to be used in dynamic retrieval. If not set, a - * system default value is used. - */ - @JsonProperty("dynamicThreshold") - public abstract Builder dynamicThreshold(Float dynamicThreshold); - - @ExcludeFromGeneratedCoverageReport - abstract Builder dynamicThreshold(Optional dynamicThreshold); - - /** Clears the value of dynamicThreshold field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearDynamicThreshold() { - return dynamicThreshold(Optional.empty()); - } - public abstract DynamicRetrievalConfig build(); } diff --git a/src/main/java/com/google/genai/types/DynamicRetrievalConfigMode.java b/src/main/java/com/google/genai/types/DynamicRetrievalConfigMode.java index 515b5ff89af..5d52901d9e8 100644 --- a/src/main/java/com/google/genai/types/DynamicRetrievalConfigMode.java +++ b/src/main/java/com/google/genai/types/DynamicRetrievalConfigMode.java @@ -23,7 +23,7 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** Config for the dynamic retrieval config mode. */ +/** The mode of the predictor to be used in dynamic retrieval. */ public class DynamicRetrievalConfigMode { /** Enum representing the known values for DynamicRetrievalConfigMode. */ diff --git a/src/main/java/com/google/genai/types/FunctionCallingConfig.java b/src/main/java/com/google/genai/types/FunctionCallingConfig.java index 727a94a222b..f5b59242c95 100644 --- a/src/main/java/com/google/genai/types/FunctionCallingConfig.java +++ b/src/main/java/com/google/genai/types/FunctionCallingConfig.java @@ -32,10 +32,6 @@ @AutoValue @JsonDeserialize(builder = FunctionCallingConfig.Builder.class) public abstract class FunctionCallingConfig extends JsonSerializable { - /** Optional. Function calling mode. */ - @JsonProperty("mode") - public abstract Optional mode(); - /** * Optional. Function names to call. Only set when the Mode is ANY. Function names should match * [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the @@ -44,6 +40,10 @@ public abstract class FunctionCallingConfig extends JsonSerializable { @JsonProperty("allowedFunctionNames") public abstract Optional> allowedFunctionNames(); + /** Optional. Function calling mode. */ + @JsonProperty("mode") + public abstract Optional mode(); + /** * Optional. When set to true, arguments of a single function call will be streamed out in * multiple parts/contents/responses. Partial parameter results will be returned in the @@ -70,6 +70,38 @@ private static Builder create() { return new AutoValue_FunctionCallingConfig.Builder(); } + /** + * Setter for allowedFunctionNames. + * + *

allowedFunctionNames: Optional. Function names to call. Only set when the Mode is ANY. + * Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will + * predict a function call from the set of function names provided. + */ + @JsonProperty("allowedFunctionNames") + public abstract Builder allowedFunctionNames(List allowedFunctionNames); + + /** + * Setter for allowedFunctionNames. + * + *

allowedFunctionNames: Optional. Function names to call. Only set when the Mode is ANY. + * Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will + * predict a function call from the set of function names provided. + */ + @CanIgnoreReturnValue + public Builder allowedFunctionNames(String... allowedFunctionNames) { + return allowedFunctionNames(Arrays.asList(allowedFunctionNames)); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder allowedFunctionNames(Optional> allowedFunctionNames); + + /** Clears the value of allowedFunctionNames field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAllowedFunctionNames() { + return allowedFunctionNames(Optional.empty()); + } + /** * Setter for mode. * @@ -108,38 +140,6 @@ public Builder mode(String mode) { return mode(new FunctionCallingConfigMode(mode)); } - /** - * Setter for allowedFunctionNames. - * - *

allowedFunctionNames: Optional. Function names to call. Only set when the Mode is ANY. - * Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will - * predict a function call from the set of function names provided. - */ - @JsonProperty("allowedFunctionNames") - public abstract Builder allowedFunctionNames(List allowedFunctionNames); - - /** - * Setter for allowedFunctionNames. - * - *

allowedFunctionNames: Optional. Function names to call. Only set when the Mode is ANY. - * Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will - * predict a function call from the set of function names provided. - */ - @CanIgnoreReturnValue - public Builder allowedFunctionNames(String... allowedFunctionNames) { - return allowedFunctionNames(Arrays.asList(allowedFunctionNames)); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder allowedFunctionNames(Optional> allowedFunctionNames); - - /** Clears the value of allowedFunctionNames field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearAllowedFunctionNames() { - return allowedFunctionNames(Optional.empty()); - } - /** * Setter for streamFunctionCallArguments. * diff --git a/src/main/java/com/google/genai/types/FunctionCallingConfigMode.java b/src/main/java/com/google/genai/types/FunctionCallingConfigMode.java index 8c86c3c3cfa..f3ce4c61ed2 100644 --- a/src/main/java/com/google/genai/types/FunctionCallingConfigMode.java +++ b/src/main/java/com/google/genai/types/FunctionCallingConfigMode.java @@ -23,12 +23,12 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** Config for the function calling config mode. */ +/** Function calling mode. */ public class FunctionCallingConfigMode { /** Enum representing the known values for FunctionCallingConfigMode. */ public enum Known { - /** The function calling config mode is unspecified. Should not be used. */ + /** Unspecified function calling mode. This value should not be used. */ MODE_UNSPECIFIED, /** @@ -51,10 +51,10 @@ public enum Known { NONE, /** - * Model decides to predict either a function call or a natural language response, but will - * validate function calls with constrained decoding. If "allowed_function_names" are set, the - * predicted function call will be limited to any one of "allowed_function_names", else the - * predicted function call will be any one of the provided "function_declarations". + * Model is constrained to predict either function calls or natural language response. If + * "allowed_function_names" are set, the predicted function calls will be limited to any one of + * "allowed_function_names", else the predicted function calls will be any one of the provided + * "function_declarations". */ VALIDATED, diff --git a/src/main/java/com/google/genai/types/FunctionDeclaration.java b/src/main/java/com/google/genai/types/FunctionDeclaration.java index 28f91dad68d..02a4ad7a766 100644 --- a/src/main/java/com/google/genai/types/FunctionDeclaration.java +++ b/src/main/java/com/google/genai/types/FunctionDeclaration.java @@ -36,17 +36,15 @@ import java.util.Optional; /** - * Defines a function that the model can generate JSON inputs for. - * - *

The inputs are based on `OpenAPI 3.0 specifications `_. + * Structured representation of a function declaration as defined by the [OpenAPI 3.0 + * specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the + * function name, description, parameters and response type. This FunctionDeclaration is a + * representation of a block of code that can be used as a `Tool` by the model and executed by the + * client. */ @AutoValue @JsonDeserialize(builder = FunctionDeclaration.Builder.class) public abstract class FunctionDeclaration extends JsonSerializable { - /** Defines the function behavior. */ - @JsonProperty("behavior") - public abstract Optional behavior(); - /** * Optional. Description and purpose of the function. Model uses it to decide how and whether to * call the function. @@ -98,6 +96,13 @@ public abstract class FunctionDeclaration extends JsonSerializable { @JsonProperty("responseJsonSchema") public abstract Optional responseJsonSchema(); + /** + * Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent + * method. This field is not supported in Vertex AI. + */ + @JsonProperty("behavior") + public abstract Optional behavior(); + /** Instantiates a builder for FunctionDeclaration. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -116,44 +121,6 @@ private static Builder create() { return new AutoValue_FunctionDeclaration.Builder(); } - /** - * Setter for behavior. - * - *

behavior: Defines the function behavior. - */ - @JsonProperty("behavior") - public abstract Builder behavior(Behavior behavior); - - @ExcludeFromGeneratedCoverageReport - abstract Builder behavior(Optional behavior); - - /** Clears the value of behavior field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearBehavior() { - return behavior(Optional.empty()); - } - - /** - * Setter for behavior given a known enum. - * - *

behavior: Defines the function behavior. - */ - @CanIgnoreReturnValue - public Builder behavior(Behavior.Known knownType) { - return behavior(new Behavior(knownType)); - } - - /** - * Setter for behavior given a string. - * - *

behavior: Defines the function behavior. - */ - @CanIgnoreReturnValue - public Builder behavior(String behavior) { - return behavior(new Behavior(behavior)); - } - /** * Setter for description. * @@ -307,6 +274,47 @@ public Builder clearResponseJsonSchema() { return responseJsonSchema(Optional.empty()); } + /** + * Setter for behavior. + * + *

behavior: Optional. Specifies the function Behavior. Currently only supported by the + * BidiGenerateContent method. This field is not supported in Vertex AI. + */ + @JsonProperty("behavior") + public abstract Builder behavior(Behavior behavior); + + @ExcludeFromGeneratedCoverageReport + abstract Builder behavior(Optional behavior); + + /** Clears the value of behavior field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearBehavior() { + return behavior(Optional.empty()); + } + + /** + * Setter for behavior given a known enum. + * + *

behavior: Optional. Specifies the function Behavior. Currently only supported by the + * BidiGenerateContent method. This field is not supported in Vertex AI. + */ + @CanIgnoreReturnValue + public Builder behavior(Behavior.Known knownType) { + return behavior(new Behavior(knownType)); + } + + /** + * Setter for behavior given a string. + * + *

behavior: Optional. Specifies the function Behavior. Currently only supported by the + * BidiGenerateContent method. This field is not supported in Vertex AI. + */ + @CanIgnoreReturnValue + public Builder behavior(String behavior) { + return behavior(new Behavior(behavior)); + } + public abstract FunctionDeclaration build(); } diff --git a/src/main/java/com/google/genai/types/Mode.java b/src/main/java/com/google/genai/types/Mode.java deleted file mode 100644 index 8ef57cf582a..00000000000 --- a/src/main/java/com/google/genai/types/Mode.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Auto-generated code. Do not edit. - -package com.google.genai.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import com.google.common.base.Ascii; -import java.util.Objects; - -/** The mode of the predictor to be used in dynamic retrieval. */ -public class Mode { - - /** Enum representing the known values for Mode. */ - public enum Known { - /** Always trigger retrieval. */ - MODE_UNSPECIFIED, - - /** Run retrieval only when system decides it is necessary. */ - MODE_DYNAMIC - } - - private Known modeEnum; - private final String value; - - @JsonCreator - public Mode(String value) { - this.value = value; - for (Known modeEnum : Known.values()) { - if (Ascii.equalsIgnoreCase(modeEnum.toString(), value)) { - this.modeEnum = modeEnum; - break; - } - } - if (this.modeEnum == null) { - this.modeEnum = Known.MODE_UNSPECIFIED; - } - } - - public Mode(Known knownValue) { - this.modeEnum = knownValue; - this.value = knownValue.toString(); - } - - @ExcludeFromGeneratedCoverageReport - @Override - @JsonValue - public String toString() { - return this.value; - } - - @ExcludeFromGeneratedCoverageReport - @SuppressWarnings("PatternMatchingInstanceof") - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null) { - return false; - } - - if (!(o instanceof Mode)) { - return false; - } - - Mode other = (Mode) o; - - if (this.modeEnum != Known.MODE_UNSPECIFIED && other.modeEnum != Known.MODE_UNSPECIFIED) { - return this.modeEnum == other.modeEnum; - } else if (this.modeEnum == Known.MODE_UNSPECIFIED - && other.modeEnum == Known.MODE_UNSPECIFIED) { - return this.value.equals(other.value); - } - return false; - } - - @ExcludeFromGeneratedCoverageReport - @Override - public int hashCode() { - if (this.modeEnum != Known.MODE_UNSPECIFIED) { - return this.modeEnum.hashCode(); - } else { - return Objects.hashCode(this.value); - } - } - - @ExcludeFromGeneratedCoverageReport - public Known knownEnum() { - return this.modeEnum; - } -} diff --git a/src/main/java/com/google/genai/types/Tool.java b/src/main/java/com/google/genai/types/Tool.java index 5c7c7b8a71b..82e438cba86 100644 --- a/src/main/java/com/google/genai/types/Tool.java +++ b/src/main/java/com/google/genai/types/Tool.java @@ -36,10 +36,6 @@ @AutoValue @JsonDeserialize(builder = Tool.Builder.class) public abstract class Tool extends JsonSerializable { - /** List of function declarations that the tool supports. */ - @JsonProperty("functionDeclarations") - public abstract Optional> functionDeclarations(); - /** * Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get * external knowledge to answer the prompt. Retrieval results are presented to the model for @@ -48,10 +44,6 @@ public abstract class Tool extends JsonSerializable { @JsonProperty("retrieval") public abstract Optional retrieval(); - /** Optional. Specialized retrieval tool that is powered by Google Search. */ - @JsonProperty("googleSearchRetrieval") - public abstract Optional googleSearchRetrieval(); - /** * The java.lang.reflect.Method instance. If provided, it will to be parsed into a list of * FunctionDeclaration instances, and be assigned to the functionDeclarations field. @@ -81,6 +73,16 @@ public abstract class Tool extends JsonSerializable { @JsonProperty("enterpriseWebSearch") public abstract Optional enterpriseWebSearch(); + /** + * Optional. Function tool type. One or more function declarations to be passed to the model along + * with the current user query. Model may decide to call a subset of these functions by populating + * FunctionCall in the response. User should provide a FunctionResponse for each function call in + * the next turn. Based on the function responses, Model will generate the final response back to + * the user. Maximum 512 function declarations can be provided. + */ + @JsonProperty("functionDeclarations") + public abstract Optional> functionDeclarations(); + /** Optional. GoogleMaps tool type. Tool to support Google Maps in Model. */ @JsonProperty("googleMaps") public abstract Optional googleMaps(); @@ -91,6 +93,10 @@ public abstract class Tool extends JsonSerializable { @JsonProperty("googleSearch") public abstract Optional googleSearch(); + /** Optional. Specialized retrieval tool that is powered by Google Search. */ + @JsonProperty("googleSearchRetrieval") + public abstract Optional googleSearchRetrieval(); + /** Optional. Tool to support URL context retrieval. */ @JsonProperty("urlContext") public abstract Optional urlContext(); @@ -113,48 +119,6 @@ private static Builder create() { return new AutoValue_Tool.Builder(); } - /** - * Setter for functionDeclarations. - * - *

functionDeclarations: List of function declarations that the tool supports. - */ - @JsonProperty("functionDeclarations") - public abstract Builder functionDeclarations(List functionDeclarations); - - /** - * Setter for functionDeclarations. - * - *

functionDeclarations: List of function declarations that the tool supports. - */ - @CanIgnoreReturnValue - public Builder functionDeclarations(FunctionDeclaration... functionDeclarations) { - return functionDeclarations(Arrays.asList(functionDeclarations)); - } - - /** - * Setter for functionDeclarations builder. - * - *

functionDeclarations: List of function declarations that the tool supports. - */ - @CanIgnoreReturnValue - public Builder functionDeclarations( - FunctionDeclaration.Builder... functionDeclarationsBuilders) { - return functionDeclarations( - Arrays.asList(functionDeclarationsBuilders).stream() - .map(FunctionDeclaration.Builder::build) - .collect(toImmutableList())); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder functionDeclarations(Optional> functionDeclarations); - - /** Clears the value of functionDeclarations field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearFunctionDeclarations() { - return functionDeclarations(Optional.empty()); - } - /** * Setter for retrieval. * @@ -187,37 +151,6 @@ public Builder clearRetrieval() { return retrieval(Optional.empty()); } - /** - * Setter for googleSearchRetrieval. - * - *

googleSearchRetrieval: Optional. Specialized retrieval tool that is powered by Google - * Search. - */ - @JsonProperty("googleSearchRetrieval") - public abstract Builder googleSearchRetrieval(GoogleSearchRetrieval googleSearchRetrieval); - - /** - * Setter for googleSearchRetrieval builder. - * - *

googleSearchRetrieval: Optional. Specialized retrieval tool that is powered by Google - * Search. - */ - @CanIgnoreReturnValue - public Builder googleSearchRetrieval( - GoogleSearchRetrieval.Builder googleSearchRetrievalBuilder) { - return googleSearchRetrieval(googleSearchRetrievalBuilder.build()); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder googleSearchRetrieval(Optional googleSearchRetrieval); - - /** Clears the value of googleSearchRetrieval field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearGoogleSearchRetrieval() { - return googleSearchRetrieval(Optional.empty()); - } - /** * Setter for functions. * @@ -366,6 +299,63 @@ public Builder clearEnterpriseWebSearch() { return enterpriseWebSearch(Optional.empty()); } + /** + * Setter for functionDeclarations. + * + *

functionDeclarations: Optional. Function tool type. One or more function declarations to + * be passed to the model along with the current user query. Model may decide to call a subset + * of these functions by populating FunctionCall in the response. User should provide a + * FunctionResponse for each function call in the next turn. Based on the function responses, + * Model will generate the final response back to the user. Maximum 512 function declarations + * can be provided. + */ + @JsonProperty("functionDeclarations") + public abstract Builder functionDeclarations(List functionDeclarations); + + /** + * Setter for functionDeclarations. + * + *

functionDeclarations: Optional. Function tool type. One or more function declarations to + * be passed to the model along with the current user query. Model may decide to call a subset + * of these functions by populating FunctionCall in the response. User should provide a + * FunctionResponse for each function call in the next turn. Based on the function responses, + * Model will generate the final response back to the user. Maximum 512 function declarations + * can be provided. + */ + @CanIgnoreReturnValue + public Builder functionDeclarations(FunctionDeclaration... functionDeclarations) { + return functionDeclarations(Arrays.asList(functionDeclarations)); + } + + /** + * Setter for functionDeclarations builder. + * + *

functionDeclarations: Optional. Function tool type. One or more function declarations to + * be passed to the model along with the current user query. Model may decide to call a subset + * of these functions by populating FunctionCall in the response. User should provide a + * FunctionResponse for each function call in the next turn. Based on the function responses, + * Model will generate the final response back to the user. Maximum 512 function declarations + * can be provided. + */ + @CanIgnoreReturnValue + public Builder functionDeclarations( + FunctionDeclaration.Builder... functionDeclarationsBuilders) { + return functionDeclarations( + Arrays.asList(functionDeclarationsBuilders).stream() + .map(FunctionDeclaration.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder functionDeclarations(Optional> functionDeclarations); + + /** Clears the value of functionDeclarations field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearFunctionDeclarations() { + return functionDeclarations(Optional.empty()); + } + /** * Setter for googleMaps. * @@ -424,6 +414,37 @@ public Builder clearGoogleSearch() { return googleSearch(Optional.empty()); } + /** + * Setter for googleSearchRetrieval. + * + *

googleSearchRetrieval: Optional. Specialized retrieval tool that is powered by Google + * Search. + */ + @JsonProperty("googleSearchRetrieval") + public abstract Builder googleSearchRetrieval(GoogleSearchRetrieval googleSearchRetrieval); + + /** + * Setter for googleSearchRetrieval builder. + * + *

googleSearchRetrieval: Optional. Specialized retrieval tool that is powered by Google + * Search. + */ + @CanIgnoreReturnValue + public Builder googleSearchRetrieval( + GoogleSearchRetrieval.Builder googleSearchRetrievalBuilder) { + return googleSearchRetrieval(googleSearchRetrievalBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder googleSearchRetrieval(Optional googleSearchRetrieval); + + /** Clears the value of googleSearchRetrieval field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearGoogleSearchRetrieval() { + return googleSearchRetrieval(Optional.empty()); + } + /** * Setter for urlContext. * diff --git a/src/main/java/com/google/genai/types/ToolConfig.java b/src/main/java/com/google/genai/types/ToolConfig.java index d02db644522..770f8d06ae9 100644 --- a/src/main/java/com/google/genai/types/ToolConfig.java +++ b/src/main/java/com/google/genai/types/ToolConfig.java @@ -34,14 +34,14 @@ @AutoValue @JsonDeserialize(builder = ToolConfig.Builder.class) public abstract class ToolConfig extends JsonSerializable { - /** Optional. Function calling config. */ - @JsonProperty("functionCallingConfig") - public abstract Optional functionCallingConfig(); - /** Optional. Retrieval config. */ @JsonProperty("retrievalConfig") public abstract Optional retrievalConfig(); + /** Optional. Function calling config. */ + @JsonProperty("functionCallingConfig") + public abstract Optional functionCallingConfig(); + /** Instantiates a builder for ToolConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -61,60 +61,60 @@ private static Builder create() { } /** - * Setter for functionCallingConfig. + * Setter for retrievalConfig. * - *

functionCallingConfig: Optional. Function calling config. + *

retrievalConfig: Optional. Retrieval config. */ - @JsonProperty("functionCallingConfig") - public abstract Builder functionCallingConfig(FunctionCallingConfig functionCallingConfig); + @JsonProperty("retrievalConfig") + public abstract Builder retrievalConfig(RetrievalConfig retrievalConfig); /** - * Setter for functionCallingConfig builder. + * Setter for retrievalConfig builder. * - *

functionCallingConfig: Optional. Function calling config. + *

retrievalConfig: Optional. Retrieval config. */ @CanIgnoreReturnValue - public Builder functionCallingConfig( - FunctionCallingConfig.Builder functionCallingConfigBuilder) { - return functionCallingConfig(functionCallingConfigBuilder.build()); + public Builder retrievalConfig(RetrievalConfig.Builder retrievalConfigBuilder) { + return retrievalConfig(retrievalConfigBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder functionCallingConfig(Optional functionCallingConfig); + abstract Builder retrievalConfig(Optional retrievalConfig); - /** Clears the value of functionCallingConfig field. */ + /** Clears the value of retrievalConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearFunctionCallingConfig() { - return functionCallingConfig(Optional.empty()); + public Builder clearRetrievalConfig() { + return retrievalConfig(Optional.empty()); } /** - * Setter for retrievalConfig. + * Setter for functionCallingConfig. * - *

retrievalConfig: Optional. Retrieval config. + *

functionCallingConfig: Optional. Function calling config. */ - @JsonProperty("retrievalConfig") - public abstract Builder retrievalConfig(RetrievalConfig retrievalConfig); + @JsonProperty("functionCallingConfig") + public abstract Builder functionCallingConfig(FunctionCallingConfig functionCallingConfig); /** - * Setter for retrievalConfig builder. + * Setter for functionCallingConfig builder. * - *

retrievalConfig: Optional. Retrieval config. + *

functionCallingConfig: Optional. Function calling config. */ @CanIgnoreReturnValue - public Builder retrievalConfig(RetrievalConfig.Builder retrievalConfigBuilder) { - return retrievalConfig(retrievalConfigBuilder.build()); + public Builder functionCallingConfig( + FunctionCallingConfig.Builder functionCallingConfigBuilder) { + return functionCallingConfig(functionCallingConfigBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder retrievalConfig(Optional retrievalConfig); + abstract Builder functionCallingConfig(Optional functionCallingConfig); - /** Clears the value of retrievalConfig field. */ + /** Clears the value of functionCallingConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearRetrievalConfig() { - return retrievalConfig(Optional.empty()); + public Builder clearFunctionCallingConfig() { + return functionCallingConfig(Optional.empty()); } public abstract ToolConfig build();