Skip to content
Open
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
206 changes: 182 additions & 24 deletions src/main/java/com/google/genai/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,46 @@ public Batches(ApiClient apiClient) {
this.apiClient = apiClient;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"apiKey"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"apiKey"},
Common.getValueByPath(fromObject, new String[] {"apiKey"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}))) {
throw new IllegalArgumentException("apiKeyConfig parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authType"}))) {
throw new IllegalArgumentException("authType parameter is not supported in Gemini API.");
}

if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}))) {
throw new IllegalArgumentException(
"googleServiceAccountConfig parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}))) {
throw new IllegalArgumentException(
"httpBasicAuthConfig parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"oauthConfig"}))) {
throw new IllegalArgumentException("oauthConfig parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"oidcConfig"}))) {
throw new IllegalArgumentException("oidcConfig parameter is not supported in Gemini API.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode batchJobDestinationFromMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -527,18 +567,18 @@ ObjectNode candidateFromMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"finishReason"}));
}

if (Common.getValueByPath(fromObject, new String[] {"avgLogprobs"}) != null) {
if (Common.getValueByPath(fromObject, new String[] {"groundingMetadata"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"avgLogprobs"},
Common.getValueByPath(fromObject, new String[] {"avgLogprobs"}));
new String[] {"groundingMetadata"},
Common.getValueByPath(fromObject, new String[] {"groundingMetadata"}));
}

if (Common.getValueByPath(fromObject, new String[] {"groundingMetadata"}) != null) {
if (Common.getValueByPath(fromObject, new String[] {"avgLogprobs"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"groundingMetadata"},
Common.getValueByPath(fromObject, new String[] {"groundingMetadata"}));
new String[] {"avgLogprobs"},
Common.getValueByPath(fromObject, new String[] {"avgLogprobs"}));
}

if (Common.getValueByPath(fromObject, new String[] {"index"}) != null) {
Expand Down Expand Up @@ -1224,8 +1264,11 @@ ObjectNode generateContentConfigToMldev(
Common.setValueByPath(
toObject,
new String[] {"speechConfig"},
Transformers.tSpeechConfig(
Common.getValueByPath(fromObject, new String[] {"speechConfig"})));
speechConfigToMldev(
JsonSerializable.toJsonNode(
Transformers.tSpeechConfig(
Common.getValueByPath(fromObject, new String[] {"speechConfig"}))),
toObject));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"audioTimestamp"}))) {
Expand Down Expand Up @@ -1339,8 +1382,14 @@ ObjectNode getBatchJobParametersToVertex(
@ExcludeFromGeneratedCoverageReport
ObjectNode googleMapsToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authConfig"}))) {
throw new IllegalArgumentException("authConfig parameter is not supported in Gemini API.");
if (Common.getValueByPath(fromObject, new String[] {"authConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"authConfig"},
authConfigToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"authConfig"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"enableWidget"}) != null) {
Expand All @@ -1356,14 +1405,14 @@ ObjectNode googleMapsToMldev(JsonNode fromObject, ObjectNode parentObject) {
@ExcludeFromGeneratedCoverageReport
ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"excludeDomains"}))) {
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
throw new IllegalArgumentException(
"excludeDomains parameter is not supported in Gemini API.");
"blockingConfidence parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"excludeDomains"}))) {
throw new IllegalArgumentException(
"blockingConfidence parameter is not supported in Gemini API.");
"excludeDomains parameter is not supported in Gemini API.");
}

if (Common.getValueByPath(fromObject, new String[] {"timeRangeFilter"}) != null) {
Expand Down Expand Up @@ -1404,6 +1453,16 @@ ObjectNode imageConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
"outputCompressionQuality parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"imageOutputOptions"}))) {
throw new IllegalArgumentException(
"imageOutputOptions parameter is not supported in Gemini API.");
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"personGeneration"}))) {
throw new IllegalArgumentException(
"personGeneration parameter is not supported in Gemini API.");
}

return toObject;
}

Expand Down Expand Up @@ -1625,6 +1684,24 @@ ObjectNode listBatchJobsResponseFromVertex(JsonNode fromObject, ObjectNode paren
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode multiSpeakerVoiceConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"}) != null) {
ArrayNode keyArray =
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(speakerVoiceConfigToMldev(JsonSerializable.toJsonNode(item), toObject));
}
Common.setValueByPath(toObject, new String[] {"speakerVoiceConfigs"}, result);
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -1714,6 +1791,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"videoMetadata"}));
}

if (Common.getValueByPath(fromObject, new String[] {"partMetadata"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"partMetadata"},
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
}

return toObject;
}

Expand Down Expand Up @@ -1741,6 +1825,62 @@ ObjectNode safetySettingToMldev(JsonNode fromObject, ObjectNode parentObject) {
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode speakerVoiceConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"speaker"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"speaker"},
Common.getValueByPath(fromObject, new String[] {"speaker"}));
}

if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"voiceConfig"},
voiceConfigToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
toObject));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode speechConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"languageCode"},
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
}

if (Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"multiSpeakerVoiceConfig"},
multiSpeakerVoiceConfigToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"voiceConfig"},
voiceConfigToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
toObject));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -1799,6 +1939,16 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"fileSearch"}));
}

if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"googleMaps"},
googleMapsToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -1811,16 +1961,6 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
"enterpriseWebSearch parameter is not supported in Gemini API.");
}

if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"googleMaps"},
googleMapsToMldev(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"googleSearch"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -1841,6 +1981,24 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode voiceConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"prebuiltVoiceConfig"},
Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"replicatedVoiceConfig"}))) {
throw new IllegalArgumentException(
"replicatedVoiceConfig parameter is not supported in Gemini API.");
}

return toObject;
}

/** A shared buildRequest method for both sync and async methods. */
BuiltRequest buildRequestForPrivateCreate(
String model, BatchJobSource src, CreateBatchJobConfig config) {
Expand Down
Loading