From 86a66678776c3c049ed0d1b5b244d05e644fd743 Mon Sep 17 00:00:00 2001 From: Jaycee Li Date: Tue, 23 Jun 2026 13:14:10 -0700 Subject: [PATCH] feat: Add Tool.exa_ai_search for Gemini Enterprise API feat: Add response_format and Translation_config in GenerationConfig PiperOrigin-RevId: 936848756 --- .../java/com/google/genai/AsyncModels.java | 6 +- src/main/java/com/google/genai/Batches.java | 6 + src/main/java/com/google/genai/Caches.java | 13 ++ .../java/com/google/genai/LiveConverters.java | 26 +++ src/main/java/com/google/genai/Models.java | 26 +++ .../com/google/genai/TokensConverters.java | 6 + src/main/java/com/google/genai/Tunings.java | 20 ++ .../com/google/genai/types/AspectRatio.java | 147 +++++++++++++ .../genai/types/AudioResponseFormat.java | 171 +++++++++++++++ .../java/com/google/genai/types/Behavior.java | 5 +- .../com/google/genai/types/Candidate.java | 4 +- ...positeReinforcementTuningRewardConfig.java | 8 +- ...uningRewardConfigWeightedRewardConfig.java | 17 +- .../genai/types/ComputeTokensParameters.java | 4 +- .../genai/types/CountTokensParameters.java | 4 +- .../genai/types/CustomCodeExecutionSpec.java | 8 +- .../com/google/genai/types/DatasetStats.java | 101 +++++++++ .../genai/types/DeleteModelResponse.java | 2 +- .../java/com/google/genai/types/Delivery.java | 111 ++++++++++ .../genai/types/EmbedContentParameters.java | 4 +- .../types/EmbedContentParametersPrivate.java | 4 +- .../genai/types/EmbeddingsBatchJobSource.java | 2 +- ...ionParserConfigCustomCodeParserConfig.java | 19 +- .../types/FetchPredictOperationConfig.java | 2 +- .../genai/types/FunctionDeclaration.java | 24 +- .../genai/types/GenerateContentConfig.java | 2 +- .../types/GenerateContentParameters.java | 4 +- .../genai/types/GenerateImagesParameters.java | 4 +- .../genai/types/GenerateVideosParameters.java | 4 +- .../google/genai/types/GenerationConfig.java | 98 ++++++++- .../genai/types/GetModelParameters.java | 2 +- .../genai/types/GetOperationConfig.java | 2 +- .../google/genai/types/GroundingMetadata.java | 12 +- .../genai/types/ImageResponseFormat.java | 207 ++++++++++++++++++ .../com/google/genai/types/ImageSize.java | 117 ++++++++++ .../google/genai/types/InlinedRequest.java | 4 +- .../types/ListCachedContentsResponse.java | 2 +- .../google/genai/types/ListModelsConfig.java | 2 +- .../genai/types/ListModelsParameters.java | 2 +- .../genai/types/ListModelsResponse.java | 2 +- .../genai/types/LiveConnectConstraints.java | 4 +- .../genai/types/LiveConnectParameters.java | 4 +- .../google/genai/types/LiveServerContent.java | 10 +- .../google/genai/types/MatchOperation.java | 14 +- .../genai/types/RecontextImageParameters.java | 4 +- .../ReinforcementTuningAutoraterScorer.java | 39 ++-- ...TuningAutoraterScorerExactMatchScorer.java | 39 +++- ...rScorerParsedResponseConversionScorer.java | 5 +- ...inforcementTuningCloudRunRewardScorer.java | 41 +++- ...cementTuningCodeExecutionRewardScorer.java | 32 ++- .../types/ReinforcementTuningExample.java | 188 ++++++++++++++++ .../ReinforcementTuningHyperParameters.java | 102 ++++++--- ...einforcementTuningParseResponseConfig.java | 27 ++- .../genai/types/ReinforcementTuningSpec.java | 23 +- ...orcementTuningStringMatchRewardScorer.java | 24 +- ...gMatchRewardScorerJsonMatchExpression.java | 27 ++- ...atchRewardScorerStringMatchExpression.java | 38 +++- ...einforcementTuningUserDatasetExamples.java | 118 ++++++++++ .../google/genai/types/ResponseFormat.java | 190 ++++++++++++++++ .../google/genai/types/ResponseParseType.java | 13 +- .../genai/types/SegmentImageParameters.java | 4 +- ...SingleReinforcementTuningRewardConfig.java | 58 +++-- .../com/google/genai/types/SlidingWindow.java | 6 +- .../com/google/genai/types/TestTableFile.java | 2 +- .../com/google/genai/types/TestTableItem.java | 2 +- .../genai/types/TextResponseFormat.java | 107 +++++++++ .../java/com/google/genai/types/Tool.java | 40 ++++ .../google/genai/types/ToolExaAiSearch.java | 108 +++++++++ .../google/genai/types/TranslationConfig.java | 19 +- .../google/genai/types/TuningDataStats.java | 34 +++ .../com/google/genai/types/TuningJob.java | 6 +- .../genai/types/TuningValidationDataset.java | 2 +- .../types/UpdateCachedContentParameters.java | 2 +- .../genai/types/UpscaleImageConfig.java | 2 +- .../genai/types/UpscaleImageResponse.java | 2 +- .../genai/types/VideoResponseFormat.java | 195 +++++++++++++++++ .../types/VoiceActivityDetectionSignal.java | 2 +- 77 files changed, 2482 insertions(+), 255 deletions(-) create mode 100644 src/main/java/com/google/genai/types/AspectRatio.java create mode 100644 src/main/java/com/google/genai/types/AudioResponseFormat.java create mode 100644 src/main/java/com/google/genai/types/Delivery.java create mode 100644 src/main/java/com/google/genai/types/ImageResponseFormat.java create mode 100644 src/main/java/com/google/genai/types/ImageSize.java create mode 100644 src/main/java/com/google/genai/types/ReinforcementTuningExample.java create mode 100644 src/main/java/com/google/genai/types/ReinforcementTuningUserDatasetExamples.java create mode 100644 src/main/java/com/google/genai/types/ResponseFormat.java create mode 100644 src/main/java/com/google/genai/types/TextResponseFormat.java create mode 100644 src/main/java/com/google/genai/types/ToolExaAiSearch.java create mode 100644 src/main/java/com/google/genai/types/VideoResponseFormat.java diff --git a/src/main/java/com/google/genai/AsyncModels.java b/src/main/java/com/google/genai/AsyncModels.java index eb1855fed5e..e499784c565 100644 --- a/src/main/java/com/google/genai/AsyncModels.java +++ b/src/main/java/com/google/genai/AsyncModels.java @@ -458,7 +458,8 @@ public CompletableFuture delete(String model, DeleteModelCo * Asynchronously counts tokens given a GenAI model and a list of content. * * @param model the name of the GenAI model to use. - * @param contents a {@link List} to send to count tokens for. + * @param contents a {@link List<com.google.genai.types.Content>} to send to count tokens + * for. * @param config a {@link com.google.genai.types.CountTokensConfig} instance that specifies the * optional configurations * @return a {@link com.google.genai.types.CountTokensResponse} instance that contains tokens @@ -493,7 +494,8 @@ public CompletableFuture countTokens( * Asynchronously computes tokens given a GenAI model and a list of content. * * @param model the name of the GenAI model to use. - * @param contents a {@link List} to send to compute tokens for. + * @param contents a {@link List<com.google.genai.types.Content>} to send to compute tokens + * for. * @param config a {@link com.google.genai.types.ComputeTokensConfig} instance that specifies the * optional configurations * @return a {@link com.google.genai.types.ComputeTokensResponse} instance that contains tokens diff --git a/src/main/java/com/google/genai/Batches.java b/src/main/java/com/google/genai/Batches.java index 14c0c9dae81..d5cf780500e 100644 --- a/src/main/java/com/google/genai/Batches.java +++ b/src/main/java/com/google/genai/Batches.java @@ -2116,6 +2116,12 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"mcpServers"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) { + throw new IllegalArgumentException( + "exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in" + + " Gemini Developer API mode."); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Caches.java b/src/main/java/com/google/genai/Caches.java index abb71ff904a..ca3b25b67e4 100644 --- a/src/main/java/com/google/genai/Caches.java +++ b/src/main/java/com/google/genai/Caches.java @@ -1217,6 +1217,12 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"mcpServers"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) { + throw new IllegalArgumentException( + "exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in" + + " Gemini Developer API mode."); + } + return toObject; } @@ -1314,6 +1320,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.setValueByPath(toObject, new String[] {"mcpServers"}, result); } + if (Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"exaAiSearch"}, + Common.getValueByPath(fromObject, new String[] {"exaAiSearch"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index ef2e2200261..4c9e5ab33c3 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -502,6 +502,19 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject + " in Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"responseFormat"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"responseFormat"}, + Common.getValueByPath(fromObject, new String[] {"responseFormat"})); + } + + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"translationConfig"}))) { + throw new IllegalArgumentException( + "translationConfig parameter is only supported in Gemini Developer API mode, not in" + + " Gemini Enterprise Agent Platform mode."); + } + return toObject; } @@ -2115,6 +2128,12 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"mcpServers"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) { + throw new IllegalArgumentException( + "exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in" + + " Gemini Developer API mode."); + } + return toObject; } @@ -2212,6 +2231,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) { Common.setValueByPath(toObject, new String[] {"mcpServers"}, result); } + if (Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"exaAiSearch"}, + Common.getValueByPath(fromObject, new String[] {"exaAiSearch"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java index 4c3dacd5db4..a48ee8caae7 100644 --- a/src/main/java/com/google/genai/Models.java +++ b/src/main/java/com/google/genai/Models.java @@ -3547,6 +3547,19 @@ ObjectNode generationConfigToVertex( + " in Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"responseFormat"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"responseFormat"}, + Common.getValueByPath(fromObject, new String[] {"responseFormat"})); + } + + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"translationConfig"}))) { + throw new IllegalArgumentException( + "translationConfig parameter is only supported in Gemini Developer API mode, not in" + + " Gemini Enterprise Agent Platform mode."); + } + return toObject; } @@ -5126,6 +5139,12 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode ro Common.getValueByPath(fromObject, new String[] {"mcpServers"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) { + throw new IllegalArgumentException( + "exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in" + + " Gemini Developer API mode."); + } + return toObject; } @@ -5224,6 +5243,13 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode r Common.setValueByPath(toObject, new String[] {"mcpServers"}, result); } + if (Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"exaAiSearch"}, + Common.getValueByPath(fromObject, new String[] {"exaAiSearch"})); + } + return toObject; } diff --git a/src/main/java/com/google/genai/TokensConverters.java b/src/main/java/com/google/genai/TokensConverters.java index 62462b09e5d..54fb3cc9254 100644 --- a/src/main/java/com/google/genai/TokensConverters.java +++ b/src/main/java/com/google/genai/TokensConverters.java @@ -817,6 +817,12 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) { Common.getValueByPath(fromObject, new String[] {"mcpServers"})); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) { + throw new IllegalArgumentException( + "exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in" + + " Gemini Developer API mode."); + } + return toObject; } } diff --git a/src/main/java/com/google/genai/Tunings.java b/src/main/java/com/google/genai/Tunings.java index c8ce051a358..1327840ee7d 100644 --- a/src/main/java/com/google/genai/Tunings.java +++ b/src/main/java/com/google/genai/Tunings.java @@ -1219,6 +1219,13 @@ ObjectNode generationConfigFromVertex( Common.getValueByPath(fromObject, new String[] {"topP"})); } + if (Common.getValueByPath(fromObject, new String[] {"responseFormat"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"responseFormat"}, + Common.getValueByPath(fromObject, new String[] {"responseFormat"})); + } + return toObject; } @@ -1387,6 +1394,19 @@ ObjectNode generationConfigToVertex( + " in Gemini Enterprise Agent Platform mode."); } + if (Common.getValueByPath(fromObject, new String[] {"responseFormat"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"responseFormat"}, + Common.getValueByPath(fromObject, new String[] {"responseFormat"})); + } + + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"translationConfig"}))) { + throw new IllegalArgumentException( + "translationConfig parameter is only supported in Gemini Developer API mode, not in" + + " Gemini Enterprise Agent Platform mode."); + } + return toObject; } diff --git a/src/main/java/com/google/genai/types/AspectRatio.java b/src/main/java/com/google/genai/types/AspectRatio.java new file mode 100644 index 00000000000..9c150e351af --- /dev/null +++ b/src/main/java/com/google/genai/types/AspectRatio.java @@ -0,0 +1,147 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** The aspect ratio for the image output. */ +public class AspectRatio { + + /** Enum representing the known values for AspectRatio. */ + public enum Known { + /** Default value. This value is unused. */ + ASPECT_RATIO_UNSPECIFIED, + + /** 1:1 aspect ratio. */ + ASPECT_RATIO_ONE_BY_ONE, + + /** 2:3 aspect ratio. */ + ASPECT_RATIO_TWO_BY_THREE, + + /** 3:2 aspect ratio. */ + ASPECT_RATIO_THREE_BY_TWO, + + /** 3:4 aspect ratio. */ + ASPECT_RATIO_THREE_BY_FOUR, + + /** 4:3 aspect ratio. */ + ASPECT_RATIO_FOUR_BY_THREE, + + /** 4:5 aspect ratio. */ + ASPECT_RATIO_FOUR_BY_FIVE, + + /** 5:4 aspect ratio. */ + ASPECT_RATIO_FIVE_BY_FOUR, + + /** 9:16 aspect ratio. */ + ASPECT_RATIO_NINE_BY_SIXTEEN, + + /** 16:9 aspect ratio. */ + ASPECT_RATIO_SIXTEEN_BY_NINE, + + /** 21:9 aspect ratio. */ + ASPECT_RATIO_TWENTY_ONE_BY_NINE, + + /** 1:8 aspect ratio. */ + ASPECT_RATIO_ONE_BY_EIGHT, + + /** 8:1 aspect ratio. */ + ASPECT_RATIO_EIGHT_BY_ONE, + + /** 1:4 aspect ratio. */ + ASPECT_RATIO_ONE_BY_FOUR, + + /** 4:1 aspect ratio. */ + ASPECT_RATIO_FOUR_BY_ONE + } + + private Known aspectRatioEnum; + private final String value; + + @JsonCreator + public AspectRatio(String value) { + this.value = value; + for (Known aspectRatioEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(aspectRatioEnum.toString(), value)) { + this.aspectRatioEnum = aspectRatioEnum; + break; + } + } + if (this.aspectRatioEnum == null) { + this.aspectRatioEnum = Known.ASPECT_RATIO_UNSPECIFIED; + } + } + + public AspectRatio(Known knownValue) { + this.aspectRatioEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof AspectRatio)) { + return false; + } + + AspectRatio other = (AspectRatio) o; + + if (this.aspectRatioEnum != Known.ASPECT_RATIO_UNSPECIFIED + && other.aspectRatioEnum != Known.ASPECT_RATIO_UNSPECIFIED) { + return this.aspectRatioEnum == other.aspectRatioEnum; + } else if (this.aspectRatioEnum == Known.ASPECT_RATIO_UNSPECIFIED + && other.aspectRatioEnum == Known.ASPECT_RATIO_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.aspectRatioEnum != Known.ASPECT_RATIO_UNSPECIFIED) { + return this.aspectRatioEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.aspectRatioEnum; + } +} diff --git a/src/main/java/com/google/genai/types/AudioResponseFormat.java b/src/main/java/com/google/genai/types/AudioResponseFormat.java new file mode 100644 index 00000000000..070773d7ab4 --- /dev/null +++ b/src/main/java/com/google/genai/types/AudioResponseFormat.java @@ -0,0 +1,171 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Configuration for audio-specific output formatting. */ +@AutoValue +@JsonDeserialize(builder = AudioResponseFormat.Builder.class) +public abstract class AudioResponseFormat extends JsonSerializable { + /** + * Optional. Bit rate in bits per second (bps). Only applicable for compressed formats (MP3, + * Opus). + */ + @JsonProperty("bitRate") + public abstract Optional bitRate(); + + /** Optional. Delivery mode for the generated content. */ + @JsonProperty("delivery") + public abstract Optional delivery(); + + /** Optional. The MIME type of the audio output. */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** Optional. Sample rate for the generated audio in Hertz. */ + @JsonProperty("sampleRate") + public abstract Optional sampleRate(); + + /** Instantiates a builder for AudioResponseFormat. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_AudioResponseFormat.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for AudioResponseFormat. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `AudioResponseFormat.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_AudioResponseFormat.Builder(); + } + + /** + * Setter for bitRate. + * + *

bitRate: Optional. Bit rate in bits per second (bps). Only applicable for compressed + * formats (MP3, Opus). + */ + @JsonProperty("bitRate") + public abstract Builder bitRate(Integer bitRate); + + @ExcludeFromGeneratedCoverageReport + abstract Builder bitRate(Optional bitRate); + + /** Clears the value of bitRate field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearBitRate() { + return bitRate(Optional.empty()); + } + + /** + * Setter for delivery. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @JsonProperty("delivery") + public abstract Builder delivery(Delivery delivery); + + @ExcludeFromGeneratedCoverageReport + abstract Builder delivery(Optional delivery); + + /** Clears the value of delivery field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDelivery() { + return delivery(Optional.empty()); + } + + /** + * Setter for delivery given a known enum. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(Delivery.Known knownType) { + return delivery(new Delivery(knownType)); + } + + /** + * Setter for delivery given a string. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(String delivery) { + return delivery(new Delivery(delivery)); + } + + /** + * Setter for mimeType. + * + *

mimeType: Optional. The MIME type of the audio output. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder mimeType(Optional mimeType); + + /** Clears the value of mimeType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMimeType() { + return mimeType(Optional.empty()); + } + + /** + * Setter for sampleRate. + * + *

sampleRate: Optional. Sample rate for the generated audio in Hertz. + */ + @JsonProperty("sampleRate") + public abstract Builder sampleRate(Integer sampleRate); + + @ExcludeFromGeneratedCoverageReport + abstract Builder sampleRate(Optional sampleRate); + + /** Clears the value of sampleRate field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSampleRate() { + return sampleRate(Optional.empty()); + } + + public abstract AudioResponseFormat build(); + } + + /** Deserializes a JSON string to a AudioResponseFormat object. */ + @ExcludeFromGeneratedCoverageReport + public static AudioResponseFormat fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, AudioResponseFormat.class); + } +} diff --git a/src/main/java/com/google/genai/types/Behavior.java b/src/main/java/com/google/genai/types/Behavior.java index afce247558a..3d5620a896f 100644 --- a/src/main/java/com/google/genai/types/Behavior.java +++ b/src/main/java/com/google/genai/types/Behavior.java @@ -24,9 +24,8 @@ import java.util.Objects; /** - * Specifies the function Behavior. Currently only non-blocking functions are supported. If not - * specified, the system keeps the current function call behavior. This field is currently only - * supported by the BidiGenerateContent method. + * Specifies the function Behavior. If not specified, the system keeps the current function call + * behavior. This field is currently only supported by the BidiGenerateContent method. */ public class Behavior { diff --git a/src/main/java/com/google/genai/types/Candidate.java b/src/main/java/com/google/genai/types/Candidate.java index 814e4054708..2df1ed217ec 100644 --- a/src/main/java/com/google/genai/types/Candidate.java +++ b/src/main/java/com/google/genai/types/Candidate.java @@ -74,7 +74,7 @@ public abstract class Candidate extends JsonSerializable { /** * Output only. The 0-based index of this candidate in the list of generated responses. This is - * useful for distinguishing between multiple candidates when `candidate_count` > 1. + * useful for distinguishing between multiple candidates when `candidate_count` > 1. */ @JsonProperty("index") public abstract Optional index(); @@ -308,7 +308,7 @@ public Builder clearAvgLogprobs() { * *

index: Output only. The 0-based index of this candidate in the list of generated * responses. This is useful for distinguishing between multiple candidates when - * `candidate_count` > 1. + * `candidate_count` > 1. */ @JsonProperty("index") public abstract Builder index(Integer index); diff --git a/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfig.java b/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfig.java index 9b6777151ec..bb266c1766b 100644 --- a/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfig.java +++ b/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfig.java @@ -34,7 +34,7 @@ @AutoValue @JsonDeserialize(builder = CompositeReinforcementTuningRewardConfig.Builder.class) public abstract class CompositeReinforcementTuningRewardConfig extends JsonSerializable { - /** */ + /** List of reward function configurations with weights. */ @JsonProperty("weightedRewardConfigs") public abstract Optional> weightedRewardConfigs(); @@ -63,7 +63,7 @@ private static Builder create() { /** * Setter for weightedRewardConfigs. * - *

weightedRewardConfigs: + *

weightedRewardConfigs: List of reward function configurations with weights. */ @JsonProperty("weightedRewardConfigs") public abstract Builder weightedRewardConfigs( @@ -72,7 +72,7 @@ public abstract Builder weightedRewardConfigs( /** * Setter for weightedRewardConfigs. * - *

weightedRewardConfigs: + *

weightedRewardConfigs: List of reward function configurations with weights. */ @CanIgnoreReturnValue public Builder weightedRewardConfigs( @@ -83,7 +83,7 @@ public Builder weightedRewardConfigs( /** * Setter for weightedRewardConfigs builder. * - *

weightedRewardConfigs: + *

weightedRewardConfigs: List of reward function configurations with weights. */ @CanIgnoreReturnValue public Builder weightedRewardConfigs( diff --git a/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfigWeightedRewardConfig.java b/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfigWeightedRewardConfig.java index 3dcd94de1e3..14530898c86 100644 --- a/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfigWeightedRewardConfig.java +++ b/src/main/java/com/google/genai/types/CompositeReinforcementTuningRewardConfigWeightedRewardConfig.java @@ -32,11 +32,15 @@ builder = CompositeReinforcementTuningRewardConfigWeightedRewardConfig.Builder.class) public abstract class CompositeReinforcementTuningRewardConfigWeightedRewardConfig extends JsonSerializable { - /** */ + /** Single reward configuration. */ @JsonProperty("rewardConfig") public abstract Optional rewardConfig(); - /** How much this single reward contributes to the total overall reward. */ + /** + * How much this single reward contributes to the total overall reward. Total reward is a linear + * combination of single rewards with their corresponding weights, i.e., ``` total_reward = ( + * weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + ...) ``` + */ @JsonProperty("weight") public abstract Optional weight(); @@ -64,7 +68,7 @@ private static Builder create() { /** * Setter for rewardConfig. * - *

rewardConfig: + *

rewardConfig: Single reward configuration. */ @JsonProperty("rewardConfig") public abstract Builder rewardConfig(SingleReinforcementTuningRewardConfig rewardConfig); @@ -72,7 +76,7 @@ private static Builder create() { /** * Setter for rewardConfig builder. * - *

rewardConfig: + *

rewardConfig: Single reward configuration. */ @CanIgnoreReturnValue public Builder rewardConfig(SingleReinforcementTuningRewardConfig.Builder rewardConfigBuilder) { @@ -92,7 +96,10 @@ public Builder clearRewardConfig() { /** * Setter for weight. * - *

weight: How much this single reward contributes to the total overall reward. + *

weight: How much this single reward contributes to the total overall reward. Total reward + * is a linear combination of single rewards with their corresponding weights, i.e., ``` + * total_reward = ( weight_a * reward_a + weight_b * reward_b + ... ) / (weight_a + weight_b + + * ...) ``` */ @JsonProperty("weight") public abstract Builder weight(Float weight); diff --git a/src/main/java/com/google/genai/types/ComputeTokensParameters.java b/src/main/java/com/google/genai/types/ComputeTokensParameters.java index c8bf85d8a86..5455bfc8a21 100644 --- a/src/main/java/com/google/genai/types/ComputeTokensParameters.java +++ b/src/main/java/com/google/genai/types/ComputeTokensParameters.java @@ -38,7 +38,7 @@ public abstract class ComputeTokensParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -73,7 +73,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/CountTokensParameters.java b/src/main/java/com/google/genai/types/CountTokensParameters.java index 4cc2ec68604..d8302ac50fb 100644 --- a/src/main/java/com/google/genai/types/CountTokensParameters.java +++ b/src/main/java/com/google/genai/types/CountTokensParameters.java @@ -38,7 +38,7 @@ public abstract class CountTokensParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -73,7 +73,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/CustomCodeExecutionSpec.java b/src/main/java/com/google/genai/types/CustomCodeExecutionSpec.java index 3ecf6aee07e..4fc011d1d23 100644 --- a/src/main/java/com/google/genai/types/CustomCodeExecutionSpec.java +++ b/src/main/java/com/google/genai/types/CustomCodeExecutionSpec.java @@ -32,8 +32,8 @@ public abstract class CustomCodeExecutionSpec extends JsonSerializable { /** * A string representing a user-defined function for evaluation. Expected user to define the - * following function, e.g.: def evaluate(instance: dict[str, Any]) -> float: Please include this - * function signature in the code snippet. Instance is the evaluation instance, any fields + * following function, e.g.: def evaluate(instance: dict[str, Any]) -> float: Please include + * this function signature in the code snippet. Instance is the evaluation instance, any fields * populated in the instance are available to the function as instance[field_name]. */ @JsonProperty("evaluationFunction") @@ -61,8 +61,8 @@ private static Builder create() { * Setter for evaluationFunction. * *

evaluationFunction: A string representing a user-defined function for evaluation. Expected - * user to define the following function, e.g.: def evaluate(instance: dict[str, Any]) -> float: - * Please include this function signature in the code snippet. Instance is the evaluation + * user to define the following function, e.g.: def evaluate(instance: dict[str, Any]) -> + * float: Please include this function signature in the code snippet. Instance is the evaluation * instance, any fields populated in the instance are available to the function as * instance[field_name]. */ diff --git a/src/main/java/com/google/genai/types/DatasetStats.java b/src/main/java/com/google/genai/types/DatasetStats.java index 2affb7e1f9f..905965486fd 100644 --- a/src/main/java/com/google/genai/types/DatasetStats.java +++ b/src/main/java/com/google/genai/types/DatasetStats.java @@ -77,6 +77,21 @@ public abstract class DatasetStats extends JsonSerializable { @JsonProperty("userOutputTokenDistribution") public abstract Optional userOutputTokenDistribution(); + /** Output only. Dataset distributions for the number of contents per example. */ + @JsonProperty("contentsPerExampleDistribution") + public abstract Optional contentsPerExampleDistribution(); + + /** + * Output only. Sample user dataset examples in the training dataset uri for Reinforcement Tuning. + */ + @JsonProperty("reinforcementTuningUserDatasetExamples") + public abstract Optional + reinforcementTuningUserDatasetExamples(); + + /** Output only. Number of billable tokens in the tuning dataset. */ + @JsonProperty("totalBillableTokenCount") + public abstract Optional totalBillableTokenCount(); + /** Instantiates a builder for DatasetStats. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -366,6 +381,92 @@ public Builder clearUserOutputTokenDistribution() { return userOutputTokenDistribution(Optional.empty()); } + /** + * Setter for contentsPerExampleDistribution. + * + *

contentsPerExampleDistribution: Output only. Dataset distributions for the number of + * contents per example. + */ + @JsonProperty("contentsPerExampleDistribution") + public abstract Builder contentsPerExampleDistribution( + DatasetDistribution contentsPerExampleDistribution); + + /** + * Setter for contentsPerExampleDistribution builder. + * + *

contentsPerExampleDistribution: Output only. Dataset distributions for the number of + * contents per example. + */ + @CanIgnoreReturnValue + public Builder contentsPerExampleDistribution( + DatasetDistribution.Builder contentsPerExampleDistributionBuilder) { + return contentsPerExampleDistribution(contentsPerExampleDistributionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder contentsPerExampleDistribution( + Optional contentsPerExampleDistribution); + + /** Clears the value of contentsPerExampleDistribution field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearContentsPerExampleDistribution() { + return contentsPerExampleDistribution(Optional.empty()); + } + + /** + * Setter for reinforcementTuningUserDatasetExamples. + * + *

reinforcementTuningUserDatasetExamples: Output only. Sample user dataset examples in the + * training dataset uri for Reinforcement Tuning. + */ + @JsonProperty("reinforcementTuningUserDatasetExamples") + public abstract Builder reinforcementTuningUserDatasetExamples( + ReinforcementTuningUserDatasetExamples reinforcementTuningUserDatasetExamples); + + /** + * Setter for reinforcementTuningUserDatasetExamples builder. + * + *

reinforcementTuningUserDatasetExamples: Output only. Sample user dataset examples in the + * training dataset uri for Reinforcement Tuning. + */ + @CanIgnoreReturnValue + public Builder reinforcementTuningUserDatasetExamples( + ReinforcementTuningUserDatasetExamples.Builder + reinforcementTuningUserDatasetExamplesBuilder) { + return reinforcementTuningUserDatasetExamples( + reinforcementTuningUserDatasetExamplesBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder reinforcementTuningUserDatasetExamples( + Optional reinforcementTuningUserDatasetExamples); + + /** Clears the value of reinforcementTuningUserDatasetExamples field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearReinforcementTuningUserDatasetExamples() { + return reinforcementTuningUserDatasetExamples(Optional.empty()); + } + + /** + * Setter for totalBillableTokenCount. + * + *

totalBillableTokenCount: Output only. Number of billable tokens in the tuning dataset. + */ + @JsonProperty("totalBillableTokenCount") + public abstract Builder totalBillableTokenCount(Long totalBillableTokenCount); + + @ExcludeFromGeneratedCoverageReport + abstract Builder totalBillableTokenCount(Optional totalBillableTokenCount); + + /** Clears the value of totalBillableTokenCount field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTotalBillableTokenCount() { + return totalBillableTokenCount(Optional.empty()); + } + public abstract DatasetStats build(); } diff --git a/src/main/java/com/google/genai/types/DeleteModelResponse.java b/src/main/java/com/google/genai/types/DeleteModelResponse.java index be2077b9026..153eb37b726 100644 --- a/src/main/java/com/google/genai/types/DeleteModelResponse.java +++ b/src/main/java/com/google/genai/types/DeleteModelResponse.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = DeleteModelResponse.Builder.class) public abstract class DeleteModelResponse extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/Delivery.java b/src/main/java/com/google/genai/types/Delivery.java new file mode 100644 index 00000000000..77cb726dda9 --- /dev/null +++ b/src/main/java/com/google/genai/types/Delivery.java @@ -0,0 +1,111 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** Delivery mode for the generated content. */ +public class Delivery { + + /** Enum representing the known values for Delivery. */ + public enum Known { + /** Default value. This value is unused. */ + DELIVERY_UNSPECIFIED, + + /** Generated bytes are returned inline in the response. */ + INLINE, + + /** Generated content is stored and a URI is returned. */ + URI + } + + private Known deliveryEnum; + private final String value; + + @JsonCreator + public Delivery(String value) { + this.value = value; + for (Known deliveryEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(deliveryEnum.toString(), value)) { + this.deliveryEnum = deliveryEnum; + break; + } + } + if (this.deliveryEnum == null) { + this.deliveryEnum = Known.DELIVERY_UNSPECIFIED; + } + } + + public Delivery(Known knownValue) { + this.deliveryEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof Delivery)) { + return false; + } + + Delivery other = (Delivery) o; + + if (this.deliveryEnum != Known.DELIVERY_UNSPECIFIED + && other.deliveryEnum != Known.DELIVERY_UNSPECIFIED) { + return this.deliveryEnum == other.deliveryEnum; + } else if (this.deliveryEnum == Known.DELIVERY_UNSPECIFIED + && other.deliveryEnum == Known.DELIVERY_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.deliveryEnum != Known.DELIVERY_UNSPECIFIED) { + return this.deliveryEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.deliveryEnum; + } +} diff --git a/src/main/java/com/google/genai/types/EmbedContentParameters.java b/src/main/java/com/google/genai/types/EmbedContentParameters.java index 882b97dede7..3ab041cadd7 100644 --- a/src/main/java/com/google/genai/types/EmbedContentParameters.java +++ b/src/main/java/com/google/genai/types/EmbedContentParameters.java @@ -38,7 +38,7 @@ public abstract class EmbedContentParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -73,7 +73,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/EmbedContentParametersPrivate.java b/src/main/java/com/google/genai/types/EmbedContentParametersPrivate.java index 756e4356c5c..699b4d5713a 100644 --- a/src/main/java/com/google/genai/types/EmbedContentParametersPrivate.java +++ b/src/main/java/com/google/genai/types/EmbedContentParametersPrivate.java @@ -38,7 +38,7 @@ public abstract class EmbedContentParametersPrivate extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -83,7 +83,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/EmbeddingsBatchJobSource.java b/src/main/java/com/google/genai/types/EmbeddingsBatchJobSource.java index c7838f0a243..55d6326585c 100644 --- a/src/main/java/com/google/genai/types/EmbeddingsBatchJobSource.java +++ b/src/main/java/com/google/genai/types/EmbeddingsBatchJobSource.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = EmbeddingsBatchJobSource.Builder.class) public abstract class EmbeddingsBatchJobSource extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/EvaluationParserConfigCustomCodeParserConfig.java b/src/main/java/com/google/genai/types/EvaluationParserConfigCustomCodeParserConfig.java index f7705c96604..733de9d1230 100644 --- a/src/main/java/com/google/genai/types/EvaluationParserConfigCustomCodeParserConfig.java +++ b/src/main/java/com/google/genai/types/EvaluationParserConfigCustomCodeParserConfig.java @@ -37,7 +37,7 @@ public abstract class EvaluationParserConfigCustomCodeParserConfig extends JsonS * Required. Python function for parsing results. The function should be defined within this * string. The function takes a list of strings (LLM responses) and should return either a list of * dictionaries (for rubrics) or a single dictionary (for a metric result). Example function - * signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When + * signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When * parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. * Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, * "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The @@ -76,14 +76,15 @@ private static Builder create() { *

parsingFunction: Required. Python function for parsing results. The function should be * defined within this string. The function takes a list of strings (LLM responses) and should * return either a list of dictionaries (for rubrics) or a single dictionary (for a metric - * result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] - * | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary - * represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The - * response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": - * {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": - * "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. - * Example for a metric result: { "score": 0.8, "explanation": "The model followed most - * instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation + * result). Example function signature: def parse(responses: list[str]) -> list[dict[str, + * Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each + * dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": + * {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { + * "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", + * "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a + * MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed + * most instructions.", "rubric_verdicts": [...] } ... code for result extraction and + * aggregation */ @JsonProperty("parsingFunction") public abstract Builder parsingFunction(String parsingFunction); diff --git a/src/main/java/com/google/genai/types/FetchPredictOperationConfig.java b/src/main/java/com/google/genai/types/FetchPredictOperationConfig.java index d9720d77c2c..66d4bb0481f 100644 --- a/src/main/java/com/google/genai/types/FetchPredictOperationConfig.java +++ b/src/main/java/com/google/genai/types/FetchPredictOperationConfig.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = FetchPredictOperationConfig.Builder.class) public abstract class FetchPredictOperationConfig extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/FunctionDeclaration.java b/src/main/java/com/google/genai/types/FunctionDeclaration.java index 8048a062325..cca7a2e9ed0 100644 --- a/src/main/java/com/google/genai/types/FunctionDeclaration.java +++ b/src/main/java/com/google/genai/types/FunctionDeclaration.java @@ -97,9 +97,9 @@ public abstract class FunctionDeclaration extends JsonSerializable { public abstract Optional responseJsonSchema(); /** - * Optional. Specifies the function Behavior. Currently only non-blocking functions are supported. - * If not specified, the system keeps the current function call behavior. This field is currently - * only supported by the BidiGenerateContent method. + * Optional. Specifies the function Behavior. If not specified, the system keeps the current + * function call behavior. This field is currently only supported by the BidiGenerateContent + * method. */ @JsonProperty("behavior") public abstract Optional behavior(); @@ -278,9 +278,9 @@ public Builder clearResponseJsonSchema() { /** * Setter for behavior. * - *

behavior: Optional. Specifies the function Behavior. Currently only non-blocking functions - * are supported. If not specified, the system keeps the current function call behavior. This - * field is currently only supported by the BidiGenerateContent method. + *

behavior: Optional. Specifies the function Behavior. If not specified, the system keeps + * the current function call behavior. This field is currently only supported by the + * BidiGenerateContent method. */ @JsonProperty("behavior") public abstract Builder behavior(Behavior behavior); @@ -298,9 +298,9 @@ public Builder clearBehavior() { /** * Setter for behavior given a known enum. * - *

behavior: Optional. Specifies the function Behavior. Currently only non-blocking functions - * are supported. If not specified, the system keeps the current function call behavior. This - * field is currently only supported by the BidiGenerateContent method. + *

behavior: Optional. Specifies the function Behavior. If not specified, the system keeps + * the current function call behavior. This field is currently only supported by the + * BidiGenerateContent method. */ @CanIgnoreReturnValue public Builder behavior(Behavior.Known knownType) { @@ -310,9 +310,9 @@ public Builder behavior(Behavior.Known knownType) { /** * Setter for behavior given a string. * - *

behavior: Optional. Specifies the function Behavior. Currently only non-blocking functions - * are supported. If not specified, the system keeps the current function call behavior. This - * field is currently only supported by the BidiGenerateContent method. + *

behavior: Optional. Specifies the function Behavior. If not specified, the system keeps + * the current function call behavior. This field is currently only supported by the + * BidiGenerateContent method. */ @CanIgnoreReturnValue public Builder behavior(String behavior) { diff --git a/src/main/java/com/google/genai/types/GenerateContentConfig.java b/src/main/java/com/google/genai/types/GenerateContentConfig.java index 84fc4fa02c5..1ef4635f37d 100644 --- a/src/main/java/com/google/genai/types/GenerateContentConfig.java +++ b/src/main/java/com/google/genai/types/GenerateContentConfig.java @@ -35,7 +35,7 @@ * Optional model configuration parameters. * *

For more information, see `Content generation parameters - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters>`_. */ @AutoValue @JsonDeserialize(builder = GenerateContentConfig.Builder.class) diff --git a/src/main/java/com/google/genai/types/GenerateContentParameters.java b/src/main/java/com/google/genai/types/GenerateContentParameters.java index aabe08246ab..596ecf4d10c 100644 --- a/src/main/java/com/google/genai/types/GenerateContentParameters.java +++ b/src/main/java/com/google/genai/types/GenerateContentParameters.java @@ -38,7 +38,7 @@ public abstract class GenerateContentParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -73,7 +73,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/GenerateImagesParameters.java b/src/main/java/com/google/genai/types/GenerateImagesParameters.java index 0f8515d131f..913718aa6fe 100644 --- a/src/main/java/com/google/genai/types/GenerateImagesParameters.java +++ b/src/main/java/com/google/genai/types/GenerateImagesParameters.java @@ -34,7 +34,7 @@ public abstract class GenerateImagesParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -69,7 +69,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/GenerateVideosParameters.java b/src/main/java/com/google/genai/types/GenerateVideosParameters.java index 0fbc4d25459..7efc4734ced 100644 --- a/src/main/java/com/google/genai/types/GenerateVideosParameters.java +++ b/src/main/java/com/google/genai/types/GenerateVideosParameters.java @@ -34,7 +34,7 @@ public abstract class GenerateVideosParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -87,7 +87,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/GenerationConfig.java b/src/main/java/com/google/genai/types/GenerationConfig.java index 3ff624ff1dd..e35403c01a4 100644 --- a/src/main/java/com/google/genai/types/GenerationConfig.java +++ b/src/main/java/com/google/genai/types/GenerationConfig.java @@ -124,7 +124,7 @@ public abstract class GenerationConfig extends JsonSerializable { * Optional. The IANA standard MIME type of the response. The model will generate output that * conforms to this MIME type. Supported values include 'text/plain' (default) and * 'application/json'. The model needs to be prompted to output the appropriate response type, - * otherwise the behavior is undefined. + * otherwise the behavior is undefined. Deprecated: Use `response_format` instead. */ @JsonProperty("responseMimeType") public abstract Optional responseMimeType(); @@ -142,7 +142,8 @@ public abstract class GenerationConfig extends JsonSerializable { * conforms to a particular structure. This is useful for generating structured data such as JSON. * The schema is a subset of the [OpenAPI 3.0 schema * object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must - * also set the `response_mime_type` to `application/json`. + * also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` + * instead. */ @JsonProperty("responseSchema") public abstract Optional responseSchema(); @@ -216,6 +217,16 @@ public abstract class GenerationConfig extends JsonSerializable { @JsonProperty("enableEnhancedCivicAnswers") public abstract Optional enableEnhancedCivicAnswers(); + /** + * Optional. New response format field for the model to configure output formatting and delivery. + */ + @JsonProperty("responseFormat") + public abstract Optional> responseFormat(); + + /** Optional. Config for translation. This field is not supported in Vertex AI. */ + @JsonProperty("translationConfig") + public abstract Optional translationConfig(); + /** Instantiates a builder for GenerationConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -499,7 +510,8 @@ public Builder clearResponseLogprobs() { *

responseMimeType: Optional. The IANA standard MIME type of the response. The model will * generate output that conforms to this MIME type. Supported values include 'text/plain' * (default) and 'application/json'. The model needs to be prompted to output the appropriate - * response type, otherwise the behavior is undefined. + * response type, otherwise the behavior is undefined. Deprecated: Use `response_format` + * instead. */ @JsonProperty("responseMimeType") public abstract Builder responseMimeType(String responseMimeType); @@ -605,7 +617,8 @@ public Builder responseModalitiesFromString(List responseModalities) { * that the output conforms to a particular structure. This is useful for generating structured * data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema * object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must - * also set the `response_mime_type` to `application/json`. + * also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` + * instead. */ @JsonProperty("responseSchema") public abstract Builder responseSchema(Schema responseSchema); @@ -617,7 +630,8 @@ public Builder responseModalitiesFromString(List responseModalities) { * that the output conforms to a particular structure. This is useful for generating structured * data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema * object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must - * also set the `response_mime_type` to `application/json`. + * also set the `response_mime_type` to `application/json`. Deprecated: Use `response_format` + * instead. */ @CanIgnoreReturnValue public Builder responseSchema(Schema.Builder responseSchemaBuilder) { @@ -860,6 +874,80 @@ public Builder clearEnableEnhancedCivicAnswers() { return enableEnhancedCivicAnswers(Optional.empty()); } + /** + * Setter for responseFormat. + * + *

responseFormat: Optional. New response format field for the model to configure output + * formatting and delivery. + */ + @JsonProperty("responseFormat") + public abstract Builder responseFormat(List responseFormat); + + /** + * Setter for responseFormat. + * + *

responseFormat: Optional. New response format field for the model to configure output + * formatting and delivery. + */ + @CanIgnoreReturnValue + public Builder responseFormat(ResponseFormat... responseFormat) { + return responseFormat(Arrays.asList(responseFormat)); + } + + /** + * Setter for responseFormat builder. + * + *

responseFormat: Optional. New response format field for the model to configure output + * formatting and delivery. + */ + @CanIgnoreReturnValue + public Builder responseFormat(ResponseFormat.Builder... responseFormatBuilders) { + return responseFormat( + Arrays.asList(responseFormatBuilders).stream() + .map(ResponseFormat.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder responseFormat(Optional> responseFormat); + + /** Clears the value of responseFormat field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearResponseFormat() { + return responseFormat(Optional.empty()); + } + + /** + * Setter for translationConfig. + * + *

translationConfig: Optional. Config for translation. This field is not supported in Vertex + * AI. + */ + @JsonProperty("translationConfig") + public abstract Builder translationConfig(TranslationConfig translationConfig); + + /** + * Setter for translationConfig builder. + * + *

translationConfig: Optional. Config for translation. This field is not supported in Vertex + * AI. + */ + @CanIgnoreReturnValue + public Builder translationConfig(TranslationConfig.Builder translationConfigBuilder) { + return translationConfig(translationConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder translationConfig(Optional translationConfig); + + /** Clears the value of translationConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTranslationConfig() { + return translationConfig(Optional.empty()); + } + public abstract GenerationConfig build(); } diff --git a/src/main/java/com/google/genai/types/GetModelParameters.java b/src/main/java/com/google/genai/types/GetModelParameters.java index af917831044..c07a55c9217 100644 --- a/src/main/java/com/google/genai/types/GetModelParameters.java +++ b/src/main/java/com/google/genai/types/GetModelParameters.java @@ -27,7 +27,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @InternalApi @JsonDeserialize(builder = GetModelParameters.Builder.class) diff --git a/src/main/java/com/google/genai/types/GetOperationConfig.java b/src/main/java/com/google/genai/types/GetOperationConfig.java index ecd2dbee548..039d5055d48 100644 --- a/src/main/java/com/google/genai/types/GetOperationConfig.java +++ b/src/main/java/com/google/genai/types/GetOperationConfig.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = GetOperationConfig.Builder.class) public abstract class GetOperationConfig extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/GroundingMetadata.java b/src/main/java/com/google/genai/types/GroundingMetadata.java index ac7a6582b58..5e9fe0d8b4a 100644 --- a/src/main/java/com/google/genai/types/GroundingMetadata.java +++ b/src/main/java/com/google/genai/types/GroundingMetadata.java @@ -66,7 +66,9 @@ public abstract class GroundingMetadata extends JsonSerializable { public abstract Optional> webSearchQueries(); /** - * Optional. Output only. A token that can be used to render a Google Maps widget with the + * Optional. Output only. Deprecated: The Google Maps contextual widget behavior in Grounding with + * Google Maps is being deprecated; this field is planned for removal and will no longer be + * populated once removed. A token that can be used to render a Google Maps widget with the * contextual data. This field is populated only when the grounding source is Google Maps. */ @JsonProperty("googleMapsWidgetContextToken") @@ -313,9 +315,11 @@ public Builder clearWebSearchQueries() { /** * Setter for googleMapsWidgetContextToken. * - *

googleMapsWidgetContextToken: Optional. Output only. A token that can be used to render a - * Google Maps widget with the contextual data. This field is populated only when the grounding - * source is Google Maps. + *

googleMapsWidgetContextToken: Optional. Output only. Deprecated: The Google Maps + * contextual widget behavior in Grounding with Google Maps is being deprecated; this field is + * planned for removal and will no longer be populated once removed. A token that can be used to + * render a Google Maps widget with the contextual data. This field is populated only when the + * grounding source is Google Maps. */ @JsonProperty("googleMapsWidgetContextToken") public abstract Builder googleMapsWidgetContextToken(String googleMapsWidgetContextToken); diff --git a/src/main/java/com/google/genai/types/ImageResponseFormat.java b/src/main/java/com/google/genai/types/ImageResponseFormat.java new file mode 100644 index 00000000000..4c6a07a8b8a --- /dev/null +++ b/src/main/java/com/google/genai/types/ImageResponseFormat.java @@ -0,0 +1,207 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Configuration for image-specific output formatting. */ +@AutoValue +@JsonDeserialize(builder = ImageResponseFormat.Builder.class) +public abstract class ImageResponseFormat extends JsonSerializable { + /** Optional. The aspect ratio for the image output. */ + @JsonProperty("aspectRatio") + public abstract Optional aspectRatio(); + + /** Optional. Delivery mode for the generated content. */ + @JsonProperty("delivery") + public abstract Optional delivery(); + + /** Optional. The size of the image output. */ + @JsonProperty("imageSize") + public abstract Optional imageSize(); + + /** Optional. The MIME type of the image output. */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** Instantiates a builder for ImageResponseFormat. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ImageResponseFormat.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ImageResponseFormat. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `ImageResponseFormat.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_ImageResponseFormat.Builder(); + } + + /** + * Setter for aspectRatio. + * + *

aspectRatio: Optional. The aspect ratio for the image output. + */ + @JsonProperty("aspectRatio") + public abstract Builder aspectRatio(AspectRatio aspectRatio); + + @ExcludeFromGeneratedCoverageReport + abstract Builder aspectRatio(Optional aspectRatio); + + /** Clears the value of aspectRatio field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAspectRatio() { + return aspectRatio(Optional.empty()); + } + + /** + * Setter for aspectRatio given a known enum. + * + *

aspectRatio: Optional. The aspect ratio for the image output. + */ + @CanIgnoreReturnValue + public Builder aspectRatio(AspectRatio.Known knownType) { + return aspectRatio(new AspectRatio(knownType)); + } + + /** + * Setter for aspectRatio given a string. + * + *

aspectRatio: Optional. The aspect ratio for the image output. + */ + @CanIgnoreReturnValue + public Builder aspectRatio(String aspectRatio) { + return aspectRatio(new AspectRatio(aspectRatio)); + } + + /** + * Setter for delivery. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @JsonProperty("delivery") + public abstract Builder delivery(Delivery delivery); + + @ExcludeFromGeneratedCoverageReport + abstract Builder delivery(Optional delivery); + + /** Clears the value of delivery field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDelivery() { + return delivery(Optional.empty()); + } + + /** + * Setter for delivery given a known enum. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(Delivery.Known knownType) { + return delivery(new Delivery(knownType)); + } + + /** + * Setter for delivery given a string. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(String delivery) { + return delivery(new Delivery(delivery)); + } + + /** + * Setter for imageSize. + * + *

imageSize: Optional. The size of the image output. + */ + @JsonProperty("imageSize") + public abstract Builder imageSize(ImageSize imageSize); + + @ExcludeFromGeneratedCoverageReport + abstract Builder imageSize(Optional imageSize); + + /** Clears the value of imageSize field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearImageSize() { + return imageSize(Optional.empty()); + } + + /** + * Setter for imageSize given a known enum. + * + *

imageSize: Optional. The size of the image output. + */ + @CanIgnoreReturnValue + public Builder imageSize(ImageSize.Known knownType) { + return imageSize(new ImageSize(knownType)); + } + + /** + * Setter for imageSize given a string. + * + *

imageSize: Optional. The size of the image output. + */ + @CanIgnoreReturnValue + public Builder imageSize(String imageSize) { + return imageSize(new ImageSize(imageSize)); + } + + /** + * Setter for mimeType. + * + *

mimeType: Optional. The MIME type of the image output. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder mimeType(Optional mimeType); + + /** Clears the value of mimeType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMimeType() { + return mimeType(Optional.empty()); + } + + public abstract ImageResponseFormat build(); + } + + /** Deserializes a JSON string to a ImageResponseFormat object. */ + @ExcludeFromGeneratedCoverageReport + public static ImageResponseFormat fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ImageResponseFormat.class); + } +} diff --git a/src/main/java/com/google/genai/types/ImageSize.java b/src/main/java/com/google/genai/types/ImageSize.java new file mode 100644 index 00000000000..c1b123a23ce --- /dev/null +++ b/src/main/java/com/google/genai/types/ImageSize.java @@ -0,0 +1,117 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** The size of the image output. */ +public class ImageSize { + + /** Enum representing the known values for ImageSize. */ + public enum Known { + /** Default value. This value is unused. */ + IMAGE_SIZE_UNSPECIFIED, + + /** 512px image size. */ + IMAGE_SIZE_FIVE_TWELVE, + + /** 1K image size. */ + IMAGE_SIZE_ONE_K, + + /** 2K image size. */ + IMAGE_SIZE_TWO_K, + + /** 4K image size. */ + IMAGE_SIZE_FOUR_K + } + + private Known imageSizeEnum; + private final String value; + + @JsonCreator + public ImageSize(String value) { + this.value = value; + for (Known imageSizeEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(imageSizeEnum.toString(), value)) { + this.imageSizeEnum = imageSizeEnum; + break; + } + } + if (this.imageSizeEnum == null) { + this.imageSizeEnum = Known.IMAGE_SIZE_UNSPECIFIED; + } + } + + public ImageSize(Known knownValue) { + this.imageSizeEnum = knownValue; + this.value = knownValue.toString(); + } + + @ExcludeFromGeneratedCoverageReport + @Override + @JsonValue + public String toString() { + return this.value; + } + + @ExcludeFromGeneratedCoverageReport + @SuppressWarnings("PatternMatchingInstanceof") + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null) { + return false; + } + + if (!(o instanceof ImageSize)) { + return false; + } + + ImageSize other = (ImageSize) o; + + if (this.imageSizeEnum != Known.IMAGE_SIZE_UNSPECIFIED + && other.imageSizeEnum != Known.IMAGE_SIZE_UNSPECIFIED) { + return this.imageSizeEnum == other.imageSizeEnum; + } else if (this.imageSizeEnum == Known.IMAGE_SIZE_UNSPECIFIED + && other.imageSizeEnum == Known.IMAGE_SIZE_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.imageSizeEnum != Known.IMAGE_SIZE_UNSPECIFIED) { + return this.imageSizeEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.imageSizeEnum; + } +} diff --git a/src/main/java/com/google/genai/types/InlinedRequest.java b/src/main/java/com/google/genai/types/InlinedRequest.java index 72d47ac9412..a6d5c37e17a 100644 --- a/src/main/java/com/google/genai/types/InlinedRequest.java +++ b/src/main/java/com/google/genai/types/InlinedRequest.java @@ -37,7 +37,7 @@ public abstract class InlinedRequest extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -76,7 +76,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/ListCachedContentsResponse.java b/src/main/java/com/google/genai/types/ListCachedContentsResponse.java index b1ec8455a71..760252358a3 100644 --- a/src/main/java/com/google/genai/types/ListCachedContentsResponse.java +++ b/src/main/java/com/google/genai/types/ListCachedContentsResponse.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = ListCachedContentsResponse.Builder.class) public abstract class ListCachedContentsResponse extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/ListModelsConfig.java b/src/main/java/com/google/genai/types/ListModelsConfig.java index 60c0e6415a1..1b9f4f351d0 100644 --- a/src/main/java/com/google/genai/types/ListModelsConfig.java +++ b/src/main/java/com/google/genai/types/ListModelsConfig.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = ListModelsConfig.Builder.class) public abstract class ListModelsConfig extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/ListModelsParameters.java b/src/main/java/com/google/genai/types/ListModelsParameters.java index 6fdbc90c257..b7b15872e63 100644 --- a/src/main/java/com/google/genai/types/ListModelsParameters.java +++ b/src/main/java/com/google/genai/types/ListModelsParameters.java @@ -27,7 +27,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @InternalApi @JsonDeserialize(builder = ListModelsParameters.Builder.class) diff --git a/src/main/java/com/google/genai/types/ListModelsResponse.java b/src/main/java/com/google/genai/types/ListModelsResponse.java index 5c33b224bd8..05803e7c4a9 100644 --- a/src/main/java/com/google/genai/types/ListModelsResponse.java +++ b/src/main/java/com/google/genai/types/ListModelsResponse.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = ListModelsResponse.Builder.class) public abstract class ListModelsResponse extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/LiveConnectConstraints.java b/src/main/java/com/google/genai/types/LiveConnectConstraints.java index df6ad0d5afb..3186e6dea5d 100644 --- a/src/main/java/com/google/genai/types/LiveConnectConstraints.java +++ b/src/main/java/com/google/genai/types/LiveConnectConstraints.java @@ -32,7 +32,7 @@ public abstract class LiveConnectConstraints extends JsonSerializable { /** * ID of the model to configure in the ephemeral token for Live API. For a list of models, see - * `Gemini models `. + * `Gemini models <https://ai.google.dev/gemini-api/docs/models>`. */ @JsonProperty("model") public abstract Optional model(); @@ -63,7 +63,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to configure in the ephemeral token for Live API. For a list of - * models, see `Gemini models `. + * models, see `Gemini models <https://ai.google.dev/gemini-api/docs/models>`. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/LiveConnectParameters.java b/src/main/java/com/google/genai/types/LiveConnectParameters.java index b4596250f90..037bb44af97 100644 --- a/src/main/java/com/google/genai/types/LiveConnectParameters.java +++ b/src/main/java/com/google/genai/types/LiveConnectParameters.java @@ -32,7 +32,7 @@ public abstract class LiveConnectParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -63,7 +63,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/LiveServerContent.java b/src/main/java/com/google/genai/types/LiveServerContent.java index 47de2d15860..02b4913cd3d 100644 --- a/src/main/java/com/google/genai/types/LiveServerContent.java +++ b/src/main/java/com/google/genai/types/LiveServerContent.java @@ -62,10 +62,10 @@ public abstract class LiveServerContent extends JsonSerializable { /** * If true, indicates that the model is done generating. When model is interrupted while * generating there will be no generation_complete message in interrupted turn, it will go through - * interrupted > turn_complete. When model assumes realtime playback there will be delay between - * generation_complete and turn_complete that is caused by model waiting for playback to finish. - * If true, indicates that the model has finished generating all content. This is a signal to the - * client that it can stop sending messages. + * interrupted > turn_complete. When model assumes realtime playback there will be delay + * between generation_complete and turn_complete that is caused by model waiting for playback to + * finish. If true, indicates that the model has finished generating all content. This is a signal + * to the client that it can stop sending messages. */ @JsonProperty("generationComplete") public abstract Optional generationComplete(); @@ -224,7 +224,7 @@ public Builder clearGroundingMetadata() { * *

generationComplete: If true, indicates that the model is done generating. When model is * interrupted while generating there will be no generation_complete message in interrupted - * turn, it will go through interrupted > turn_complete. When model assumes realtime playback + * turn, it will go through interrupted > turn_complete. When model assumes realtime playback * there will be delay between generation_complete and turn_complete that is caused by model * waiting for playback to finish. If true, indicates that the model has finished generating all * content. This is a signal to the client that it can stop sending messages. diff --git a/src/main/java/com/google/genai/types/MatchOperation.java b/src/main/java/com/google/genai/types/MatchOperation.java index ea8141aff12..2bd09336a8d 100644 --- a/src/main/java/com/google/genai/types/MatchOperation.java +++ b/src/main/java/com/google/genai/types/MatchOperation.java @@ -23,21 +23,25 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** Match operation to use for evaluation. */ +/** Match operation to use for evaluating rewards. This enum is not supported in Gemini API. */ public class MatchOperation { /** Enum representing the known values for MatchOperation. */ public enum Known { - /** Default value. This value is unused. */ + /** Default value. A user error will be returned if not set. */ MATCH_OPERATION_UNSPECIFIED, - /** Equivalent to GoogleSQL `REGEX_CONTAINS(target, expression)`. */ + /** + * Equivalent to + * [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains) + * `REGEX_CONTAINS(target, expression)`. + */ REGEX_CONTAINS, - /** `expression` is a substring of target. */ + /** The match operation returns `true` if expression is a substring of the target. */ PARTIAL_MATCH, - /** `expression` is an exact match of target. */ + /** The match operation returns `true` expression is an exact match of the target. */ EXACT_MATCH } diff --git a/src/main/java/com/google/genai/types/RecontextImageParameters.java b/src/main/java/com/google/genai/types/RecontextImageParameters.java index d32f137f8ea..6bb6f7fb566 100644 --- a/src/main/java/com/google/genai/types/RecontextImageParameters.java +++ b/src/main/java/com/google/genai/types/RecontextImageParameters.java @@ -34,7 +34,7 @@ public abstract class RecontextImageParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -69,7 +69,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java index cc7f60427f6..d125808ab4a 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java @@ -35,24 +35,30 @@ public abstract class ReinforcementTuningAutoraterScorer extends JsonSerializabl public abstract Optional autoraterConfig(); /** - * Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each - * wrapped in double curly braces) into the autorater prompt. + * The prompt for an autorater to scorer the parsed sample response. This field supports the + * following placeholders that will be replaced before scoring: - {{prompt}} - {{response}} - + * {{system_instruction}} - {{references.key}} */ @JsonProperty("autoraterPrompt") public abstract Optional autoraterPrompt(); - /** Parses autorater returned response. */ + /** + * Parses autorater returned response for scoring. For example, if the autorater response has + * reward stored in the `2.0` block, defining a parsing response config using regex `".*(.*?)"` + * will return a score `"2.0"`. + */ @JsonProperty("autoraterResponseParseConfig") public abstract Optional autoraterResponseParseConfig(); /** - * Scores autorater responses by directly converting parsed autorater response to float reward. + * Scores autorater responses by directly converting parsed autorater response to a float reward. + * Note: Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. */ @JsonProperty("parsedResponseConversionScorer") public abstract Optional parsedResponseConversionScorer(); - /** Scores autorater responses by using exact string match reward scorer. */ + /** Scores autorater responses by using string match reward scorer. */ @JsonProperty("exactMatchScorer") public abstract Optional exactMatchScorer(); @@ -108,8 +114,9 @@ public Builder clearAutoraterConfig() { /** * Setter for autoraterPrompt. * - *

autoraterPrompt: Allows substituting `prompt`, `response`, `system_instruction` and - * `references.reference` (each wrapped in double curly braces) into the autorater prompt. + *

autoraterPrompt: The prompt for an autorater to scorer the parsed sample response. This + * field supports the following placeholders that will be replaced before scoring: - {{prompt}} + * - {{response}} - {{system_instruction}} - {{references.key}} */ @JsonProperty("autoraterPrompt") public abstract Builder autoraterPrompt(String autoraterPrompt); @@ -127,7 +134,9 @@ public Builder clearAutoraterPrompt() { /** * Setter for autoraterResponseParseConfig. * - *

autoraterResponseParseConfig: Parses autorater returned response. + *

autoraterResponseParseConfig: Parses autorater returned response for scoring. For example, + * if the autorater response has reward stored in the `2.0` block, defining a parsing response + * config using regex `".*(.*?)"` will return a score `"2.0"`. */ @JsonProperty("autoraterResponseParseConfig") public abstract Builder autoraterResponseParseConfig( @@ -136,7 +145,9 @@ public abstract Builder autoraterResponseParseConfig( /** * Setter for autoraterResponseParseConfig builder. * - *

autoraterResponseParseConfig: Parses autorater returned response. + *

autoraterResponseParseConfig: Parses autorater returned response for scoring. For example, + * if the autorater response has reward stored in the `2.0` block, defining a parsing response + * config using regex `".*(.*?)"` will return a score `"2.0"`. */ @CanIgnoreReturnValue public Builder autoraterResponseParseConfig( @@ -159,7 +170,8 @@ public Builder clearAutoraterResponseParseConfig() { * Setter for parsedResponseConversionScorer. * *

parsedResponseConversionScorer: Scores autorater responses by directly converting parsed - * autorater response to float reward. + * autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., + * `reward = max(min(reward, 1.0), -1.0)`. */ @JsonProperty("parsedResponseConversionScorer") public abstract Builder parsedResponseConversionScorer( @@ -170,7 +182,8 @@ public abstract Builder parsedResponseConversionScorer( * Setter for parsedResponseConversionScorer builder. * *

parsedResponseConversionScorer: Scores autorater responses by directly converting parsed - * autorater response to float reward. + * autorater response to a float reward. Note: Reward is clipped to be within `[-1, 1]`, i.e., + * `reward = max(min(reward, 1.0), -1.0)`. */ @CanIgnoreReturnValue public Builder parsedResponseConversionScorer( @@ -194,7 +207,7 @@ public Builder clearParsedResponseConversionScorer() { /** * Setter for exactMatchScorer. * - *

exactMatchScorer: Scores autorater responses by using exact string match reward scorer. + *

exactMatchScorer: Scores autorater responses by using string match reward scorer. */ @JsonProperty("exactMatchScorer") public abstract Builder exactMatchScorer( @@ -203,7 +216,7 @@ public abstract Builder exactMatchScorer( /** * Setter for exactMatchScorer builder. * - *

exactMatchScorer: Scores autorater responses by using exact string match reward scorer. + *

exactMatchScorer: Scores autorater responses by using string match reward scorer. */ @CanIgnoreReturnValue public Builder exactMatchScorer( diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java index f2943ed801c..1e5042989fb 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java @@ -26,21 +26,33 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Scores autorater responses by using exact string match reward scorer. */ +/** + * Scores autorater responses by using exact string match reward scorer. This data type is not + * supported in Gemini API. + */ @AutoValue @JsonDeserialize(builder = ReinforcementTuningAutoraterScorerExactMatchScorer.Builder.class) public abstract class ReinforcementTuningAutoraterScorerExactMatchScorer extends JsonSerializable { - /** Assigns this reward score if parsed response string equals the expression. */ + /** Assigns this reward score if the parsed response string equals the expression. */ @JsonProperty("correctAnswerReward") public abstract Optional correctAnswerReward(); - /** Assigns this reward score if parsed reward value does not equal the expression. */ + /** Assigns this reward score if the parsed reward value does not equal the expression. */ @JsonProperty("wrongAnswerReward") public abstract Optional wrongAnswerReward(); /** - * The string expression to match against. Supports substitution in the format of - * `references.reference` (wrapped in double curly braces) before matching. No regex support. + * The string expression to match against for scoring. This field supports placeholders in the + * format of {{references.key}} that will be replaced before matching. Regex is not supported for + * this expression. For example, users can define an ExactMatchScorer as follows: { + * "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": + * "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater + * response, if the prompt references in the training/validation dataset has the following fields: + * ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The answer is + * Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: ``` { + * "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the + * *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, otherwise + * the reward is `-1.0`. */ @JsonProperty("expression") public abstract Optional expression(); @@ -69,7 +81,7 @@ private static Builder create() { /** * Setter for correctAnswerReward. * - *

correctAnswerReward: Assigns this reward score if parsed response string equals the + *

correctAnswerReward: Assigns this reward score if the parsed response string equals the * expression. */ @JsonProperty("correctAnswerReward") @@ -88,7 +100,7 @@ public Builder clearCorrectAnswerReward() { /** * Setter for wrongAnswerReward. * - *

wrongAnswerReward: Assigns this reward score if parsed reward value does not equal the + *

wrongAnswerReward: Assigns this reward score if the parsed reward value does not equal the * expression. */ @JsonProperty("wrongAnswerReward") @@ -107,8 +119,17 @@ public Builder clearWrongAnswerReward() { /** * Setter for expression. * - *

expression: The string expression to match against. Supports substitution in the format of - * `references.reference` (wrapped in double curly braces) before matching. No regex support. + *

expression: The string expression to match against for scoring. This field supports + * placeholders in the format of {{references.key}} that will be replaced before matching. Regex + * is not supported for this expression. For example, users can define an ExactMatchScorer as + * follows: { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": + * "{{references.concise_answer}}" } When evaluating the reward for each parsed autorater + * response, if the prompt references in the training/validation dataset has the following + * fields: ``` { "example": ..., "references": { "concise_ansser": "Yes", "verbose_answer": "The + * answer is Yes" } } ``` The above ExactMatchScorer will be replaced as follows for scoring: + * ``` { "correctAnswerReward": 1.0, "wrongAnswerReward": -1.0, "expression": "Yes" } ``` If the + * *parsed* autorater response is equal to the string `"Yes"`, then the reward is `1.0`, + * otherwise the reward is `-1.0`. */ @JsonProperty("expression") public abstract Builder expression(String expression); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java index 722853eedec..99c5c09acc5 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java @@ -24,8 +24,9 @@ import com.google.genai.JsonSerializable; /** - * Scores responses by directly converting parsed autorater response to float reward (reward is - * clipped to be within [-1, 1]). + * Scores responses by directly converting the parsed autorater response to a float reward. Note: + * Reward is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This data + * type is not supported in Gemini API. */ @AutoValue @JsonDeserialize( diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java index d979f326d27..9d15045ddf9 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java @@ -26,14 +26,39 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Scores parsed responses by calling a Cloud Run service. */ +/** + * ReinforcementTuningCloudRunRewardScorer allows users to implement a reward function through GCP + * Cloud Run. Comparing with ReinforcementTuningCodeExecutionRewardScorer that runs in a Sandbox and + * has no internet access, Cloud Run reward scorer is fully controlled by users. The Cloud Run + * service should implement the following HTTP API: HTTP method: `POST` HTTP request body: ``` { + * "example": ReinforcementTuningExample, "response": Content, "metadata": { "step": int + * "tuning_job_id": int64 } } ``` * `example` is a ReinforcementTuningExample in ProtoJSON format, + * (i.e., the format is the same as as one line in the training/validation dataset except that the + * keys must be in camel case). System instructions (i.e., `example.get("systemInstruction")`) and + * references (i.e., `example.get("references")`) are also included in the `example` provided that + * they are set in the training/validation dataset. * `response` is a Content in ProtoJSON format + * (i.e., keys must be in camel case), which is the same as the Online Prediction response for + * Gemini models. HTTP response body: { "reward": float, "user_requested_aux_info": str // Optional + * } where the field "user_requested_aux_info" is any (optional) string provided by users for + * assisting debugging. It's in snake case. This field is mostly useful when calling the + * GenAiTuningService.ValidateReinforcementTuningReward API, where the proto field (not Cloud Run + * HTTP response body) userRequestedAuxInfo will be populated if the Cloud Run reward function sets + * this field in the HTTP response. The following are examples for the HTTP request and response + * body. Example HTTP request body: ``` { "example": { "contents": [ { "role": "user", "parts": [ { + * "text": "What is the capital of France?" } ] } ], "references": { "answer": "Paris" } }, + * "response": { "parts": [ { "text": "London" } ] }, "metadata": { "step": 1, "tuning_job_id": + * 123456789 } } ``` Example HTTP response body: ``` { "reward": -1.0 } ``` Note: Reward output by + * Cloud Run reward function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, + * 1.0), -1.0)`. This data type is not supported in Gemini API. + */ @AutoValue @JsonDeserialize(builder = ReinforcementTuningCloudRunRewardScorer.Builder.class) public abstract class ReinforcementTuningCloudRunRewardScorer extends JsonSerializable { /** - * URI of the Cloud Run service that will be used to compute the reward. The Vertex AI Secure Fine - * Tuning Service Agent (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, - * where `PROJECT_NUMBER` is the numeric project number) must be granted the permission (e.g. by + * URI of the Cloud Run service that will be used to compute the reward. The [Vertex AI Secure + * Fine Tuning Service + * Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) + * (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. by * granting `roles/run.invoker` in IAM) to invoke the Cloud Run service. */ @JsonProperty("cloudRunUri") @@ -64,10 +89,10 @@ private static Builder create() { * Setter for cloudRunUri. * *

cloudRunUri: URI of the Cloud Run service that will be used to compute the reward. The - * Vertex AI Secure Fine Tuning Service Agent - * (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, where `PROJECT_NUMBER` - * is the numeric project number) must be granted the permission (e.g. by granting - * `roles/run.invoker` in IAM) to invoke the Cloud Run service. + * [Vertex AI Secure Fine Tuning Service + * Agent](https://docs.cloud.google.com/iam/docs/service-agents#vertex-ai-secure-fine-tuning-service-agent) + * (`service-@gcp-sa-vertex-tune.iam.gserviceaccount.com`) must be granted the permission (e.g. + * by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service. */ @JsonProperty("cloudRunUri") public abstract Builder cloudRunUri(String cloudRunUri); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java index 348de2a40df..0837c4de176 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java @@ -26,13 +26,30 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Scores parsed responses for code execution use cases. */ +/** + * ReinforcementTuningCodeExecutionRewardScorer allows users to implement a function to evaluate + * rewards for the sample response. The function signature is as follows: ``` def evaluate(example: + * dict[str, Any], response: dict[str, Any]) -> float: ... ``` `example` is a + * ReinforcementTuningExample in ProtoJSON format, (i.e., the format is the same as as one line in + * the training/validation dataset except that the keys must be in camel case). System instructions + * (i.e., `example.get("systemInstruction")`) and references (i.e., `example.get("references")`) are + * also included in the `example` provided that they are set in the training/validation dataset. + * `response` is a Content in ProtoJSON format (i.e., keys must be in camel case), which is the same + * as the Online Prediction response for Gemini models. Note: Reward output by the `evaluate` + * function is clipped to be within `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. This + * data type is not supported in Gemini API. + */ @AutoValue @JsonDeserialize(builder = ReinforcementTuningCodeExecutionRewardScorer.Builder.class) public abstract class ReinforcementTuningCodeExecutionRewardScorer extends JsonSerializable { /** - * Example python code snippet which assigns reward of 1 to answer matching user provided - * reference answer in per prompt references map. + * The python code snippet as a string for evaluating rewards. The following is an example python + * code snippet that returns a reward `1.0` for a parsed response matching the user-provided + * reference answer in per prompt references map. ``` def evaluate(example, response) -> float: + * response_str = response.get("parts", [])0 references = example.get("references", {}) if + * response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` Note: Reward + * output by the evaluate function is clipped to be within `[-1, 1]`, i.e., `reward = + * max(min(reward, 1.0), -1.0)`. */ @JsonProperty("pythonCodeSnippet") public abstract Optional pythonCodeSnippet(); @@ -61,8 +78,13 @@ private static Builder create() { /** * Setter for pythonCodeSnippet. * - *

pythonCodeSnippet: Example python code snippet which assigns reward of 1 to answer - * matching user provided reference answer in per prompt references map. + *

pythonCodeSnippet: The python code snippet as a string for evaluating rewards. The + * following is an example python code snippet that returns a reward `1.0` for a parsed response + * matching the user-provided reference answer in per prompt references map. ``` def + * evaluate(example, response) -> float: response_str = response.get("parts", [])0 references + * = example.get("references", {}) if response_str == references.get("concise_answer"): return + * 1.0 return -1.0 ``` Note: Reward output by the evaluate function is clipped to be within + * `[-1, 1]`, i.e., `reward = max(min(reward, 1.0), -1.0)`. */ @JsonProperty("pythonCodeSnippet") public abstract Builder pythonCodeSnippet(String pythonCodeSnippet); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningExample.java b/src/main/java/com/google/genai/types/ReinforcementTuningExample.java new file mode 100644 index 00000000000..87015670287 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningExample.java @@ -0,0 +1,188 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * User-facing format for Gemini Reinforcement Tuning examples on Vertex. This data type is not + * supported in Gemini API. + */ +@AutoValue +@JsonDeserialize(builder = ReinforcementTuningExample.Builder.class) +public abstract class ReinforcementTuningExample extends JsonSerializable { + /** Multi-turn contents that represents the Prompt. */ + @JsonProperty("contents") + public abstract Optional> contents(); + + /** + * References for the given prompt. The key is the name of the reference, and the value is the + * reference itself. Users can use this field together with the reward configurations to calculate + * rewards for reinforcement tuning. For example, users can set the following references: ``` { + * "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } ``` Then in a + * ReinforcementTuningCodeExecutionRewardScorer reward function config, for example, they can + * define a python code snippet as follows: ``` def evaluate(example, response) -> float: + * response_str = response.get("parts", [])0 references = example.get("references", {}) if + * response_str == references.get("concise_answer"): return 1.0 return -1.0 ``` In this case, + * references can serve the purpose of holding the ground truth of this example in the + * training/validation dataset. + */ + @JsonProperty("references") + public abstract Optional> references(); + + /** Corresponds to system_instruction in user-facing GenerateContentRequest. */ + @JsonProperty("systemInstruction") + public abstract Optional systemInstruction(); + + /** Instantiates a builder for ReinforcementTuningExample. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningExample.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningExample. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `ReinforcementTuningExample.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningExample.Builder(); + } + + /** + * Setter for contents. + * + *

contents: Multi-turn contents that represents the Prompt. + */ + @JsonProperty("contents") + public abstract Builder contents(List contents); + + /** + * Setter for contents. + * + *

contents: Multi-turn contents that represents the Prompt. + */ + @CanIgnoreReturnValue + public Builder contents(Content... contents) { + return contents(Arrays.asList(contents)); + } + + /** + * Setter for contents builder. + * + *

contents: Multi-turn contents that represents the Prompt. + */ + @CanIgnoreReturnValue + public Builder contents(Content.Builder... contentsBuilders) { + return contents( + Arrays.asList(contentsBuilders).stream() + .map(Content.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder contents(Optional> contents); + + /** Clears the value of contents field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearContents() { + return contents(Optional.empty()); + } + + /** + * Setter for references. + * + *

references: References for the given prompt. The key is the name of the reference, and the + * value is the reference itself. Users can use this field together with the reward + * configurations to calculate rewards for reinforcement tuning. For example, users can set the + * following references: ``` { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } + * ``` Then in a ReinforcementTuningCodeExecutionRewardScorer reward function config, for + * example, they can define a python code snippet as follows: ``` def evaluate(example, + * response) -> float: response_str = response.get("parts", [])0 references = + * example.get("references", {}) if response_str == references.get("concise_answer"): return 1.0 + * return -1.0 ``` In this case, references can serve the purpose of holding the ground truth of + * this example in the training/validation dataset. + */ + @JsonProperty("references") + public abstract Builder references(Map references); + + @ExcludeFromGeneratedCoverageReport + abstract Builder references(Optional> references); + + /** Clears the value of references field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearReferences() { + return references(Optional.empty()); + } + + /** + * Setter for systemInstruction. + * + *

systemInstruction: Corresponds to system_instruction in user-facing + * GenerateContentRequest. + */ + @JsonProperty("systemInstruction") + public abstract Builder systemInstruction(Content systemInstruction); + + /** + * Setter for systemInstruction builder. + * + *

systemInstruction: Corresponds to system_instruction in user-facing + * GenerateContentRequest. + */ + @CanIgnoreReturnValue + public Builder systemInstruction(Content.Builder systemInstructionBuilder) { + return systemInstruction(systemInstructionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder systemInstruction(Optional systemInstruction); + + /** Clears the value of systemInstruction field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSystemInstruction() { + return systemInstruction(Optional.empty()); + } + + public abstract ReinforcementTuningExample build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningExample object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningExample fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ReinforcementTuningExample.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java b/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java index e8da39e72c3..e94f49c6cc9 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java @@ -32,7 +32,7 @@ @InternalApi @JsonDeserialize(builder = ReinforcementTuningHyperParameters.Builder.class) public abstract class ReinforcementTuningHyperParameters extends JsonSerializable { - /** Number of training epochs for the tuning job. */ + /** Optional. Number of training epoches for the tuning job. */ @JsonProperty("epochCount") public abstract Optional epochCount(); @@ -40,43 +40,56 @@ public abstract class ReinforcementTuningHyperParameters extends JsonSerializabl @JsonProperty("learningRateMultiplier") public abstract Optional learningRateMultiplier(); - /** Adapter size for Reinforcement Tuning. */ + /** Optional. Adapter size for Reinforcement Tuning. */ @JsonProperty("adapterSize") public abstract Optional adapterSize(); - /** Number of different responses to generate per prompt during tuning. */ + /** Optional. Number of different responses to generate per prompt during tuning. */ @JsonProperty("samplesPerPrompt") public abstract Optional samplesPerPrompt(); /** - * Batch size for the tuning job. How many prompts to process at a train step. If not set, the - * batch size will be determined automatically. + * Optional. Batch size for the tuning job. How many prompts to process at a train step. If not + * set, the batch size will be determined automatically. */ @JsonProperty("batchSize") public abstract Optional batchSize(); /** - * How often (in steps) to evaluate the tuning job during training. If not set, evaluation will - * run per epoch. + * Optional. How often at steps to evaluate the tuning job during training. If not set, evel will + * be run per epoch. `total_steps = epoch_count * samples_per_prompt / total_prompts_in_dataset` */ @JsonProperty("evaluateInterval") public abstract Optional evaluateInterval(); /** - * How often (in steps) to save checkpoints during training. If not set, one checkpoint per epoch - * will be saved. + * Optional. How often at steps to save checkpoints during training. If not set, one checkpoint + * per epoch will be set. ```total_steps = epoch_count * samples_per_prompt / + * total_prompts_in_dataset``` */ @JsonProperty("checkpointInterval") public abstract Optional checkpointInterval(); - /** The maximum number of tokens to generate per prompt. If not set, defaults to 32768. */ + /** Optional. The maximum number of tokens to generate per prompt. Default to 32768. */ @JsonProperty("maxOutputTokens") public abstract Optional maxOutputTokens(); - /** Indicates the maximum thinking depth. Use with earlier models shall result in error. */ + /** + * Indicates the maximum thinking depth during tuning. Starting from Gemini 3.5 models, the old + * thinking_budget will no longer be supported and will result in a user error if set. Instead, + * users should use the thinking_level parameter to control the maximum thinking depth. + */ @JsonProperty("thinkingLevel") public abstract Optional thinkingLevel(); + /** + * Optional. The thinking budget for the tuning job to optimize for (Gemini 2.5 only). * -1 means + * dynamic thinking * 0 means no thinking * > 0 means thinking budget in tokens If not set, + * default to -1 (dynamic thinking). + */ + @JsonProperty("thinkingBudget") + public abstract Optional thinkingBudget(); + /** Instantiates a builder for ReinforcementTuningHyperParameters. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -101,7 +114,7 @@ private static Builder create() { /** * Setter for epochCount. * - *

epochCount: Number of training epochs for the tuning job. + *

epochCount: Optional. Number of training epoches for the tuning job. */ @JsonProperty("epochCount") public abstract Builder epochCount(Long epochCount); @@ -137,7 +150,7 @@ public Builder clearLearningRateMultiplier() { /** * Setter for adapterSize. * - *

adapterSize: Adapter size for Reinforcement Tuning. + *

adapterSize: Optional. Adapter size for Reinforcement Tuning. */ @JsonProperty("adapterSize") public abstract Builder adapterSize(AdapterSize adapterSize); @@ -155,7 +168,7 @@ public Builder clearAdapterSize() { /** * Setter for adapterSize given a known enum. * - *

adapterSize: Adapter size for Reinforcement Tuning. + *

adapterSize: Optional. Adapter size for Reinforcement Tuning. */ @CanIgnoreReturnValue public Builder adapterSize(AdapterSize.Known knownType) { @@ -165,7 +178,7 @@ public Builder adapterSize(AdapterSize.Known knownType) { /** * Setter for adapterSize given a string. * - *

adapterSize: Adapter size for Reinforcement Tuning. + *

adapterSize: Optional. Adapter size for Reinforcement Tuning. */ @CanIgnoreReturnValue public Builder adapterSize(String adapterSize) { @@ -175,7 +188,8 @@ public Builder adapterSize(String adapterSize) { /** * Setter for samplesPerPrompt. * - *

samplesPerPrompt: Number of different responses to generate per prompt during tuning. + *

samplesPerPrompt: Optional. Number of different responses to generate per prompt during + * tuning. */ @JsonProperty("samplesPerPrompt") public abstract Builder samplesPerPrompt(Integer samplesPerPrompt); @@ -193,8 +207,8 @@ public Builder clearSamplesPerPrompt() { /** * Setter for batchSize. * - *

batchSize: Batch size for the tuning job. How many prompts to process at a train step. If - * not set, the batch size will be determined automatically. + *

batchSize: Optional. Batch size for the tuning job. How many prompts to process at a train + * step. If not set, the batch size will be determined automatically. */ @JsonProperty("batchSize") public abstract Builder batchSize(Integer batchSize); @@ -212,8 +226,9 @@ public Builder clearBatchSize() { /** * Setter for evaluateInterval. * - *

evaluateInterval: How often (in steps) to evaluate the tuning job during training. If not - * set, evaluation will run per epoch. + *

evaluateInterval: Optional. How often at steps to evaluate the tuning job during training. + * If not set, evel will be run per epoch. `total_steps = epoch_count * samples_per_prompt / + * total_prompts_in_dataset` */ @JsonProperty("evaluateInterval") public abstract Builder evaluateInterval(Integer evaluateInterval); @@ -231,8 +246,9 @@ public Builder clearEvaluateInterval() { /** * Setter for checkpointInterval. * - *

checkpointInterval: How often (in steps) to save checkpoints during training. If not set, - * one checkpoint per epoch will be saved. + *

checkpointInterval: Optional. How often at steps to save checkpoints during training. If + * not set, one checkpoint per epoch will be set. ```total_steps = epoch_count * + * samples_per_prompt / total_prompts_in_dataset``` */ @JsonProperty("checkpointInterval") public abstract Builder checkpointInterval(Integer checkpointInterval); @@ -250,8 +266,8 @@ public Builder clearCheckpointInterval() { /** * Setter for maxOutputTokens. * - *

maxOutputTokens: The maximum number of tokens to generate per prompt. If not set, defaults - * to 32768. + *

maxOutputTokens: Optional. The maximum number of tokens to generate per prompt. Default to + * 32768. */ @JsonProperty("maxOutputTokens") public abstract Builder maxOutputTokens(Integer maxOutputTokens); @@ -269,8 +285,10 @@ public Builder clearMaxOutputTokens() { /** * Setter for thinkingLevel. * - *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result - * in error. + *

thinkingLevel: Indicates the maximum thinking depth during tuning. Starting from Gemini + * 3.5 models, the old thinking_budget will no longer be supported and will result in a user + * error if set. Instead, users should use the thinking_level parameter to control the maximum + * thinking depth. */ @JsonProperty("thinkingLevel") public abstract Builder thinkingLevel(ReinforcementTuningThinkingLevel thinkingLevel); @@ -288,8 +306,10 @@ public Builder clearThinkingLevel() { /** * Setter for thinkingLevel given a known enum. * - *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result - * in error. + *

thinkingLevel: Indicates the maximum thinking depth during tuning. Starting from Gemini + * 3.5 models, the old thinking_budget will no longer be supported and will result in a user + * error if set. Instead, users should use the thinking_level parameter to control the maximum + * thinking depth. */ @CanIgnoreReturnValue public Builder thinkingLevel(ReinforcementTuningThinkingLevel.Known knownType) { @@ -299,14 +319,36 @@ public Builder thinkingLevel(ReinforcementTuningThinkingLevel.Known knownType) { /** * Setter for thinkingLevel given a string. * - *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result - * in error. + *

thinkingLevel: Indicates the maximum thinking depth during tuning. Starting from Gemini + * 3.5 models, the old thinking_budget will no longer be supported and will result in a user + * error if set. Instead, users should use the thinking_level parameter to control the maximum + * thinking depth. */ @CanIgnoreReturnValue public Builder thinkingLevel(String thinkingLevel) { return thinkingLevel(new ReinforcementTuningThinkingLevel(thinkingLevel)); } + /** + * Setter for thinkingBudget. + * + *

thinkingBudget: Optional. The thinking budget for the tuning job to optimize for (Gemini + * 2.5 only). * -1 means dynamic thinking * 0 means no thinking * > 0 means thinking budget + * in tokens If not set, default to -1 (dynamic thinking). + */ + @JsonProperty("thinkingBudget") + public abstract Builder thinkingBudget(Integer thinkingBudget); + + @ExcludeFromGeneratedCoverageReport + abstract Builder thinkingBudget(Optional thinkingBudget); + + /** Clears the value of thinkingBudget field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearThinkingBudget() { + return thinkingBudget(Optional.empty()); + } + public abstract ReinforcementTuningHyperParameters build(); } diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java b/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java index 00cd42c4e8b..fe2daec2cc6 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java @@ -26,17 +26,26 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Defines how to parse sample response for reinforcement tuning. */ +/** + * Defines how to parse sample response config for reinforcement tuning. The parsed response (i.e., + * substring) will be passed to the reward functions. For example, the input prompt might be: > + * "Perform step-by-step thoughts first to problem A, finally output answer in the <ans> + * </ans> block." The sample response from the model under tuning might look like: > + * "<ans>Yes</ans>" Here, users can define the following parse config: ``` { + * "parseType": "REGEX_EXTRACT", "regexExtractExpression": ".*(.*?)" } ``` The resulting parsed + * response would be `"Yes"` and will be passed to the reward functions for evaluating rewards. This + * data type is not supported in Gemini API. + */ @AutoValue @JsonDeserialize(builder = ReinforcementTuningParseResponseConfig.Builder.class) public abstract class ReinforcementTuningParseResponseConfig extends JsonSerializable { - /** Defines how to parse sample response. */ + /** Defines the type for parsing sample response. */ @JsonProperty("parseType") public abstract Optional parseType(); /** - * Defines the regex to extract the important part of sample response. This field is only used - * when `parse_type` is `REGEX_EXTRACT`. + * Defines the regex for extracting the important part of sample response. This field is only used + * when parse_type is ResponseParseType.REGEX_EXTRACT. */ @JsonProperty("regexExtractExpression") public abstract Optional regexExtractExpression(); @@ -65,7 +74,7 @@ private static Builder create() { /** * Setter for parseType. * - *

parseType: Defines how to parse sample response. + *

parseType: Defines the type for parsing sample response. */ @JsonProperty("parseType") public abstract Builder parseType(ResponseParseType parseType); @@ -83,7 +92,7 @@ public Builder clearParseType() { /** * Setter for parseType given a known enum. * - *

parseType: Defines how to parse sample response. + *

parseType: Defines the type for parsing sample response. */ @CanIgnoreReturnValue public Builder parseType(ResponseParseType.Known knownType) { @@ -93,7 +102,7 @@ public Builder parseType(ResponseParseType.Known knownType) { /** * Setter for parseType given a string. * - *

parseType: Defines how to parse sample response. + *

parseType: Defines the type for parsing sample response. */ @CanIgnoreReturnValue public Builder parseType(String parseType) { @@ -103,8 +112,8 @@ public Builder parseType(String parseType) { /** * Setter for regexExtractExpression. * - *

regexExtractExpression: Defines the regex to extract the important part of sample - * response. This field is only used when `parse_type` is `REGEX_EXTRACT`. + *

regexExtractExpression: Defines the regex for extracting the important part of sample + * response. This field is only used when parse_type is ResponseParseType.REGEX_EXTRACT. */ @JsonProperty("regexExtractExpression") public abstract Builder regexExtractExpression(String regexExtractExpression); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java b/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java index 552f3a73ec1..bcbf1aea461 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java @@ -30,21 +30,20 @@ @AutoValue @JsonDeserialize(builder = ReinforcementTuningSpec.Builder.class) public abstract class ReinforcementTuningSpec extends JsonSerializable { - /** */ + /** Composite reward function configuration for reinforcement tuning. */ @JsonProperty("compositeRewardConfig") public abstract Optional compositeRewardConfig(); /** - * Cloud Storage path to file containing training dataset for tuning. The dataset must be + * Cloud Storage path to the file containing training dataset for tuning. The dataset must be * formatted as a JSONL file. */ @JsonProperty("trainingDatasetUri") public abstract Optional trainingDatasetUri(); /** - * Cloud Storage path to file containing validation dataset for tuning. The dataset must be - * formatted as a JSONL file. If no validation dataset is provided, by default the API splits 25% - * of the training dataset or 50 examples, whichever is larger, as the validation dataset. + * Cloud Storage path to the file containing validation dataset for tuning. The dataset must be + * formatted as a JSONL file. */ @JsonProperty("validationDatasetUri") public abstract Optional validationDatasetUri(); @@ -78,7 +77,7 @@ private static Builder create() { /** * Setter for compositeRewardConfig. * - *

compositeRewardConfig: + *

compositeRewardConfig: Composite reward function configuration for reinforcement tuning. */ @JsonProperty("compositeRewardConfig") public abstract Builder compositeRewardConfig( @@ -87,7 +86,7 @@ public abstract Builder compositeRewardConfig( /** * Setter for compositeRewardConfig builder. * - *

compositeRewardConfig: + *

compositeRewardConfig: Composite reward function configuration for reinforcement tuning. */ @CanIgnoreReturnValue public Builder compositeRewardConfig( @@ -109,8 +108,8 @@ public Builder clearCompositeRewardConfig() { /** * Setter for trainingDatasetUri. * - *

trainingDatasetUri: Cloud Storage path to file containing training dataset for tuning. The - * dataset must be formatted as a JSONL file. + *

trainingDatasetUri: Cloud Storage path to the file containing training dataset for tuning. + * The dataset must be formatted as a JSONL file. */ @JsonProperty("trainingDatasetUri") public abstract Builder trainingDatasetUri(String trainingDatasetUri); @@ -128,10 +127,8 @@ public Builder clearTrainingDatasetUri() { /** * Setter for validationDatasetUri. * - *

validationDatasetUri: Cloud Storage path to file containing validation dataset for tuning. - * The dataset must be formatted as a JSONL file. If no validation dataset is provided, by - * default the API splits 25% of the training dataset or 50 examples, whichever is larger, as - * the validation dataset. + *

validationDatasetUri: Cloud Storage path to the file containing validation dataset for + * tuning. The dataset must be formatted as a JSONL file. */ @JsonProperty("validationDatasetUri") public abstract Builder validationDatasetUri(String validationDatasetUri); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java index c86ec10ffbc..2502c61f801 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java @@ -26,20 +26,26 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Scores parsed responses for string matching use cases. */ +/** + * ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for string matching + * use cases. For example, for math problems, users can use string match scorer to check if the + * correct exact answer is generated. Note: Reward returned by the string match reward function is + * clipped to be within `[-1, 1]` if wrongAnswerReward or correctAnswerReward are beyond the range, + * i.e., `reward = max(min(reward, 1.0), -1.0)`. This data type is not supported in Gemini API. + */ @AutoValue @JsonDeserialize(builder = ReinforcementTuningStringMatchRewardScorer.Builder.class) public abstract class ReinforcementTuningStringMatchRewardScorer extends JsonSerializable { /** - * Wrong answer reward is returned if evaluator evaluates to `false`. All wrong answers get the - * same reward. + * Wrong answer reward is returned if the parsed response is evaluated as `false`. All wrong + * answers get the same reward. */ @JsonProperty("wrongAnswerReward") public abstract Optional wrongAnswerReward(); /** - * Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the - * same reward. + * Correct answer rewawrd is returned if the parsed response is evaluated as `true`. All correct + * answers get the same reward. */ @JsonProperty("correctAnswerReward") public abstract Optional correctAnswerReward(); @@ -78,8 +84,8 @@ private static Builder create() { /** * Setter for wrongAnswerReward. * - *

wrongAnswerReward: Wrong answer reward is returned if evaluator evaluates to `false`. All - * wrong answers get the same reward. + *

wrongAnswerReward: Wrong answer reward is returned if the parsed response is evaluated as + * `false`. All wrong answers get the same reward. */ @JsonProperty("wrongAnswerReward") public abstract Builder wrongAnswerReward(Float wrongAnswerReward); @@ -97,8 +103,8 @@ public Builder clearWrongAnswerReward() { /** * Setter for correctAnswerReward. * - *

correctAnswerReward: Correct answer reward is returned if evaluator evaluates to `true`. - * All correct answers get the same reward. + *

correctAnswerReward: Correct answer rewawrd is returned if the parsed response is + * evaluated as `true`. All correct answers get the same reward. */ @JsonProperty("correctAnswerReward") public abstract Builder correctAnswerReward(Float correctAnswerReward); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java index c6521a834c7..8b796de5550 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java @@ -27,19 +27,27 @@ import java.util.Optional; /** - * Converts parsed responses to JSON format, finds the first-level matching key, then performs - * StringMatchExpression on the value. + * JsonMatchExpression supports converting the parsed responses to JSON format, finding the value in + * the JSON response that matches the key_name in the first level, and performing + * StringMatchExpression operation on the matched JSON value. This data type is not supported in + * Gemini API. */ @AutoValue @JsonDeserialize( builder = ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.Builder.class) public abstract class ReinforcementTuningStringMatchRewardScorerJsonMatchExpression extends JsonSerializable { - /** Json key name to find the value to match against. */ + /** + * The key name to find the value in the parsed response that's in JSON format. Only first-level + * key matching is supported. + */ @JsonProperty("keyName") public abstract Optional keyName(); - /** String match expression to match against the value of json key. */ + /** + * String match expression to match against the extracted value from the JSON representation of + * the parsed response. + */ @JsonProperty("valueStringMatchExpression") public abstract Optional valueStringMatchExpression(); @@ -68,7 +76,8 @@ private static Builder create() { /** * Setter for keyName. * - *

keyName: Json key name to find the value to match against. + *

keyName: The key name to find the value in the parsed response that's in JSON format. Only + * first-level key matching is supported. */ @JsonProperty("keyName") public abstract Builder keyName(String keyName); @@ -86,8 +95,8 @@ public Builder clearKeyName() { /** * Setter for valueStringMatchExpression. * - *

valueStringMatchExpression: String match expression to match against the value of json - * key. + *

valueStringMatchExpression: String match expression to match against the extracted value + * from the JSON representation of the parsed response. */ @JsonProperty("valueStringMatchExpression") public abstract Builder valueStringMatchExpression( @@ -96,8 +105,8 @@ public abstract Builder valueStringMatchExpression( /** * Setter for valueStringMatchExpression builder. * - *

valueStringMatchExpression: String match expression to match against the value of json - * key. + *

valueStringMatchExpression: String match expression to match against the extracted value + * from the JSON representation of the parsed response. */ @CanIgnoreReturnValue public Builder valueStringMatchExpression( diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java index 6cacc2a333a..2e007ec91cb 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java @@ -26,20 +26,30 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** Evaluates parsed response using match type against expression. */ +/** + * Evaluates parsed response using match type against the expression. Returns `true` if + * `MatchOperation(target, expression)` evaluates to `true`, and `false` otherwise. This data type + * is not supported in Gemini API. + */ @AutoValue @JsonDeserialize( builder = ReinforcementTuningStringMatchRewardScorerStringMatchExpression.Builder.class) public abstract class ReinforcementTuningStringMatchRewardScorerStringMatchExpression extends JsonSerializable { - /** Match operation to use for evaluation. */ + /** Match operation to use for evaluating rewards. */ @JsonProperty("matchOperation") public abstract Optional matchOperation(); /** - * String or regular expression to match against. Customer can also provide a references map - * (key/value pairs) whose value will be substituted into the expression by referencing - * `references.key_name` (wrapped in double curly braces). + * A string or a regular expression to match against for evaluating rewards. Users can also + * provide a references map of `{key: value}` whose `value` will be used to replace the + * placeholder {{references.key}} in the expression. For example, if the following `references` + * are defined in the training / validation dataset: ``` { "systemInstruction": ..., "contents": + * ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer is Yes" } } ``` and + * if users define the following StringMatchExpression: { "matchOperation": "REGEX_CONTAINS", + * "expression": ".*{{references.concise_answer}}.*" } On evaluating the reward for each sample + * response, this StringMatchExpression will be substituted as: ``` { "matchOperation": + * "REGEX_CONTAINS", "expression": ".*Yes.*" } ``` */ @JsonProperty("expression") public abstract Optional expression(); @@ -70,7 +80,7 @@ private static Builder create() { /** * Setter for matchOperation. * - *

matchOperation: Match operation to use for evaluation. + *

matchOperation: Match operation to use for evaluating rewards. */ @JsonProperty("matchOperation") public abstract Builder matchOperation(MatchOperation matchOperation); @@ -88,7 +98,7 @@ public Builder clearMatchOperation() { /** * Setter for matchOperation given a known enum. * - *

matchOperation: Match operation to use for evaluation. + *

matchOperation: Match operation to use for evaluating rewards. */ @CanIgnoreReturnValue public Builder matchOperation(MatchOperation.Known knownType) { @@ -98,7 +108,7 @@ public Builder matchOperation(MatchOperation.Known knownType) { /** * Setter for matchOperation given a string. * - *

matchOperation: Match operation to use for evaluation. + *

matchOperation: Match operation to use for evaluating rewards. */ @CanIgnoreReturnValue public Builder matchOperation(String matchOperation) { @@ -108,9 +118,15 @@ public Builder matchOperation(String matchOperation) { /** * Setter for expression. * - *

expression: String or regular expression to match against. Customer can also provide a - * references map (key/value pairs) whose value will be substituted into the expression by - * referencing `references.key_name` (wrapped in double curly braces). + *

expression: A string or a regular expression to match against for evaluating rewards. + * Users can also provide a references map of `{key: value}` whose `value` will be used to + * replace the placeholder {{references.key}} in the expression. For example, if the following + * `references` are defined in the training / validation dataset: ``` { "systemInstruction": + * ..., "contents": ..., "references": { "concise_answer": "Yes", "verbose_answer": "The answer + * is Yes" } } ``` and if users define the following StringMatchExpression: { "matchOperation": + * "REGEX_CONTAINS", "expression": ".*{{references.concise_answer}}.*" } On evaluating the + * reward for each sample response, this StringMatchExpression will be substituted as: ``` { + * "matchOperation": "REGEX_CONTAINS", "expression": ".*Yes.*" } ``` */ @JsonProperty("expression") public abstract Builder expression(String expression); diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningUserDatasetExamples.java b/src/main/java/com/google/genai/types/ReinforcementTuningUserDatasetExamples.java new file mode 100644 index 00000000000..eed16103cf7 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningUserDatasetExamples.java @@ -0,0 +1,118 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import static com.google.common.collect.ImmutableList.toImmutableList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** + * Sample reinforcement tuning user data in the training dataset. The contents are truncated for + * better UI showing. This data type is not supported in Gemini API. + */ +@AutoValue +@JsonDeserialize(builder = ReinforcementTuningUserDatasetExamples.Builder.class) +public abstract class ReinforcementTuningUserDatasetExamples extends JsonSerializable { + /** List of user datasset examples showing to user. */ + @JsonProperty("userDatasetExamples") + public abstract Optional> userDatasetExamples(); + + /** Instantiates a builder for ReinforcementTuningUserDatasetExamples. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningUserDatasetExamples.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningUserDatasetExamples. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningUserDatasetExamples.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningUserDatasetExamples.Builder(); + } + + /** + * Setter for userDatasetExamples. + * + *

userDatasetExamples: List of user datasset examples showing to user. + */ + @JsonProperty("userDatasetExamples") + public abstract Builder userDatasetExamples( + List userDatasetExamples); + + /** + * Setter for userDatasetExamples. + * + *

userDatasetExamples: List of user datasset examples showing to user. + */ + @CanIgnoreReturnValue + public Builder userDatasetExamples(ReinforcementTuningExample... userDatasetExamples) { + return userDatasetExamples(Arrays.asList(userDatasetExamples)); + } + + /** + * Setter for userDatasetExamples builder. + * + *

userDatasetExamples: List of user datasset examples showing to user. + */ + @CanIgnoreReturnValue + public Builder userDatasetExamples( + ReinforcementTuningExample.Builder... userDatasetExamplesBuilders) { + return userDatasetExamples( + Arrays.asList(userDatasetExamplesBuilders).stream() + .map(ReinforcementTuningExample.Builder::build) + .collect(toImmutableList())); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder userDatasetExamples( + Optional> userDatasetExamples); + + /** Clears the value of userDatasetExamples field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearUserDatasetExamples() { + return userDatasetExamples(Optional.empty()); + } + + public abstract ReinforcementTuningUserDatasetExamples build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningUserDatasetExamples object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningUserDatasetExamples fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningUserDatasetExamples.class); + } +} diff --git a/src/main/java/com/google/genai/types/ResponseFormat.java b/src/main/java/com/google/genai/types/ResponseFormat.java new file mode 100644 index 00000000000..5b986fbf9c4 --- /dev/null +++ b/src/main/java/com/google/genai/types/ResponseFormat.java @@ -0,0 +1,190 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** + * Configuration for the model to configure output formatting and delivery. This data type is not + * supported in Gemini API. + */ +@AutoValue +@JsonDeserialize(builder = ResponseFormat.Builder.class) +public abstract class ResponseFormat extends JsonSerializable { + /** Audio output format. */ + @JsonProperty("audio") + public abstract Optional audio(); + + /** Image output format. */ + @JsonProperty("image") + public abstract Optional image(); + + /** Text output format. */ + @JsonProperty("text") + public abstract Optional text(); + + /** Video output format. */ + @JsonProperty("video") + public abstract Optional video(); + + /** Instantiates a builder for ResponseFormat. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ResponseFormat.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ResponseFormat. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `ResponseFormat.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_ResponseFormat.Builder(); + } + + /** + * Setter for audio. + * + *

audio: Audio output format. + */ + @JsonProperty("audio") + public abstract Builder audio(AudioResponseFormat audio); + + /** + * Setter for audio builder. + * + *

audio: Audio output format. + */ + @CanIgnoreReturnValue + public Builder audio(AudioResponseFormat.Builder audioBuilder) { + return audio(audioBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder audio(Optional audio); + + /** Clears the value of audio field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAudio() { + return audio(Optional.empty()); + } + + /** + * Setter for image. + * + *

image: Image output format. + */ + @JsonProperty("image") + public abstract Builder image(ImageResponseFormat image); + + /** + * Setter for image builder. + * + *

image: Image output format. + */ + @CanIgnoreReturnValue + public Builder image(ImageResponseFormat.Builder imageBuilder) { + return image(imageBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder image(Optional image); + + /** Clears the value of image field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearImage() { + return image(Optional.empty()); + } + + /** + * Setter for text. + * + *

text: Text output format. + */ + @JsonProperty("text") + public abstract Builder text(TextResponseFormat text); + + /** + * Setter for text builder. + * + *

text: Text output format. + */ + @CanIgnoreReturnValue + public Builder text(TextResponseFormat.Builder textBuilder) { + return text(textBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder text(Optional text); + + /** Clears the value of text field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearText() { + return text(Optional.empty()); + } + + /** + * Setter for video. + * + *

video: Video output format. + */ + @JsonProperty("video") + public abstract Builder video(VideoResponseFormat video); + + /** + * Setter for video builder. + * + *

video: Video output format. + */ + @CanIgnoreReturnValue + public Builder video(VideoResponseFormat.Builder videoBuilder) { + return video(videoBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder video(Optional video); + + /** Clears the value of video field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearVideo() { + return video(Optional.empty()); + } + + public abstract ResponseFormat build(); + } + + /** Deserializes a JSON string to a ResponseFormat object. */ + @ExcludeFromGeneratedCoverageReport + public static ResponseFormat fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ResponseFormat.class); + } +} diff --git a/src/main/java/com/google/genai/types/ResponseParseType.java b/src/main/java/com/google/genai/types/ResponseParseType.java index e4e3068911a..56e16b83a07 100644 --- a/src/main/java/com/google/genai/types/ResponseParseType.java +++ b/src/main/java/com/google/genai/types/ResponseParseType.java @@ -23,18 +23,23 @@ import com.google.common.base.Ascii; import java.util.Objects; -/** Defines how to parse sample response. */ +/** Defines the type for parsing sample response. This enum is not supported in Gemini API. */ public class ResponseParseType { /** Enum representing the known values for ResponseParseType. */ public enum Known { - /** Default value. This value is unused. */ + /** Default value. Fallback to IDENTITY */ RESPONSE_PARSE_TYPE_UNSPECIFIED, - /** Use the sample response as is. */ + /** Returns the sample response as is. */ IDENTITY, - /** Use regex to extract the important part of sample response. */ + /** + * Uses regex to extract the important part of sample response. Similar to + * [GoogleSQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_extract) + * `REGEX_EXTRACT(response, regex_extract_expression)`, but different in that if there are + * multiple matches, the last match will be returned. + */ REGEX_EXTRACT } diff --git a/src/main/java/com/google/genai/types/SegmentImageParameters.java b/src/main/java/com/google/genai/types/SegmentImageParameters.java index b19f35df6a0..d44cfd401f3 100644 --- a/src/main/java/com/google/genai/types/SegmentImageParameters.java +++ b/src/main/java/com/google/genai/types/SegmentImageParameters.java @@ -34,7 +34,7 @@ public abstract class SegmentImageParameters extends JsonSerializable { /** * ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Optional model(); @@ -69,7 +69,7 @@ private static Builder create() { * Setter for model. * *

model: ID of the model to use. For a list of models, see `Google models - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_. */ @JsonProperty("model") public abstract Builder model(String model); diff --git a/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java b/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java index b04cd3d81cd..a2c64bba329 100644 --- a/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java +++ b/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java @@ -34,27 +34,39 @@ public abstract class SingleReinforcementTuningRewardConfig extends JsonSerializ @JsonProperty("autoraterScorer") public abstract Optional autoraterScorer(); - /** A unique reward name used to identify each single reinforcement tuning reward. */ + /** A unique reward name for identifying each single reinforcement tuning reward. */ @JsonProperty("rewardName") public abstract Optional rewardName(); - /** Defines how to parse sample response. */ + /** + * Defines how to parse sample response. For example, given a sample response for evaluating the + * reward, users might want to extract the text only between `` and `` in the sample response, and + * keeps only the last one in case there are multiple such tags. To achieve such a purpose, they + * can define a regex `".*(.*?)"` using the + * ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type. + */ @JsonProperty("parseResponseConfig") public abstract Optional parseResponseConfig(); - /** Scores parsed responses for code execution use cases. */ + /** + * ReinforcementTuningCodeExecutionRewardScorer is used to score parsed responses for code + * execution use cases. + */ @JsonProperty("codeExecutionRewardScorer") public abstract Optional codeExecutionRewardScorer(); /** - * Scores parsed responses for simple string matching use cases against reference answer without - * writing python code. + * ReinforcementTuningStringMatchRewardScorer is used to score parsed responses for simple string + * matching use cases against reference answers. */ @JsonProperty("stringMatchRewardScorer") public abstract Optional stringMatchRewardScorer(); - /** Scores parsed responses by calling a Cloud Run service. */ + /** + * ReinforcementTuningCloudRunRewardScorer is used to score parsed responses by calling a Cloud + * Run service. + */ @JsonProperty("cloudRunRewardScorer") public abstract Optional cloudRunRewardScorer(); @@ -113,7 +125,7 @@ public Builder clearAutoraterScorer() { /** * Setter for rewardName. * - *

rewardName: A unique reward name used to identify each single reinforcement tuning reward. + *

rewardName: A unique reward name for identifying each single reinforcement tuning reward. */ @JsonProperty("rewardName") public abstract Builder rewardName(String rewardName); @@ -131,7 +143,11 @@ public Builder clearRewardName() { /** * Setter for parseResponseConfig. * - *

parseResponseConfig: Defines how to parse sample response. + *

parseResponseConfig: Defines how to parse sample response. For example, given a sample + * response for evaluating the reward, users might want to extract the text only between `` and + * `` in the sample response, and keeps only the last one in case there are multiple such tags. + * To achieve such a purpose, they can define a regex `".*(.*?)"` using the + * ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type. */ @JsonProperty("parseResponseConfig") public abstract Builder parseResponseConfig( @@ -140,7 +156,11 @@ public abstract Builder parseResponseConfig( /** * Setter for parseResponseConfig builder. * - *

parseResponseConfig: Defines how to parse sample response. + *

parseResponseConfig: Defines how to parse sample response. For example, given a sample + * response for evaluating the reward, users might want to extract the text only between `` and + * `` in the sample response, and keeps only the last one in case there are multiple such tags. + * To achieve such a purpose, they can define a regex `".*(.*?)"` using the + * ReinforcementTuningParseResponseConfig.ResponseParseType.REGEX_EXTRACT parse type. */ @CanIgnoreReturnValue public Builder parseResponseConfig( @@ -162,7 +182,8 @@ public Builder clearParseResponseConfig() { /** * Setter for codeExecutionRewardScorer. * - *

codeExecutionRewardScorer: Scores parsed responses for code execution use cases. + *

codeExecutionRewardScorer: ReinforcementTuningCodeExecutionRewardScorer is used to score + * parsed responses for code execution use cases. */ @JsonProperty("codeExecutionRewardScorer") public abstract Builder codeExecutionRewardScorer( @@ -171,7 +192,8 @@ public abstract Builder codeExecutionRewardScorer( /** * Setter for codeExecutionRewardScorer builder. * - *

codeExecutionRewardScorer: Scores parsed responses for code execution use cases. + *

codeExecutionRewardScorer: ReinforcementTuningCodeExecutionRewardScorer is used to score + * parsed responses for code execution use cases. */ @CanIgnoreReturnValue public Builder codeExecutionRewardScorer( @@ -193,8 +215,8 @@ public Builder clearCodeExecutionRewardScorer() { /** * Setter for stringMatchRewardScorer. * - *

stringMatchRewardScorer: Scores parsed responses for simple string matching use cases - * against reference answer without writing python code. + *

stringMatchRewardScorer: ReinforcementTuningStringMatchRewardScorer is used to score + * parsed responses for simple string matching use cases against reference answers. */ @JsonProperty("stringMatchRewardScorer") public abstract Builder stringMatchRewardScorer( @@ -203,8 +225,8 @@ public abstract Builder stringMatchRewardScorer( /** * Setter for stringMatchRewardScorer builder. * - *

stringMatchRewardScorer: Scores parsed responses for simple string matching use cases - * against reference answer without writing python code. + *

stringMatchRewardScorer: ReinforcementTuningStringMatchRewardScorer is used to score + * parsed responses for simple string matching use cases against reference answers. */ @CanIgnoreReturnValue public Builder stringMatchRewardScorer( @@ -226,7 +248,8 @@ public Builder clearStringMatchRewardScorer() { /** * Setter for cloudRunRewardScorer. * - *

cloudRunRewardScorer: Scores parsed responses by calling a Cloud Run service. + *

cloudRunRewardScorer: ReinforcementTuningCloudRunRewardScorer is used to score parsed + * responses by calling a Cloud Run service. */ @JsonProperty("cloudRunRewardScorer") public abstract Builder cloudRunRewardScorer( @@ -235,7 +258,8 @@ public abstract Builder cloudRunRewardScorer( /** * Setter for cloudRunRewardScorer builder. * - *

cloudRunRewardScorer: Scores parsed responses by calling a Cloud Run service. + *

cloudRunRewardScorer: ReinforcementTuningCloudRunRewardScorer is used to score parsed + * responses by calling a Cloud Run service. */ @CanIgnoreReturnValue public Builder cloudRunRewardScorer( diff --git a/src/main/java/com/google/genai/types/SlidingWindow.java b/src/main/java/com/google/genai/types/SlidingWindow.java index 923327ca7d3..6404af53364 100644 --- a/src/main/java/com/google/genai/types/SlidingWindow.java +++ b/src/main/java/com/google/genai/types/SlidingWindow.java @@ -38,8 +38,8 @@ public abstract class SlidingWindow extends JsonSerializable { /** * Session reduction target -- how many tokens we should keep. Window shortening operation has - * some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If - * not set, trigger_tokens/2 is assumed. + * some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. + * If not set, trigger_tokens/2 is assumed. */ @JsonProperty("targetTokens") public abstract Optional targetTokens(); @@ -67,7 +67,7 @@ private static Builder create() { * *

targetTokens: Session reduction target -- how many tokens we should keep. Window * shortening operation has some latency costs, so we should avoid running it on every turn. - * Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed. + * Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed. */ @JsonProperty("targetTokens") public abstract Builder targetTokens(Long targetTokens); diff --git a/src/main/java/com/google/genai/types/TestTableFile.java b/src/main/java/com/google/genai/types/TestTableFile.java index 3dbc9ef9050..799d264b125 100644 --- a/src/main/java/com/google/genai/types/TestTableFile.java +++ b/src/main/java/com/google/genai/types/TestTableFile.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = TestTableFile.Builder.class) public abstract class TestTableFile extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/TestTableItem.java b/src/main/java/com/google/genai/types/TestTableItem.java index 6e20ff702aa..a4b7f4bcd61 100644 --- a/src/main/java/com/google/genai/types/TestTableItem.java +++ b/src/main/java/com/google/genai/types/TestTableItem.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = TestTableItem.Builder.class) public abstract class TestTableItem extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/TextResponseFormat.java b/src/main/java/com/google/genai/types/TextResponseFormat.java new file mode 100644 index 00000000000..976ac6fc121 --- /dev/null +++ b/src/main/java/com/google/genai/types/TextResponseFormat.java @@ -0,0 +1,107 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Configuration for text-specific output formatting. */ +@AutoValue +@JsonDeserialize(builder = TextResponseFormat.Builder.class) +public abstract class TextResponseFormat extends JsonSerializable { + /** Optional. The IANA standard MIME type of the response. */ + @JsonProperty("mimeType") + public abstract Optional mimeType(); + + /** + * Optional. The JSON schema that the output should conform to. Only applicable when mime_type is + * APPLICATION_JSON. + */ + @JsonProperty("schema") + public abstract Optional schema(); + + /** Instantiates a builder for TextResponseFormat. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_TextResponseFormat.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for TextResponseFormat. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `TextResponseFormat.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_TextResponseFormat.Builder(); + } + + /** + * Setter for mimeType. + * + *

mimeType: Optional. The IANA standard MIME type of the response. + */ + @JsonProperty("mimeType") + public abstract Builder mimeType(String mimeType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder mimeType(Optional mimeType); + + /** Clears the value of mimeType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMimeType() { + return mimeType(Optional.empty()); + } + + /** + * Setter for schema. + * + *

schema: Optional. The JSON schema that the output should conform to. Only applicable when + * mime_type is APPLICATION_JSON. + */ + @JsonProperty("schema") + public abstract Builder schema(Object schema); + + @ExcludeFromGeneratedCoverageReport + abstract Builder schema(Optional schema); + + /** Clears the value of schema field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSchema() { + return schema(Optional.empty()); + } + + public abstract TextResponseFormat build(); + } + + /** Deserializes a JSON string to a TextResponseFormat object. */ + @ExcludeFromGeneratedCoverageReport + public static TextResponseFormat fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, TextResponseFormat.class); + } +} diff --git a/src/main/java/com/google/genai/types/Tool.java b/src/main/java/com/google/genai/types/Tool.java index cc315890552..68121d26195 100644 --- a/src/main/java/com/google/genai/types/Tool.java +++ b/src/main/java/com/google/genai/types/Tool.java @@ -119,6 +119,14 @@ public abstract class Tool extends JsonSerializable { @JsonProperty("mcpServers") public abstract Optional> mcpServers(); + /** + * Optional. Uses Exa.ai to search for information to answer user queries. The search results will + * be grounded on Exa.ai and presented to the model for response generation. This field is not + * supported in Gemini API. + */ + @JsonProperty("exaAiSearch") + public abstract Optional exaAiSearch(); + /** Instantiates a builder for Tool. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -568,6 +576,38 @@ public Builder clearMcpServers() { return mcpServers(Optional.empty()); } + /** + * Setter for exaAiSearch. + * + *

exaAiSearch: Optional. Uses Exa.ai to search for information to answer user queries. The + * search results will be grounded on Exa.ai and presented to the model for response generation. + * This field is not supported in Gemini API. + */ + @JsonProperty("exaAiSearch") + public abstract Builder exaAiSearch(ToolExaAiSearch exaAiSearch); + + /** + * Setter for exaAiSearch builder. + * + *

exaAiSearch: Optional. Uses Exa.ai to search for information to answer user queries. The + * search results will be grounded on Exa.ai and presented to the model for response generation. + * This field is not supported in Gemini API. + */ + @CanIgnoreReturnValue + public Builder exaAiSearch(ToolExaAiSearch.Builder exaAiSearchBuilder) { + return exaAiSearch(exaAiSearchBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder exaAiSearch(Optional exaAiSearch); + + /** Clears the value of exaAiSearch field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExaAiSearch() { + return exaAiSearch(Optional.empty()); + } + public abstract Tool build(); } diff --git a/src/main/java/com/google/genai/types/ToolExaAiSearch.java b/src/main/java/com/google/genai/types/ToolExaAiSearch.java new file mode 100644 index 00000000000..b562c39a467 --- /dev/null +++ b/src/main/java/com/google/genai/types/ToolExaAiSearch.java @@ -0,0 +1,108 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Map; +import java.util.Optional; + +/** + * ExaAiSearch tool type. A tool that uses the Exa.ai search engine for grounding. This data type is + * not supported in Gemini API. + */ +@AutoValue +@JsonDeserialize(builder = ToolExaAiSearch.Builder.class) +public abstract class ToolExaAiSearch extends JsonSerializable { + /** Required. The API key for ExaAiSearch. */ + @JsonProperty("apiKey") + public abstract Optional apiKey(); + + /** Optional. This field can be used to pass any parameter from the Exa.ai Search API. */ + @JsonProperty("customConfigs") + public abstract Optional> customConfigs(); + + /** Instantiates a builder for ToolExaAiSearch. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ToolExaAiSearch.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ToolExaAiSearch. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `ToolExaAiSearch.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_ToolExaAiSearch.Builder(); + } + + /** + * Setter for apiKey. + * + *

apiKey: Required. The API key for ExaAiSearch. + */ + @JsonProperty("apiKey") + public abstract Builder apiKey(String apiKey); + + @ExcludeFromGeneratedCoverageReport + abstract Builder apiKey(Optional apiKey); + + /** Clears the value of apiKey field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearApiKey() { + return apiKey(Optional.empty()); + } + + /** + * Setter for customConfigs. + * + *

customConfigs: Optional. This field can be used to pass any parameter from the Exa.ai + * Search API. + */ + @JsonProperty("customConfigs") + public abstract Builder customConfigs(Map customConfigs); + + @ExcludeFromGeneratedCoverageReport + abstract Builder customConfigs(Optional> customConfigs); + + /** Clears the value of customConfigs field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCustomConfigs() { + return customConfigs(Optional.empty()); + } + + public abstract ToolExaAiSearch build(); + } + + /** Deserializes a JSON string to a ToolExaAiSearch object. */ + @ExcludeFromGeneratedCoverageReport + public static ToolExaAiSearch fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ToolExaAiSearch.class); + } +} diff --git a/src/main/java/com/google/genai/types/TranslationConfig.java b/src/main/java/com/google/genai/types/TranslationConfig.java index 61ae7c4fcc7..173d2b5594d 100644 --- a/src/main/java/com/google/genai/types/TranslationConfig.java +++ b/src/main/java/com/google/genai/types/TranslationConfig.java @@ -31,15 +31,16 @@ @JsonDeserialize(builder = TranslationConfig.Builder.class) public abstract class TranslationConfig extends JsonSerializable { /** - * If true, the model will generate audio when the target language is spoken, essentially it will - * parrot the input. If false, we will not produce audio for the target language. + * Optional. If true, the model will generate audio when the target language is spoken, + * essentially it will parrot the input. If false, we will not produce audio for the target + * language. */ @JsonProperty("echoTargetLanguage") public abstract Optional echoTargetLanguage(); /** - * The target language for translation. Supported values are BCP-47 language codes (e.g. "en", - * "es", "fr"). + * Required. The target language for translation. Supported values are BCP-47 language codes (e.g. + * "en", "es", "fr"). */ @JsonProperty("targetLanguageCode") public abstract Optional targetLanguageCode(); @@ -65,9 +66,9 @@ private static Builder create() { /** * Setter for echoTargetLanguage. * - *

echoTargetLanguage: If true, the model will generate audio when the target language is - * spoken, essentially it will parrot the input. If false, we will not produce audio for the - * target language. + *

echoTargetLanguage: Optional. If true, the model will generate audio when the target + * language is spoken, essentially it will parrot the input. If false, we will not produce audio + * for the target language. */ @JsonProperty("echoTargetLanguage") public abstract Builder echoTargetLanguage(boolean echoTargetLanguage); @@ -85,8 +86,8 @@ public Builder clearEchoTargetLanguage() { /** * Setter for targetLanguageCode. * - *

targetLanguageCode: The target language for translation. Supported values are BCP-47 - * language codes (e.g. "en", "es", "fr"). + *

targetLanguageCode: Required. The target language for translation. Supported values are + * BCP-47 language codes (e.g. "en", "es", "fr"). */ @JsonProperty("targetLanguageCode") public abstract Builder targetLanguageCode(String targetLanguageCode); diff --git a/src/main/java/com/google/genai/types/TuningDataStats.java b/src/main/java/com/google/genai/types/TuningDataStats.java index 70c086a16c3..c1c3edd0385 100644 --- a/src/main/java/com/google/genai/types/TuningDataStats.java +++ b/src/main/java/com/google/genai/types/TuningDataStats.java @@ -47,6 +47,10 @@ public abstract class TuningDataStats extends JsonSerializable { @JsonProperty("supervisedTuningDataStats") public abstract Optional supervisedTuningDataStats(); + /** Output only. Statistics for reinforcement tuning. */ + @JsonProperty("reinforcementTuningDataStats") + public abstract Optional reinforcementTuningDataStats(); + /** Instantiates a builder for TuningDataStats. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -158,6 +162,36 @@ public Builder clearSupervisedTuningDataStats() { return supervisedTuningDataStats(Optional.empty()); } + /** + * Setter for reinforcementTuningDataStats. + * + *

reinforcementTuningDataStats: Output only. Statistics for reinforcement tuning. + */ + @JsonProperty("reinforcementTuningDataStats") + public abstract Builder reinforcementTuningDataStats(DatasetStats reinforcementTuningDataStats); + + /** + * Setter for reinforcementTuningDataStats builder. + * + *

reinforcementTuningDataStats: Output only. Statistics for reinforcement tuning. + */ + @CanIgnoreReturnValue + public Builder reinforcementTuningDataStats( + DatasetStats.Builder reinforcementTuningDataStatsBuilder) { + return reinforcementTuningDataStats(reinforcementTuningDataStatsBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder reinforcementTuningDataStats( + Optional reinforcementTuningDataStats); + + /** Clears the value of reinforcementTuningDataStats field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearReinforcementTuningDataStats() { + return reinforcementTuningDataStats(Optional.empty()); + } + public abstract TuningDataStats build(); } diff --git a/src/main/java/com/google/genai/types/TuningJob.java b/src/main/java/com/google/genai/types/TuningJob.java index f6dc5db8533..709982b84e2 100644 --- a/src/main/java/com/google/genai/types/TuningJob.java +++ b/src/main/java/com/google/genai/types/TuningJob.java @@ -109,7 +109,7 @@ public abstract class TuningJob extends JsonSerializable { @JsonProperty("distillationSpec") public abstract Optional distillationSpec(); - /** */ + /** Tuning Spec for Reinforcement Tuning. */ @JsonProperty("reinforcementTuningSpec") public abstract Optional reinforcementTuningSpec(); @@ -607,7 +607,7 @@ public Builder clearDistillationSpec() { /** * Setter for reinforcementTuningSpec. * - *

reinforcementTuningSpec: + *

reinforcementTuningSpec: Tuning Spec for Reinforcement Tuning. */ @JsonProperty("reinforcementTuningSpec") public abstract Builder reinforcementTuningSpec( @@ -616,7 +616,7 @@ public abstract Builder reinforcementTuningSpec( /** * Setter for reinforcementTuningSpec builder. * - *

reinforcementTuningSpec: + *

reinforcementTuningSpec: Tuning Spec for Reinforcement Tuning. */ @CanIgnoreReturnValue public Builder reinforcementTuningSpec( diff --git a/src/main/java/com/google/genai/types/TuningValidationDataset.java b/src/main/java/com/google/genai/types/TuningValidationDataset.java index e39537f371f..cc63cc84c41 100644 --- a/src/main/java/com/google/genai/types/TuningValidationDataset.java +++ b/src/main/java/com/google/genai/types/TuningValidationDataset.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = TuningValidationDataset.Builder.class) public abstract class TuningValidationDataset extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/UpdateCachedContentParameters.java b/src/main/java/com/google/genai/types/UpdateCachedContentParameters.java index c7393b92e09..ceea586b23d 100644 --- a/src/main/java/com/google/genai/types/UpdateCachedContentParameters.java +++ b/src/main/java/com/google/genai/types/UpdateCachedContentParameters.java @@ -27,7 +27,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @InternalApi @JsonDeserialize(builder = UpdateCachedContentParameters.Builder.class) diff --git a/src/main/java/com/google/genai/types/UpscaleImageConfig.java b/src/main/java/com/google/genai/types/UpscaleImageConfig.java index 0d7c5469c8d..3f0867668c4 100644 --- a/src/main/java/com/google/genai/types/UpscaleImageConfig.java +++ b/src/main/java/com/google/genai/types/UpscaleImageConfig.java @@ -31,7 +31,7 @@ * Configuration for upscaling an image. * *

For more information on this configuration, refer to the `Imagen API reference documentation - * `_. + * <https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api>`_. */ @AutoValue @JsonDeserialize(builder = UpscaleImageConfig.Builder.class) diff --git a/src/main/java/com/google/genai/types/UpscaleImageResponse.java b/src/main/java/com/google/genai/types/UpscaleImageResponse.java index 085990c0101..91df2b3cdef 100644 --- a/src/main/java/com/google/genai/types/UpscaleImageResponse.java +++ b/src/main/java/com/google/genai/types/UpscaleImageResponse.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = UpscaleImageResponse.Builder.class) public abstract class UpscaleImageResponse extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/VideoResponseFormat.java b/src/main/java/com/google/genai/types/VideoResponseFormat.java new file mode 100644 index 00000000000..fd13bc57a68 --- /dev/null +++ b/src/main/java/com/google/genai/types/VideoResponseFormat.java @@ -0,0 +1,195 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Auto-generated code. Do not edit. + +package com.google.genai.types; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.time.Duration; +import java.util.Optional; + +/** + * Configuration for video-specific output formatting. This data type is not supported in Gemini + * API. + */ +@AutoValue +@JsonDeserialize(builder = VideoResponseFormat.Builder.class) +public abstract class VideoResponseFormat extends JsonSerializable { + /** The aspect ratio for the video output. */ + @JsonProperty("aspectRatio") + public abstract Optional aspectRatio(); + + /** Optional. Delivery mode for the generated content. */ + @JsonProperty("delivery") + public abstract Optional delivery(); + + /** Optional. The duration for the video output. */ + @JsonProperty("duration") + public abstract Optional duration(); + + /** + * Optional. The Google Cloud Storage URI to store the video output. Required for Vertex if + * delivery is URI. + */ + @JsonProperty("gcsUri") + public abstract Optional gcsUri(); + + /** Instantiates a builder for VideoResponseFormat. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_VideoResponseFormat.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for VideoResponseFormat. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `VideoResponseFormat.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_VideoResponseFormat.Builder(); + } + + /** + * Setter for aspectRatio. + * + *

aspectRatio: The aspect ratio for the video output. + */ + @JsonProperty("aspectRatio") + public abstract Builder aspectRatio(AspectRatio aspectRatio); + + @ExcludeFromGeneratedCoverageReport + abstract Builder aspectRatio(Optional aspectRatio); + + /** Clears the value of aspectRatio field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAspectRatio() { + return aspectRatio(Optional.empty()); + } + + /** + * Setter for aspectRatio given a known enum. + * + *

aspectRatio: The aspect ratio for the video output. + */ + @CanIgnoreReturnValue + public Builder aspectRatio(AspectRatio.Known knownType) { + return aspectRatio(new AspectRatio(knownType)); + } + + /** + * Setter for aspectRatio given a string. + * + *

aspectRatio: The aspect ratio for the video output. + */ + @CanIgnoreReturnValue + public Builder aspectRatio(String aspectRatio) { + return aspectRatio(new AspectRatio(aspectRatio)); + } + + /** + * Setter for delivery. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @JsonProperty("delivery") + public abstract Builder delivery(Delivery delivery); + + @ExcludeFromGeneratedCoverageReport + abstract Builder delivery(Optional delivery); + + /** Clears the value of delivery field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDelivery() { + return delivery(Optional.empty()); + } + + /** + * Setter for delivery given a known enum. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(Delivery.Known knownType) { + return delivery(new Delivery(knownType)); + } + + /** + * Setter for delivery given a string. + * + *

delivery: Optional. Delivery mode for the generated content. + */ + @CanIgnoreReturnValue + public Builder delivery(String delivery) { + return delivery(new Delivery(delivery)); + } + + /** + * Setter for duration. + * + *

duration: Optional. The duration for the video output. + */ + @JsonProperty("duration") + public abstract Builder duration(Duration duration); + + @ExcludeFromGeneratedCoverageReport + abstract Builder duration(Optional duration); + + /** Clears the value of duration field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearDuration() { + return duration(Optional.empty()); + } + + /** + * Setter for gcsUri. + * + *

gcsUri: Optional. The Google Cloud Storage URI to store the video output. Required for + * Vertex if delivery is URI. + */ + @JsonProperty("gcsUri") + public abstract Builder gcsUri(String gcsUri); + + @ExcludeFromGeneratedCoverageReport + abstract Builder gcsUri(Optional gcsUri); + + /** Clears the value of gcsUri field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearGcsUri() { + return gcsUri(Optional.empty()); + } + + public abstract VideoResponseFormat build(); + } + + /** Deserializes a JSON string to a VideoResponseFormat object. */ + @ExcludeFromGeneratedCoverageReport + public static VideoResponseFormat fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, VideoResponseFormat.class); + } +} diff --git a/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java b/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java index 7e095317e8c..b32b32b96b9 100644 --- a/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java +++ b/src/main/java/com/google/genai/types/VoiceActivityDetectionSignal.java @@ -26,7 +26,7 @@ import com.google.genai.JsonSerializable; import java.util.Optional; -/** None */ +/** */ @AutoValue @JsonDeserialize(builder = VoiceActivityDetectionSignal.Builder.class) public abstract class VoiceActivityDetectionSignal extends JsonSerializable {