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
184 changes: 94 additions & 90 deletions src/main/java/com/google/genai/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -1040,44 +1040,40 @@ ObjectNode functionCallingConfigToMldev(JsonNode fromObject, ObjectNode parentOb
ObjectNode generateContentConfigToMldev(
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"}))) {
throw new IllegalArgumentException(
"modelSelectionConfig parameter is not supported in Gemini API.");
}

if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"systemInstruction"},
contentToMldev(
JsonSerializable.toJsonNode(
Transformers.tContent(
Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))),
toObject));
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"audioTimestamp"}))) {
throw new IllegalArgumentException(
"audioTimestamp parameter is not supported in Gemini API.");
}

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

if (Common.getValueByPath(fromObject, new String[] {"topP"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"topP"},
Common.getValueByPath(fromObject, new String[] {"topP"}));
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"enableAffectiveDialog"}))) {
throw new IllegalArgumentException(
"enableAffectiveDialog parameter is not supported in Gemini API.");
}

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

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

if (Common.getValueByPath(fromObject, new String[] {"maxOutputTokens"}) != null) {
Expand All @@ -1087,11 +1083,25 @@ ObjectNode generateContentConfigToMldev(
Common.getValueByPath(fromObject, new String[] {"maxOutputTokens"}));
}

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

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

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

if (Common.getValueByPath(fromObject, new String[] {"responseLogprobs"}) != null) {
Expand All @@ -1101,25 +1111,29 @@ ObjectNode generateContentConfigToMldev(
Common.getValueByPath(fromObject, new String[] {"responseLogprobs"}));
}

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

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

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

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

if (Common.getValueByPath(fromObject, new String[] {"seed"}) != null) {
Expand All @@ -1129,34 +1143,65 @@ ObjectNode generateContentConfigToMldev(
Common.getValueByPath(fromObject, new String[] {"seed"}));
}

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

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

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

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"routingConfig"}))) {
throw new IllegalArgumentException("routingConfig parameter is not supported in Gemini API.");
if (Common.getValueByPath(fromObject, new String[] {"thinkingConfig"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"thinkingConfig"},
Common.getValueByPath(fromObject, new String[] {"thinkingConfig"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"}))) {
throw new IllegalArgumentException(
"modelSelectionConfig parameter is not supported in Gemini API.");
if (Common.getValueByPath(fromObject, new String[] {"topK"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"topK"},
Common.getValueByPath(fromObject, new String[] {"topK"}));
}

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

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

if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"systemInstruction"},
contentToMldev(
JsonSerializable.toJsonNode(
Transformers.tContent(
Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"safetySettings"}) != null) {
Expand Down Expand Up @@ -1206,40 +1251,6 @@ ObjectNode generateContentConfigToMldev(
this.apiClient, Common.getValueByPath(fromObject, new String[] {"cachedContent"})));
}

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

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

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

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

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

if (Common.getValueByPath(fromObject, new String[] {"imageConfig"}) != null) {
Common.setValueByPath(
toObject,
Expand All @@ -1250,13 +1261,6 @@ ObjectNode generateContentConfigToMldev(
toObject));
}

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

return toObject;
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,6 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject
Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"}));
}

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

if (Common.getValueByPath(fromObject, new String[] {"audioTimestamp"}) != null) {
Common.setValueByPath(
toObject,
Expand Down Expand Up @@ -261,6 +254,13 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject
Common.getValueByPath(fromObject, new String[] {"presencePenalty"}));
}

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

if (Common.getValueByPath(fromObject, new String[] {"responseLogprobs"}) != null) {
Common.setValueByPath(
toObject,
Expand Down
Loading