Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions src/main/java/com/google/genai/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
100 changes: 50 additions & 50 deletions src/main/java/com/google/genai/Caches.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -878,32 +878,13 @@ 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,
new String[] {"retrieval"},
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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading
Loading