From a561a1bcaef74f68ed3d3d9edae3bf2d114370d9 Mon Sep 17 00:00:00 2001 From: Jaycee Li Date: Wed, 26 Nov 2025 11:57:20 -0800 Subject: [PATCH] chore: Refactor GenerateContentConfig to inherit from GenerationConfig feat: Add enableAffectiveDialog field in the GenerateContentConfig PiperOrigin-RevId: 837208137 --- src/main/java/com/google/genai/Batches.java | 184 +-- .../java/com/google/genai/LiveConverters.java | 14 +- src/main/java/com/google/genai/Models.java | 376 +++--- .../genai/types/GenerateContentConfig.java | 1006 ++++++++--------- .../google/genai/types/GenerationConfig.java | 71 +- .../google/genai/types/MediaResolution.java | 4 +- 6 files changed, 834 insertions(+), 821 deletions(-) diff --git a/src/main/java/com/google/genai/Batches.java b/src/main/java/com/google/genai/Batches.java index 192faa17f65..d5917d37646 100644 --- a/src/main/java/com/google/genai/Batches.java +++ b/src/main/java/com/google/genai/Batches.java @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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, @@ -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; } diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index 9e31bb32129..5e5ad7901c1 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -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, @@ -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, diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java index 156c48e8891..83ee2a6b082 100644 --- a/src/main/java/com/google/genai/Models.java +++ b/src/main/java/com/google/genai/Models.java @@ -1162,44 +1162,40 @@ ObjectNode functionDeclarationToVertex(JsonNode fromObject, ObjectNode parentObj 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) { @@ -1209,11 +1205,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) { @@ -1223,25 +1233,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) { @@ -1251,34 +1265,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) { @@ -1328,40 +1373,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, @@ -1372,13 +1383,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; } @@ -1386,41 +1390,46 @@ ObjectNode generateContentConfigToMldev( ObjectNode generateContentConfigToVertex( ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); + if (Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"modelConfig"}, + Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"})); + } - if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"audioTimestamp"}) != null) { Common.setValueByPath( - parentObject, - new String[] {"systemInstruction"}, - Transformers.tContent( - Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))); + toObject, + new String[] {"audioTimestamp"}, + Common.getValueByPath(fromObject, new String[] {"audioTimestamp"})); } - 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) { + if (Common.getValueByPath(fromObject, new String[] {"enableAffectiveDialog"}) != null) { Common.setValueByPath( toObject, - new String[] {"topP"}, - Common.getValueByPath(fromObject, new String[] {"topP"})); + new String[] {"enableAffectiveDialog"}, + Common.getValueByPath(fromObject, new String[] {"enableAffectiveDialog"})); } - 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) { @@ -1430,11 +1439,25 @@ ObjectNode generateContentConfigToVertex( 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) { @@ -1444,25 +1467,32 @@ ObjectNode generateContentConfigToVertex( 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.getValueByPath(fromObject, new String[] {"routingConfig"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"routingConfig"}, + Common.getValueByPath(fromObject, new String[] {"routingConfig"})); } if (Common.getValueByPath(fromObject, new String[] {"seed"}) != null) { @@ -1472,39 +1502,61 @@ ObjectNode generateContentConfigToVertex( 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.getValueByPath(fromObject, new String[] {"routingConfig"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"thinkingConfig"}) != null) { Common.setValueByPath( toObject, - new String[] {"routingConfig"}, - Common.getValueByPath(fromObject, new String[] {"routingConfig"})); + new String[] {"thinkingConfig"}, + Common.getValueByPath(fromObject, new String[] {"thinkingConfig"})); } - if (Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"}) != null) { + if (Common.getValueByPath(fromObject, new String[] {"topK"}) != null) { Common.setValueByPath( toObject, - new String[] {"modelConfig"}, - Common.getValueByPath(fromObject, new String[] {"modelSelectionConfig"})); + 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.isZero( + Common.getValueByPath(fromObject, new String[] {"enableEnhancedCivicAnswers"}))) { + throw new IllegalArgumentException( + "enableEnhancedCivicAnswers parameter is not supported in Vertex AI."); + } + + if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"systemInstruction"}, + Transformers.tContent( + Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))); } if (Common.getValueByPath(fromObject, new String[] {"safetySettings"}) != null) { @@ -1549,42 +1601,6 @@ ObjectNode generateContentConfigToVertex( 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.getValueByPath(fromObject, new String[] {"audioTimestamp"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"audioTimestamp"}, - Common.getValueByPath(fromObject, new String[] {"audioTimestamp"})); - } - - 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, @@ -1595,12 +1611,6 @@ ObjectNode generateContentConfigToVertex( toObject)); } - if (!Common.isZero( - Common.getValueByPath(fromObject, new String[] {"enableEnhancedCivicAnswers"}))) { - throw new IllegalArgumentException( - "enableEnhancedCivicAnswers parameter is not supported in Vertex AI."); - } - return toObject; } @@ -2868,13 +2878,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, @@ -2931,6 +2934,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, diff --git a/src/main/java/com/google/genai/types/GenerateContentConfig.java b/src/main/java/com/google/genai/types/GenerateContentConfig.java index e22cf8b4c29..e904de38821 100644 --- a/src/main/java/com/google/genai/types/GenerateContentConfig.java +++ b/src/main/java/com/google/genai/types/GenerateContentConfig.java @@ -40,113 +40,47 @@ @AutoValue @JsonDeserialize(builder = GenerateContentConfig.Builder.class) public abstract class GenerateContentConfig extends JsonSerializable { - /** Used to override HTTP request options. */ - @JsonProperty("httpOptions") - public abstract Optional httpOptions(); - - /** If true, the raw HTTP response will be returned in the 'sdk_http_response' field. */ - @JsonProperty("shouldReturnHttpResponse") - public abstract Optional shouldReturnHttpResponse(); - - /** - * Instructions for the model to steer it toward better performance. For example, "Answer as - * concisely as possible" or "Don't use technical terms in your response". - */ - @JsonProperty("systemInstruction") - public abstract Optional systemInstruction(); - - /** - * Value that controls the degree of randomness in token selection. Lower temperatures are good - * for prompts that require a less open-ended or creative response, while higher temperatures can - * lead to more diverse or creative results. - */ - @JsonProperty("temperature") - public abstract Optional temperature(); - - /** - * Tokens are selected from the most to least probable until the sum of their probabilities equals - * this value. Use a lower value for less random responses and a higher value for more random - * responses. - */ - @JsonProperty("topP") - public abstract Optional topP(); + /** Optional. Config for model selection. */ + @JsonProperty("modelSelectionConfig") + public abstract Optional modelSelectionConfig(); /** - * For each token selection step, the ``top_k`` tokens with the highest probabilities are sampled. - * Then tokens are further filtered based on ``top_p`` with the final token selected using - * temperature sampling. Use a lower number for less random responses and a higher number for more - * random responses. + * Optional. If enabled, audio timestamp will be included in the request to the model. This field + * is not supported in Gemini API. */ - @JsonProperty("topK") - public abstract Optional topK(); + @JsonProperty("audioTimestamp") + public abstract Optional audioTimestamp(); - /** Number of response variations to return. */ + /** Optional. Number of candidates to generate. */ @JsonProperty("candidateCount") public abstract Optional candidateCount(); - /** Maximum number of tokens that can be generated in the response. */ - @JsonProperty("maxOutputTokens") - public abstract Optional maxOutputTokens(); - /** - * List of strings that tells the model to stop generating text if one of the strings is - * encountered in the response. + * Optional. If enabled, the model will detect emotions and adapt its responses accordingly. This + * field is not supported in Gemini API. */ - @JsonProperty("stopSequences") - public abstract Optional> stopSequences(); + @JsonProperty("enableAffectiveDialog") + public abstract Optional enableAffectiveDialog(); - /** - * Whether to return the log probabilities of the tokens that were chosen by the model at each - * step. - */ - @JsonProperty("responseLogprobs") - public abstract Optional responseLogprobs(); + /** Optional. Frequency penalties. */ + @JsonProperty("frequencyPenalty") + public abstract Optional frequencyPenalty(); - /** Number of top candidate tokens to return the log probabilities for at each generation step. */ + /** Optional. Logit probabilities. */ @JsonProperty("logprobs") public abstract Optional logprobs(); - /** - * Positive values penalize tokens that already appear in the generated text, increasing the - * probability of generating more diverse content. - */ - @JsonProperty("presencePenalty") - public abstract Optional presencePenalty(); - - /** - * Positive values penalize tokens that repeatedly appear in the generated text, increasing the - * probability of generating more diverse content. - */ - @JsonProperty("frequencyPenalty") - public abstract Optional frequencyPenalty(); - - /** - * When ``seed`` is fixed to a specific number, the model makes a best effort to provide the same - * response for repeated requests. By default, a random number is used. - */ - @JsonProperty("seed") - public abstract Optional seed(); + /** Optional. The maximum number of output tokens to generate per message. */ + @JsonProperty("maxOutputTokens") + public abstract Optional maxOutputTokens(); - /** - * Output response mimetype of the generated candidate text. Supported mimetype: - `text/plain`: - * (default) Text output. - `application/json`: JSON response in the candidates. The model needs - * to be prompted to output the appropriate response type, otherwise the behavior is undefined. - * This is a preview feature. - */ - @JsonProperty("responseMimeType") - public abstract Optional responseMimeType(); + /** Optional. If specified, the media resolution specified will be used. */ + @JsonProperty("mediaResolution") + public abstract Optional mediaResolution(); - /** - * The `Schema` object allows the definition of input and output data types. These types can be - * objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema - * object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type - * must also be set. Compatible mimetypes: `application/json`: Schema for JSON response. - * - *

If `response_schema` doesn't process your schema correctly, try using `response_json_schema` - * instead. - */ - @JsonProperty("responseSchema") - public abstract Optional responseSchema(); + /** Optional. Positive penalties. */ + @JsonProperty("presencePenalty") + public abstract Optional presencePenalty(); /** * Optional. Output schema of the generated response. This is an alternative to `response_schema` @@ -164,13 +98,89 @@ public abstract class GenerateContentConfig extends JsonSerializable { @JsonProperty("responseJsonSchema") public abstract Optional responseJsonSchema(); - /** Configuration for model router requests. */ + /** Optional. If true, export the logprobs results in response. */ + @JsonProperty("responseLogprobs") + public abstract Optional responseLogprobs(); + + /** + * Optional. Output response mimetype of the generated candidate text. Supported mimetype: - + * `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. The + * model needs to be prompted to output the appropriate response type, otherwise the behavior is + * undefined. This is a preview feature. + */ + @JsonProperty("responseMimeType") + public abstract Optional responseMimeType(); + + /** Optional. The modalities of the response. */ + @JsonProperty("responseModalities") + public abstract Optional> responseModalities(); + + /** + * Optional. The `Schema` object allows the definition of input and output data types. These types + * can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 + * schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible + * response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON + * response. + */ + @JsonProperty("responseSchema") + public abstract Optional responseSchema(); + + /** Optional. Routing configuration. This field is not supported in Gemini API. */ @JsonProperty("routingConfig") public abstract Optional routingConfig(); - /** Configuration for model selection. */ - @JsonProperty("modelSelectionConfig") - public abstract Optional modelSelectionConfig(); + /** Optional. Seed. */ + @JsonProperty("seed") + public abstract Optional seed(); + + /** Optional. The speech generation config. */ + @JsonProperty("speechConfig") + public abstract Optional speechConfig(); + + /** Optional. Stop sequences. */ + @JsonProperty("stopSequences") + public abstract Optional> stopSequences(); + + /** Optional. Controls the randomness of predictions. */ + @JsonProperty("temperature") + public abstract Optional temperature(); + + /** + * Optional. Config for thinking features. An error will be returned if this field is set for + * models that don't support thinking. + */ + @JsonProperty("thinkingConfig") + public abstract Optional thinkingConfig(); + + /** Optional. If specified, top-k sampling will be used. */ + @JsonProperty("topK") + public abstract Optional topK(); + + /** Optional. If specified, nucleus sampling will be used. */ + @JsonProperty("topP") + public abstract Optional topP(); + + /** + * Optional. Enables enhanced civic answers. It may not be available for all models. This field is + * not supported in Vertex AI. + */ + @JsonProperty("enableEnhancedCivicAnswers") + public abstract Optional enableEnhancedCivicAnswers(); + + /** Used to override HTTP request options. */ + @JsonProperty("httpOptions") + public abstract Optional httpOptions(); + + /** If true, the raw HTTP response will be returned in the 'sdk_http_response' field. */ + @JsonProperty("shouldReturnHttpResponse") + public abstract Optional shouldReturnHttpResponse(); + + /** + * Instructions for the model to steer it toward better performance. For example, "Answer as + * concisely as possible" or "Don't use technical terms in your response". + */ + @JsonProperty("systemInstruction") + public abstract Optional systemInstruction(); /** Safety settings in the request to block unsafe content in the response. */ @JsonProperty("safetySettings") @@ -195,43 +205,13 @@ public abstract class GenerateContentConfig extends JsonSerializable { @JsonProperty("cachedContent") public abstract Optional cachedContent(); - /** - * The requested modalities of the response. Represents the set of modalities that the model can - * return. - */ - @JsonProperty("responseModalities") - public abstract Optional> responseModalities(); - - /** If specified, the media resolution specified will be used. */ - @JsonProperty("mediaResolution") - public abstract Optional mediaResolution(); - - /** The speech generation configuration. */ - @JsonProperty("speechConfig") - public abstract Optional speechConfig(); - - /** If enabled, audio timestamp will be included in the request to the model. */ - @JsonProperty("audioTimestamp") - public abstract Optional audioTimestamp(); - - /** The configuration for automatic function calling. */ - @JsonProperty("automaticFunctionCalling") - public abstract Optional automaticFunctionCalling(); - - /** The thinking features configuration. */ - @JsonProperty("thinkingConfig") - public abstract Optional thinkingConfig(); - /** The image generation configuration. */ @JsonProperty("imageConfig") public abstract Optional imageConfig(); - /** - * Enables enhanced civic answers. It may not be available for all models. This field is not - * supported in Vertex AI. - */ - @JsonProperty("enableEnhancedCivicAnswers") - public abstract Optional enableEnhancedCivicAnswers(); + /** The configuration for automatic function calling. */ + @JsonProperty("automaticFunctionCalling") + public abstract Optional automaticFunctionCalling(); /** Instantiates a builder for GenerateContentConfig. */ @ExcludeFromGeneratedCoverageReport @@ -252,214 +232,232 @@ private static Builder create() { } /** - * Setter for httpOptions. + * Setter for modelSelectionConfig. * - *

httpOptions: Used to override HTTP request options. + *

modelSelectionConfig: Optional. Config for model selection. */ - @JsonProperty("httpOptions") - public abstract Builder httpOptions(HttpOptions httpOptions); + @JsonProperty("modelSelectionConfig") + public abstract Builder modelSelectionConfig(ModelSelectionConfig modelSelectionConfig); /** - * Setter for httpOptions builder. + * Setter for modelSelectionConfig builder. * - *

httpOptions: Used to override HTTP request options. + *

modelSelectionConfig: Optional. Config for model selection. */ @CanIgnoreReturnValue - public Builder httpOptions(HttpOptions.Builder httpOptionsBuilder) { - return httpOptions(httpOptionsBuilder.build()); + public Builder modelSelectionConfig(ModelSelectionConfig.Builder modelSelectionConfigBuilder) { + return modelSelectionConfig(modelSelectionConfigBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder httpOptions(Optional httpOptions); + abstract Builder modelSelectionConfig(Optional modelSelectionConfig); - /** Clears the value of httpOptions field. */ + /** Clears the value of modelSelectionConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearHttpOptions() { - return httpOptions(Optional.empty()); + public Builder clearModelSelectionConfig() { + return modelSelectionConfig(Optional.empty()); } /** - * Setter for shouldReturnHttpResponse. + * Setter for audioTimestamp. * - *

shouldReturnHttpResponse: If true, the raw HTTP response will be returned in the - * 'sdk_http_response' field. + *

audioTimestamp: Optional. If enabled, audio timestamp will be included in the request to + * the model. This field is not supported in Gemini API. */ - @JsonProperty("shouldReturnHttpResponse") - public abstract Builder shouldReturnHttpResponse(boolean shouldReturnHttpResponse); + @JsonProperty("audioTimestamp") + public abstract Builder audioTimestamp(boolean audioTimestamp); @ExcludeFromGeneratedCoverageReport - abstract Builder shouldReturnHttpResponse(Optional shouldReturnHttpResponse); + abstract Builder audioTimestamp(Optional audioTimestamp); - /** Clears the value of shouldReturnHttpResponse field. */ + /** Clears the value of audioTimestamp field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearShouldReturnHttpResponse() { - return shouldReturnHttpResponse(Optional.empty()); + public Builder clearAudioTimestamp() { + return audioTimestamp(Optional.empty()); } /** - * Setter for systemInstruction. - * - *

systemInstruction: Instructions for the model to steer it toward better performance. For - * example, "Answer as concisely as possible" or "Don't use technical terms in your response". - */ - @JsonProperty("systemInstruction") - public abstract Builder systemInstruction(Content systemInstruction); - - /** - * Setter for systemInstruction builder. + * Setter for candidateCount. * - *

systemInstruction: Instructions for the model to steer it toward better performance. For - * example, "Answer as concisely as possible" or "Don't use technical terms in your response". + *

candidateCount: Optional. Number of candidates to generate. */ - @CanIgnoreReturnValue - public Builder systemInstruction(Content.Builder systemInstructionBuilder) { - return systemInstruction(systemInstructionBuilder.build()); - } + @JsonProperty("candidateCount") + public abstract Builder candidateCount(Integer candidateCount); @ExcludeFromGeneratedCoverageReport - abstract Builder systemInstruction(Optional systemInstruction); + abstract Builder candidateCount(Optional candidateCount); - /** Clears the value of systemInstruction field. */ + /** Clears the value of candidateCount field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearSystemInstruction() { - return systemInstruction(Optional.empty()); + public Builder clearCandidateCount() { + return candidateCount(Optional.empty()); } /** - * Setter for temperature. + * Setter for enableAffectiveDialog. * - *

temperature: Value that controls the degree of randomness in token selection. Lower - * temperatures are good for prompts that require a less open-ended or creative response, while - * higher temperatures can lead to more diverse or creative results. + *

enableAffectiveDialog: Optional. If enabled, the model will detect emotions and adapt its + * responses accordingly. This field is not supported in Gemini API. */ - @JsonProperty("temperature") - public abstract Builder temperature(Float temperature); + @JsonProperty("enableAffectiveDialog") + public abstract Builder enableAffectiveDialog(boolean enableAffectiveDialog); @ExcludeFromGeneratedCoverageReport - abstract Builder temperature(Optional temperature); + abstract Builder enableAffectiveDialog(Optional enableAffectiveDialog); - /** Clears the value of temperature field. */ + /** Clears the value of enableAffectiveDialog field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearTemperature() { - return temperature(Optional.empty()); + public Builder clearEnableAffectiveDialog() { + return enableAffectiveDialog(Optional.empty()); } /** - * Setter for topP. + * Setter for frequencyPenalty. * - *

topP: Tokens are selected from the most to least probable until the sum of their - * probabilities equals this value. Use a lower value for less random responses and a higher - * value for more random responses. + *

frequencyPenalty: Optional. Frequency penalties. */ - @JsonProperty("topP") - public abstract Builder topP(Float topP); + @JsonProperty("frequencyPenalty") + public abstract Builder frequencyPenalty(Float frequencyPenalty); @ExcludeFromGeneratedCoverageReport - abstract Builder topP(Optional topP); + abstract Builder frequencyPenalty(Optional frequencyPenalty); - /** Clears the value of topP field. */ + /** Clears the value of frequencyPenalty field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearTopP() { - return topP(Optional.empty()); + public Builder clearFrequencyPenalty() { + return frequencyPenalty(Optional.empty()); } /** - * Setter for topK. + * Setter for logprobs. * - *

topK: For each token selection step, the ``top_k`` tokens with the highest probabilities - * are sampled. Then tokens are further filtered based on ``top_p`` with the final token - * selected using temperature sampling. Use a lower number for less random responses and a - * higher number for more random responses. + *

logprobs: Optional. Logit probabilities. */ - @JsonProperty("topK") - public abstract Builder topK(Float topK); + @JsonProperty("logprobs") + public abstract Builder logprobs(Integer logprobs); @ExcludeFromGeneratedCoverageReport - abstract Builder topK(Optional topK); + abstract Builder logprobs(Optional logprobs); - /** Clears the value of topK field. */ + /** Clears the value of logprobs field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearTopK() { - return topK(Optional.empty()); - } + public Builder clearLogprobs() { + return logprobs(Optional.empty()); + } /** - * Setter for candidateCount. + * Setter for maxOutputTokens. * - *

candidateCount: Number of response variations to return. + *

maxOutputTokens: Optional. The maximum number of output tokens to generate per message. */ - @JsonProperty("candidateCount") - public abstract Builder candidateCount(Integer candidateCount); + @JsonProperty("maxOutputTokens") + public abstract Builder maxOutputTokens(Integer maxOutputTokens); @ExcludeFromGeneratedCoverageReport - abstract Builder candidateCount(Optional candidateCount); + abstract Builder maxOutputTokens(Optional maxOutputTokens); - /** Clears the value of candidateCount field. */ + /** Clears the value of maxOutputTokens field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearCandidateCount() { - return candidateCount(Optional.empty()); + public Builder clearMaxOutputTokens() { + return maxOutputTokens(Optional.empty()); } /** - * Setter for maxOutputTokens. + * Setter for mediaResolution. * - *

maxOutputTokens: Maximum number of tokens that can be generated in the response. + *

mediaResolution: Optional. If specified, the media resolution specified will be used. */ - @JsonProperty("maxOutputTokens") - public abstract Builder maxOutputTokens(Integer maxOutputTokens); + @JsonProperty("mediaResolution") + public abstract Builder mediaResolution(MediaResolution mediaResolution); @ExcludeFromGeneratedCoverageReport - abstract Builder maxOutputTokens(Optional maxOutputTokens); + abstract Builder mediaResolution(Optional mediaResolution); - /** Clears the value of maxOutputTokens field. */ + /** Clears the value of mediaResolution field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearMaxOutputTokens() { - return maxOutputTokens(Optional.empty()); + public Builder clearMediaResolution() { + return mediaResolution(Optional.empty()); } /** - * Setter for stopSequences. + * Setter for mediaResolution given a known enum. * - *

stopSequences: List of strings that tells the model to stop generating text if one of the - * strings is encountered in the response. + *

mediaResolution: Optional. If specified, the media resolution specified will be used. */ - @JsonProperty("stopSequences") - public abstract Builder stopSequences(List stopSequences); + @CanIgnoreReturnValue + public Builder mediaResolution(MediaResolution.Known knownType) { + return mediaResolution(new MediaResolution(knownType)); + } /** - * Setter for stopSequences. + * Setter for mediaResolution given a string. * - *

stopSequences: List of strings that tells the model to stop generating text if one of the - * strings is encountered in the response. + *

mediaResolution: Optional. If specified, the media resolution specified will be used. */ @CanIgnoreReturnValue - public Builder stopSequences(String... stopSequences) { - return stopSequences(Arrays.asList(stopSequences)); + public Builder mediaResolution(String mediaResolution) { + return mediaResolution(new MediaResolution(mediaResolution)); } + /** + * Setter for presencePenalty. + * + *

presencePenalty: Optional. Positive penalties. + */ + @JsonProperty("presencePenalty") + public abstract Builder presencePenalty(Float presencePenalty); + @ExcludeFromGeneratedCoverageReport - abstract Builder stopSequences(Optional> stopSequences); + abstract Builder presencePenalty(Optional presencePenalty); - /** Clears the value of stopSequences field. */ + /** Clears the value of presencePenalty field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearStopSequences() { - return stopSequences(Optional.empty()); + public Builder clearPresencePenalty() { + return presencePenalty(Optional.empty()); + } + + /** + * Setter for responseJsonSchema. + * + *

responseJsonSchema: Optional. Output schema of the generated response. This is an + * alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If + * set, `response_schema` must be omitted, but `response_mime_type` is required. While the full + * JSON Schema may be sent, not all features are supported. Specifically, only the following + * properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - + * `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - + * `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as + * `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard + * `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited + * degree and, as such, may only be used within non-required properties. (Nullable properties + * are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than + * those starting as a `$`, may be set. + */ + @JsonProperty("responseJsonSchema") + public abstract Builder responseJsonSchema(Object responseJsonSchema); + + @ExcludeFromGeneratedCoverageReport + abstract Builder responseJsonSchema(Optional responseJsonSchema); + + /** Clears the value of responseJsonSchema field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearResponseJsonSchema() { + return responseJsonSchema(Optional.empty()); } /** * Setter for responseLogprobs. * - *

responseLogprobs: Whether to return the log probabilities of the tokens that were chosen - * by the model at each step. + *

responseLogprobs: Optional. If true, export the logprobs results in response. */ @JsonProperty("responseLogprobs") public abstract Builder responseLogprobs(boolean responseLogprobs); @@ -475,67 +473,122 @@ public Builder clearResponseLogprobs() { } /** - * Setter for logprobs. + * Setter for responseMimeType. * - *

logprobs: Number of top candidate tokens to return the log probabilities for at each - * generation step. + *

responseMimeType: Optional. Output response mimetype of the generated candidate text. + * Supported mimetype: - `text/plain`: (default) Text output. - `application/json`: JSON + * response in the candidates. The model needs to be prompted to output the appropriate response + * type, otherwise the behavior is undefined. This is a preview feature. */ - @JsonProperty("logprobs") - public abstract Builder logprobs(Integer logprobs); + @JsonProperty("responseMimeType") + public abstract Builder responseMimeType(String responseMimeType); @ExcludeFromGeneratedCoverageReport - abstract Builder logprobs(Optional logprobs); + abstract Builder responseMimeType(Optional responseMimeType); - /** Clears the value of logprobs field. */ + /** Clears the value of responseMimeType field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearLogprobs() { - return logprobs(Optional.empty()); + public Builder clearResponseMimeType() { + return responseMimeType(Optional.empty()); } /** - * Setter for presencePenalty. + * Setter for responseModalities. * - *

presencePenalty: Positive values penalize tokens that already appear in the generated - * text, increasing the probability of generating more diverse content. + *

responseModalities: Optional. The modalities of the response. */ - @JsonProperty("presencePenalty") - public abstract Builder presencePenalty(Float presencePenalty); + @JsonProperty("responseModalities") + public abstract Builder responseModalities(List responseModalities); + + /** + * Setter for responseModalities. + * + *

responseModalities: Optional. The modalities of the response. + */ + @CanIgnoreReturnValue + public Builder responseModalities(String... responseModalities) { + return responseModalities(Arrays.asList(responseModalities)); + } @ExcludeFromGeneratedCoverageReport - abstract Builder presencePenalty(Optional presencePenalty); + abstract Builder responseModalities(Optional> responseModalities); - /** Clears the value of presencePenalty field. */ + /** Clears the value of responseModalities field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearPresencePenalty() { - return presencePenalty(Optional.empty()); + public Builder clearResponseModalities() { + return responseModalities(Optional.empty()); } /** - * Setter for frequencyPenalty. + * Setter for responseSchema. * - *

frequencyPenalty: Positive values penalize tokens that repeatedly appear in the generated - * text, increasing the probability of generating more diverse content. + *

responseSchema: Optional. The `Schema` object allows the definition of input and output + * data types. These types can be objects, but also primitives and arrays. Represents a select + * subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If + * set, a compatible response_mime_type must also be set. Compatible mimetypes: + * `application/json`: Schema for JSON response. */ - @JsonProperty("frequencyPenalty") - public abstract Builder frequencyPenalty(Float frequencyPenalty); + @JsonProperty("responseSchema") + public abstract Builder responseSchema(Schema responseSchema); + + /** + * Setter for responseSchema builder. + * + *

responseSchema: Optional. The `Schema` object allows the definition of input and output + * data types. These types can be objects, but also primitives and arrays. Represents a select + * subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If + * set, a compatible response_mime_type must also be set. Compatible mimetypes: + * `application/json`: Schema for JSON response. + */ + @CanIgnoreReturnValue + public Builder responseSchema(Schema.Builder responseSchemaBuilder) { + return responseSchema(responseSchemaBuilder.build()); + } @ExcludeFromGeneratedCoverageReport - abstract Builder frequencyPenalty(Optional frequencyPenalty); + abstract Builder responseSchema(Optional responseSchema); - /** Clears the value of frequencyPenalty field. */ + /** Clears the value of responseSchema field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearFrequencyPenalty() { - return frequencyPenalty(Optional.empty()); + public Builder clearResponseSchema() { + return responseSchema(Optional.empty()); + } + + /** + * Setter for routingConfig. + * + *

routingConfig: Optional. Routing configuration. This field is not supported in Gemini API. + */ + @JsonProperty("routingConfig") + public abstract Builder routingConfig(GenerationConfigRoutingConfig routingConfig); + + /** + * Setter for routingConfig builder. + * + *

routingConfig: Optional. Routing configuration. This field is not supported in Gemini API. + */ + @CanIgnoreReturnValue + public Builder routingConfig(GenerationConfigRoutingConfig.Builder routingConfigBuilder) { + return routingConfig(routingConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder routingConfig(Optional routingConfig); + + /** Clears the value of routingConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearRoutingConfig() { + return routingConfig(Optional.empty()); } /** * Setter for seed. * - *

seed: When ``seed`` is fixed to a specific number, the model makes a best effort to - * provide the same response for repeated requests. By default, a random number is used. + *

seed: Optional. Seed. */ @JsonProperty("seed") public abstract Builder seed(Integer seed); @@ -551,151 +604,239 @@ public Builder clearSeed() { } /** - * Setter for responseMimeType. + * Setter for speechConfig. * - *

responseMimeType: Output response mimetype of the generated candidate text. Supported - * mimetype: - `text/plain`: (default) Text output. - `application/json`: JSON response in the - * candidates. The model needs to be prompted to output the appropriate response type, otherwise - * the behavior is undefined. This is a preview feature. + *

speechConfig: Optional. The speech generation config. */ - @JsonProperty("responseMimeType") - public abstract Builder responseMimeType(String responseMimeType); + @JsonProperty("speechConfig") + public abstract Builder speechConfig(SpeechConfig speechConfig); + + /** + * Setter for speechConfig builder. + * + *

speechConfig: Optional. The speech generation config. + */ + @CanIgnoreReturnValue + public Builder speechConfig(SpeechConfig.Builder speechConfigBuilder) { + return speechConfig(speechConfigBuilder.build()); + } @ExcludeFromGeneratedCoverageReport - abstract Builder responseMimeType(Optional responseMimeType); + abstract Builder speechConfig(Optional speechConfig); - /** Clears the value of responseMimeType field. */ + /** Clears the value of speechConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearResponseMimeType() { - return responseMimeType(Optional.empty()); + public Builder clearSpeechConfig() { + return speechConfig(Optional.empty()); } /** - * Setter for responseSchema. + * Setter for stopSequences. * - *

responseSchema: The `Schema` object allows the definition of input and output data types. - * These types can be objects, but also primitives and arrays. Represents a select subset of an - * [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a - * compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: - * Schema for JSON response. + *

stopSequences: Optional. Stop sequences. + */ + @JsonProperty("stopSequences") + public abstract Builder stopSequences(List stopSequences); + + /** + * Setter for stopSequences. * - *

If `response_schema` doesn't process your schema correctly, try using - * `response_json_schema` instead. + *

stopSequences: Optional. Stop sequences. */ - @JsonProperty("responseSchema") - public abstract Builder responseSchema(Schema responseSchema); + @CanIgnoreReturnValue + public Builder stopSequences(String... stopSequences) { + return stopSequences(Arrays.asList(stopSequences)); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder stopSequences(Optional> stopSequences); + + /** Clears the value of stopSequences field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearStopSequences() { + return stopSequences(Optional.empty()); + } /** - * Setter for responseSchema builder. + * Setter for temperature. * - *

responseSchema: The `Schema` object allows the definition of input and output data types. - * These types can be objects, but also primitives and arrays. Represents a select subset of an - * [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). If set, a - * compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: - * Schema for JSON response. + *

temperature: Optional. Controls the randomness of predictions. + */ + @JsonProperty("temperature") + public abstract Builder temperature(Float temperature); + + @ExcludeFromGeneratedCoverageReport + abstract Builder temperature(Optional temperature); + + /** Clears the value of temperature field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTemperature() { + return temperature(Optional.empty()); + } + + /** + * Setter for thinkingConfig. * - *

If `response_schema` doesn't process your schema correctly, try using - * `response_json_schema` instead. + *

thinkingConfig: Optional. Config for thinking features. An error will be returned if this + * field is set for models that don't support thinking. + */ + @JsonProperty("thinkingConfig") + public abstract Builder thinkingConfig(ThinkingConfig thinkingConfig); + + /** + * Setter for thinkingConfig builder. + * + *

thinkingConfig: Optional. Config for thinking features. An error will be returned if this + * field is set for models that don't support thinking. */ @CanIgnoreReturnValue - public Builder responseSchema(Schema.Builder responseSchemaBuilder) { - return responseSchema(responseSchemaBuilder.build()); + public Builder thinkingConfig(ThinkingConfig.Builder thinkingConfigBuilder) { + return thinkingConfig(thinkingConfigBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder responseSchema(Optional responseSchema); + abstract Builder thinkingConfig(Optional thinkingConfig); - /** Clears the value of responseSchema field. */ + /** Clears the value of thinkingConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearResponseSchema() { - return responseSchema(Optional.empty()); + public Builder clearThinkingConfig() { + return thinkingConfig(Optional.empty()); } /** - * Setter for responseJsonSchema. + * Setter for topK. * - *

responseJsonSchema: Optional. Output schema of the generated response. This is an - * alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If - * set, `response_schema` must be omitted, but `response_mime_type` is required. While the full - * JSON Schema may be sent, not all features are supported. Specifically, only the following - * properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - - * `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - - * `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as - * `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard - * `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited - * degree and, as such, may only be used within non-required properties. (Nullable properties - * are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than - * those starting as a `$`, may be set. + *

topK: Optional. If specified, top-k sampling will be used. + */ + @JsonProperty("topK") + public abstract Builder topK(Float topK); + + @ExcludeFromGeneratedCoverageReport + abstract Builder topK(Optional topK); + + /** Clears the value of topK field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTopK() { + return topK(Optional.empty()); + } + + /** + * Setter for topP. + * + *

topP: Optional. If specified, nucleus sampling will be used. + */ + @JsonProperty("topP") + public abstract Builder topP(Float topP); + + @ExcludeFromGeneratedCoverageReport + abstract Builder topP(Optional topP); + + /** Clears the value of topP field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTopP() { + return topP(Optional.empty()); + } + + /** + * Setter for enableEnhancedCivicAnswers. + * + *

enableEnhancedCivicAnswers: Optional. Enables enhanced civic answers. It may not be + * available for all models. This field is not supported in Vertex AI. */ - @JsonProperty("responseJsonSchema") - public abstract Builder responseJsonSchema(Object responseJsonSchema); + @JsonProperty("enableEnhancedCivicAnswers") + public abstract Builder enableEnhancedCivicAnswers(boolean enableEnhancedCivicAnswers); @ExcludeFromGeneratedCoverageReport - abstract Builder responseJsonSchema(Optional responseJsonSchema); + abstract Builder enableEnhancedCivicAnswers(Optional enableEnhancedCivicAnswers); - /** Clears the value of responseJsonSchema field. */ + /** Clears the value of enableEnhancedCivicAnswers field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearResponseJsonSchema() { - return responseJsonSchema(Optional.empty()); + public Builder clearEnableEnhancedCivicAnswers() { + return enableEnhancedCivicAnswers(Optional.empty()); } /** - * Setter for routingConfig. + * Setter for httpOptions. * - *

routingConfig: Configuration for model router requests. + *

httpOptions: Used to override HTTP request options. */ - @JsonProperty("routingConfig") - public abstract Builder routingConfig(GenerationConfigRoutingConfig routingConfig); + @JsonProperty("httpOptions") + public abstract Builder httpOptions(HttpOptions httpOptions); /** - * Setter for routingConfig builder. + * Setter for httpOptions builder. * - *

routingConfig: Configuration for model router requests. + *

httpOptions: Used to override HTTP request options. */ @CanIgnoreReturnValue - public Builder routingConfig(GenerationConfigRoutingConfig.Builder routingConfigBuilder) { - return routingConfig(routingConfigBuilder.build()); + public Builder httpOptions(HttpOptions.Builder httpOptionsBuilder) { + return httpOptions(httpOptionsBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder routingConfig(Optional routingConfig); + abstract Builder httpOptions(Optional httpOptions); - /** Clears the value of routingConfig field. */ + /** Clears the value of httpOptions field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearRoutingConfig() { - return routingConfig(Optional.empty()); + public Builder clearHttpOptions() { + return httpOptions(Optional.empty()); } /** - * Setter for modelSelectionConfig. + * Setter for shouldReturnHttpResponse. * - *

modelSelectionConfig: Configuration for model selection. + *

shouldReturnHttpResponse: If true, the raw HTTP response will be returned in the + * 'sdk_http_response' field. */ - @JsonProperty("modelSelectionConfig") - public abstract Builder modelSelectionConfig(ModelSelectionConfig modelSelectionConfig); + @JsonProperty("shouldReturnHttpResponse") + public abstract Builder shouldReturnHttpResponse(boolean shouldReturnHttpResponse); + + @ExcludeFromGeneratedCoverageReport + abstract Builder shouldReturnHttpResponse(Optional shouldReturnHttpResponse); + + /** Clears the value of shouldReturnHttpResponse field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearShouldReturnHttpResponse() { + return shouldReturnHttpResponse(Optional.empty()); + } /** - * Setter for modelSelectionConfig builder. + * Setter for systemInstruction. + * + *

systemInstruction: Instructions for the model to steer it toward better performance. For + * example, "Answer as concisely as possible" or "Don't use technical terms in your response". + */ + @JsonProperty("systemInstruction") + public abstract Builder systemInstruction(Content systemInstruction); + + /** + * Setter for systemInstruction builder. * - *

modelSelectionConfig: Configuration for model selection. + *

systemInstruction: Instructions for the model to steer it toward better performance. For + * example, "Answer as concisely as possible" or "Don't use technical terms in your response". */ @CanIgnoreReturnValue - public Builder modelSelectionConfig(ModelSelectionConfig.Builder modelSelectionConfigBuilder) { - return modelSelectionConfig(modelSelectionConfigBuilder.build()); + public Builder systemInstruction(Content.Builder systemInstructionBuilder) { + return systemInstruction(systemInstructionBuilder.build()); } @ExcludeFromGeneratedCoverageReport - abstract Builder modelSelectionConfig(Optional modelSelectionConfig); + abstract Builder systemInstruction(Optional systemInstruction); - /** Clears the value of modelSelectionConfig field. */ + /** Clears the value of systemInstruction field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearModelSelectionConfig() { - return modelSelectionConfig(Optional.empty()); + public Builder clearSystemInstruction() { + return systemInstruction(Optional.empty()); } /** @@ -848,117 +989,31 @@ public Builder clearCachedContent() { } /** - * Setter for responseModalities. - * - *

responseModalities: The requested modalities of the response. Represents the set of - * modalities that the model can return. - */ - @JsonProperty("responseModalities") - public abstract Builder responseModalities(List responseModalities); - - /** - * Setter for responseModalities. - * - *

responseModalities: The requested modalities of the response. Represents the set of - * modalities that the model can return. - */ - @CanIgnoreReturnValue - public Builder responseModalities(String... responseModalities) { - return responseModalities(Arrays.asList(responseModalities)); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder responseModalities(Optional> responseModalities); - - /** Clears the value of responseModalities field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearResponseModalities() { - return responseModalities(Optional.empty()); - } - - /** - * Setter for mediaResolution. - * - *

mediaResolution: If specified, the media resolution specified will be used. - */ - @JsonProperty("mediaResolution") - public abstract Builder mediaResolution(MediaResolution mediaResolution); - - @ExcludeFromGeneratedCoverageReport - abstract Builder mediaResolution(Optional mediaResolution); - - /** Clears the value of mediaResolution field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearMediaResolution() { - return mediaResolution(Optional.empty()); - } - - /** - * Setter for mediaResolution given a known enum. - * - *

mediaResolution: If specified, the media resolution specified will be used. - */ - @CanIgnoreReturnValue - public Builder mediaResolution(MediaResolution.Known knownType) { - return mediaResolution(new MediaResolution(knownType)); - } - - /** - * Setter for mediaResolution given a string. - * - *

mediaResolution: If specified, the media resolution specified will be used. - */ - @CanIgnoreReturnValue - public Builder mediaResolution(String mediaResolution) { - return mediaResolution(new MediaResolution(mediaResolution)); - } - - /** - * Setter for speechConfig. + * Setter for imageConfig. * - *

speechConfig: The speech generation configuration. + *

imageConfig: The image generation configuration. */ - @JsonProperty("speechConfig") - public abstract Builder speechConfig(SpeechConfig speechConfig); + @JsonProperty("imageConfig") + public abstract Builder imageConfig(ImageConfig imageConfig); /** - * Setter for speechConfig builder. + * Setter for imageConfig builder. * - *

speechConfig: The speech generation configuration. + *

imageConfig: The image generation configuration. */ @CanIgnoreReturnValue - public Builder speechConfig(SpeechConfig.Builder speechConfigBuilder) { - return speechConfig(speechConfigBuilder.build()); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder speechConfig(Optional speechConfig); - - /** Clears the value of speechConfig field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearSpeechConfig() { - return speechConfig(Optional.empty()); + public Builder imageConfig(ImageConfig.Builder imageConfigBuilder) { + return imageConfig(imageConfigBuilder.build()); } - /** - * Setter for audioTimestamp. - * - *

audioTimestamp: If enabled, audio timestamp will be included in the request to the model. - */ - @JsonProperty("audioTimestamp") - public abstract Builder audioTimestamp(boolean audioTimestamp); - @ExcludeFromGeneratedCoverageReport - abstract Builder audioTimestamp(Optional audioTimestamp); + abstract Builder imageConfig(Optional imageConfig); - /** Clears the value of audioTimestamp field. */ + /** Clears the value of imageConfig field. */ @ExcludeFromGeneratedCoverageReport @CanIgnoreReturnValue - public Builder clearAudioTimestamp() { - return audioTimestamp(Optional.empty()); + public Builder clearImageConfig() { + return imageConfig(Optional.empty()); } /** @@ -992,81 +1047,6 @@ public Builder clearAutomaticFunctionCalling() { return automaticFunctionCalling(Optional.empty()); } - /** - * Setter for thinkingConfig. - * - *

thinkingConfig: The thinking features configuration. - */ - @JsonProperty("thinkingConfig") - public abstract Builder thinkingConfig(ThinkingConfig thinkingConfig); - - /** - * Setter for thinkingConfig builder. - * - *

thinkingConfig: The thinking features configuration. - */ - @CanIgnoreReturnValue - public Builder thinkingConfig(ThinkingConfig.Builder thinkingConfigBuilder) { - return thinkingConfig(thinkingConfigBuilder.build()); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder thinkingConfig(Optional thinkingConfig); - - /** Clears the value of thinkingConfig field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearThinkingConfig() { - return thinkingConfig(Optional.empty()); - } - - /** - * Setter for imageConfig. - * - *

imageConfig: The image generation configuration. - */ - @JsonProperty("imageConfig") - public abstract Builder imageConfig(ImageConfig imageConfig); - - /** - * Setter for imageConfig builder. - * - *

imageConfig: The image generation configuration. - */ - @CanIgnoreReturnValue - public Builder imageConfig(ImageConfig.Builder imageConfigBuilder) { - return imageConfig(imageConfigBuilder.build()); - } - - @ExcludeFromGeneratedCoverageReport - abstract Builder imageConfig(Optional imageConfig); - - /** Clears the value of imageConfig field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearImageConfig() { - return imageConfig(Optional.empty()); - } - - /** - * Setter for enableEnhancedCivicAnswers. - * - *

enableEnhancedCivicAnswers: Enables enhanced civic answers. It may not be available for - * all models. This field is not supported in Vertex AI. - */ - @JsonProperty("enableEnhancedCivicAnswers") - public abstract Builder enableEnhancedCivicAnswers(boolean enableEnhancedCivicAnswers); - - @ExcludeFromGeneratedCoverageReport - abstract Builder enableEnhancedCivicAnswers(Optional enableEnhancedCivicAnswers); - - /** Clears the value of enableEnhancedCivicAnswers field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearEnableEnhancedCivicAnswers() { - return enableEnhancedCivicAnswers(Optional.empty()); - } - public abstract GenerateContentConfig build(); } diff --git a/src/main/java/com/google/genai/types/GenerationConfig.java b/src/main/java/com/google/genai/types/GenerationConfig.java index f5468420b11..d33162f9ab6 100644 --- a/src/main/java/com/google/genai/types/GenerationConfig.java +++ b/src/main/java/com/google/genai/types/GenerationConfig.java @@ -39,13 +39,6 @@ public abstract class GenerationConfig extends JsonSerializable { @JsonProperty("modelSelectionConfig") public abstract Optional modelSelectionConfig(); - /** - * Output schema of the generated response. This is an alternative to `response_schema` that - * accepts [JSON Schema](https://json-schema.org/). - */ - @JsonProperty("responseJsonSchema") - public abstract Optional responseJsonSchema(); - /** * Optional. If enabled, audio timestamp will be included in the request to the model. This field * is not supported in Gemini API. @@ -84,6 +77,22 @@ public abstract class GenerationConfig extends JsonSerializable { @JsonProperty("presencePenalty") public abstract Optional presencePenalty(); + /** + * Optional. Output schema of the generated response. This is an alternative to `response_schema` + * that accepts [JSON Schema](https://json-schema.org/). If set, `response_schema` must be + * omitted, but `response_mime_type` is required. While the full JSON Schema may be sent, not all + * features are supported. Specifically, only the following properties are supported: - `$id` - + * `$defs` - `$ref` - `$anchor` - `type` - `format` - `title` - `description` - `enum` (for + * strings and numbers) - `items` - `prefixItems` - `minItems` - `maxItems` - `minimum` - + * `maximum` - `anyOf` - `oneOf` (interpreted the same as `anyOf`) - `properties` - + * `additionalProperties` - `required` The non-standard `propertyOrdering` property may also be + * set. Cyclic references are unrolled to a limited degree and, as such, may only be used within + * non-required properties. (Nullable properties are not sufficient.) If `$ref` is set on a + * sub-schema, no other properties, except for than those starting as a `$`, may be set. + */ + @JsonProperty("responseJsonSchema") + public abstract Optional responseJsonSchema(); + /** Optional. If true, export the logprobs results in response. */ @JsonProperty("responseLogprobs") public abstract Optional responseLogprobs(); @@ -199,25 +208,6 @@ public Builder clearModelSelectionConfig() { return modelSelectionConfig(Optional.empty()); } - /** - * Setter for responseJsonSchema. - * - *

responseJsonSchema: Output schema of the generated response. This is an alternative to - * `response_schema` that accepts [JSON Schema](https://json-schema.org/). - */ - @JsonProperty("responseJsonSchema") - public abstract Builder responseJsonSchema(Object responseJsonSchema); - - @ExcludeFromGeneratedCoverageReport - abstract Builder responseJsonSchema(Optional responseJsonSchema); - - /** Clears the value of responseJsonSchema field. */ - @ExcludeFromGeneratedCoverageReport - @CanIgnoreReturnValue - public Builder clearResponseJsonSchema() { - return responseJsonSchema(Optional.empty()); - } - /** * Setter for audioTimestamp. * @@ -384,6 +374,35 @@ public Builder clearPresencePenalty() { return presencePenalty(Optional.empty()); } + /** + * Setter for responseJsonSchema. + * + *

responseJsonSchema: Optional. Output schema of the generated response. This is an + * alternative to `response_schema` that accepts [JSON Schema](https://json-schema.org/). If + * set, `response_schema` must be omitted, but `response_mime_type` is required. While the full + * JSON Schema may be sent, not all features are supported. Specifically, only the following + * properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - + * `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - + * `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as + * `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard + * `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited + * degree and, as such, may only be used within non-required properties. (Nullable properties + * are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than + * those starting as a `$`, may be set. + */ + @JsonProperty("responseJsonSchema") + public abstract Builder responseJsonSchema(Object responseJsonSchema); + + @ExcludeFromGeneratedCoverageReport + abstract Builder responseJsonSchema(Optional responseJsonSchema); + + /** Clears the value of responseJsonSchema field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearResponseJsonSchema() { + return responseJsonSchema(Optional.empty()); + } + /** * Setter for responseLogprobs. * diff --git a/src/main/java/com/google/genai/types/MediaResolution.java b/src/main/java/com/google/genai/types/MediaResolution.java index 3a404907c98..ad4c63f9e1b 100644 --- a/src/main/java/com/google/genai/types/MediaResolution.java +++ b/src/main/java/com/google/genai/types/MediaResolution.java @@ -23,12 +23,12 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** The media resolution to use. */ +/** If specified, the media resolution specified will be used. */ public class MediaResolution { /** Enum representing the known values for MediaResolution. */ public enum Known { - /** Media resolution has not been set */ + /** Media resolution has not been set. */ MEDIA_RESOLUTION_UNSPECIFIED, /** Media resolution set to low (64 tokens). */