diff --git a/src/main/java/com/google/genai/Tunings.java b/src/main/java/com/google/genai/Tunings.java index 5b1fc64cdd9..c8ce051a358 100644 --- a/src/main/java/com/google/genai/Tunings.java +++ b/src/main/java/com/google/genai/Tunings.java @@ -283,6 +283,18 @@ ObjectNode createTuningJobConfigToMldev( + " not in Gemini Developer API mode."); } + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"thinkingLevel"}))) { + throw new IllegalArgumentException( + "thinkingLevel parameter is only supported in Gemini Enterprise Agent Platform mode, not" + + " in Gemini Developer API mode."); + } + + if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"validationDatasetUri"}))) { + throw new IllegalArgumentException( + "validationDatasetUri parameter is only supported in Gemini Enterprise Agent Platform" + + " mode, not in Gemini Developer API mode."); + } + return toObject; } @@ -703,6 +715,20 @@ ObjectNode createTuningJobConfigToVertex( Common.getValueByPath(fromObject, new String[] {"maxOutputTokens"})); } + if (Common.getValueByPath(fromObject, new String[] {"thinkingLevel"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"reinforcementTuningSpec", "hyperParameters", "thinkingLevel"}, + Common.getValueByPath(fromObject, new String[] {"thinkingLevel"})); + } + + if (Common.getValueByPath(fromObject, new String[] {"validationDatasetUri"}) != null) { + Common.setValueByPath( + parentObject, + new String[] {"reinforcementTuningSpec", "validationDatasetUri"}, + Common.getValueByPath(fromObject, new String[] {"validationDatasetUri"})); + } + return toObject; } @@ -1793,6 +1819,13 @@ ObjectNode tuningJobFromVertex( rootObject)); } + if (Common.getValueByPath(fromObject, new String[] {"reinforcementTuningSpec"}) != null) { + Common.setValueByPath( + toObject, + new String[] {"reinforcementTuningSpec"}, + Common.getValueByPath(fromObject, new String[] {"reinforcementTuningSpec"})); + } + if (Common.getValueByPath(fromObject, new String[] {"tuningDataStats"}) != null) { Common.setValueByPath( toObject, diff --git a/src/main/java/com/google/genai/types/CreateTuningJobConfig.java b/src/main/java/com/google/genai/types/CreateTuningJobConfig.java index 8ec76b62a65..09b3c6adc66 100644 --- a/src/main/java/com/google/genai/types/CreateTuningJobConfig.java +++ b/src/main/java/com/google/genai/types/CreateTuningJobConfig.java @@ -178,6 +178,22 @@ public abstract class CreateTuningJobConfig extends JsonSerializable { @JsonProperty("maxOutputTokens") public abstract Optional maxOutputTokens(); + /** + * Indicates the maximum thinking depth. Use with earlier models shall result in error. + * Reinforcement tuning only. + */ + @JsonProperty("thinkingLevel") + public abstract Optional thinkingLevel(); + + /** + * 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. + * Reinforcement tuning only. + */ + @JsonProperty("validationDatasetUri") + public abstract Optional validationDatasetUri(); + /** Instantiates a builder for CreateTuningJobConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -853,6 +869,68 @@ public Builder clearMaxOutputTokens() { return maxOutputTokens(Optional.empty()); } + /** + * Setter for thinkingLevel. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. Reinforcement tuning only. + */ + @JsonProperty("thinkingLevel") + public abstract Builder thinkingLevel(ReinforcementTuningThinkingLevel thinkingLevel); + + @ExcludeFromGeneratedCoverageReport + abstract Builder thinkingLevel(Optional thinkingLevel); + + /** Clears the value of thinkingLevel field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearThinkingLevel() { + return thinkingLevel(Optional.empty()); + } + + /** + * Setter for thinkingLevel given a known enum. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. Reinforcement tuning only. + */ + @CanIgnoreReturnValue + public Builder thinkingLevel(ReinforcementTuningThinkingLevel.Known knownType) { + return thinkingLevel(new ReinforcementTuningThinkingLevel(knownType)); + } + + /** + * Setter for thinkingLevel given a string. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. Reinforcement tuning only. + */ + @CanIgnoreReturnValue + public Builder thinkingLevel(String thinkingLevel) { + return thinkingLevel(new ReinforcementTuningThinkingLevel(thinkingLevel)); + } + + /** + * 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. Reinforcement tuning only. + */ + @JsonProperty("validationDatasetUri") + public abstract Builder validationDatasetUri(String validationDatasetUri); + + @ExcludeFromGeneratedCoverageReport + abstract Builder validationDatasetUri(Optional validationDatasetUri); + + /** Clears the value of validationDatasetUri field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearValidationDatasetUri() { + return validationDatasetUri(Optional.empty()); + } + public abstract CreateTuningJobConfig build(); } diff --git a/src/main/java/com/google/genai/types/MatchOperation.java b/src/main/java/com/google/genai/types/MatchOperation.java new file mode 100644 index 00000000000..ea8141aff12 --- /dev/null +++ b/src/main/java/com/google/genai/types/MatchOperation.java @@ -0,0 +1,114 @@ +/* + * 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; + +/** Match operation to use for evaluation. */ +public class MatchOperation { + + /** Enum representing the known values for MatchOperation. */ + public enum Known { + /** Default value. This value is unused. */ + MATCH_OPERATION_UNSPECIFIED, + + /** Equivalent to GoogleSQL `REGEX_CONTAINS(target, expression)`. */ + REGEX_CONTAINS, + + /** `expression` is a substring of target. */ + PARTIAL_MATCH, + + /** `expression` is an exact match of target. */ + EXACT_MATCH + } + + private Known matchOperationEnum; + private final String value; + + @JsonCreator + public MatchOperation(String value) { + this.value = value; + for (Known matchOperationEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(matchOperationEnum.toString(), value)) { + this.matchOperationEnum = matchOperationEnum; + break; + } + } + if (this.matchOperationEnum == null) { + this.matchOperationEnum = Known.MATCH_OPERATION_UNSPECIFIED; + } + } + + public MatchOperation(Known knownValue) { + this.matchOperationEnum = 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 MatchOperation)) { + return false; + } + + MatchOperation other = (MatchOperation) o; + + if (this.matchOperationEnum != Known.MATCH_OPERATION_UNSPECIFIED + && other.matchOperationEnum != Known.MATCH_OPERATION_UNSPECIFIED) { + return this.matchOperationEnum == other.matchOperationEnum; + } else if (this.matchOperationEnum == Known.MATCH_OPERATION_UNSPECIFIED + && other.matchOperationEnum == Known.MATCH_OPERATION_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.matchOperationEnum != Known.MATCH_OPERATION_UNSPECIFIED) { + return this.matchOperationEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.matchOperationEnum; + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java index 3542711d960..cc7f60427f6 100644 --- a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorer.java @@ -34,6 +34,28 @@ public abstract class ReinforcementTuningAutoraterScorer extends JsonSerializabl @JsonProperty("autoraterConfig") public abstract Optional autoraterConfig(); + /** + * Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each + * wrapped in double curly braces) into the autorater prompt. + */ + @JsonProperty("autoraterPrompt") + public abstract Optional autoraterPrompt(); + + /** Parses autorater returned response. */ + @JsonProperty("autoraterResponseParseConfig") + public abstract Optional autoraterResponseParseConfig(); + + /** + * Scores autorater responses by directly converting parsed autorater response to float reward. + */ + @JsonProperty("parsedResponseConversionScorer") + public abstract Optional + parsedResponseConversionScorer(); + + /** Scores autorater responses by using exact string match reward scorer. */ + @JsonProperty("exactMatchScorer") + public abstract Optional exactMatchScorer(); + /** Instantiates a builder for ReinforcementTuningAutoraterScorer. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -83,6 +105,123 @@ public Builder clearAutoraterConfig() { return autoraterConfig(Optional.empty()); } + /** + * Setter for autoraterPrompt. + * + *

autoraterPrompt: Allows substituting `prompt`, `response`, `system_instruction` and + * `references.reference` (each wrapped in double curly braces) into the autorater prompt. + */ + @JsonProperty("autoraterPrompt") + public abstract Builder autoraterPrompt(String autoraterPrompt); + + @ExcludeFromGeneratedCoverageReport + abstract Builder autoraterPrompt(Optional autoraterPrompt); + + /** Clears the value of autoraterPrompt field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAutoraterPrompt() { + return autoraterPrompt(Optional.empty()); + } + + /** + * Setter for autoraterResponseParseConfig. + * + *

autoraterResponseParseConfig: Parses autorater returned response. + */ + @JsonProperty("autoraterResponseParseConfig") + public abstract Builder autoraterResponseParseConfig( + ReinforcementTuningParseResponseConfig autoraterResponseParseConfig); + + /** + * Setter for autoraterResponseParseConfig builder. + * + *

autoraterResponseParseConfig: Parses autorater returned response. + */ + @CanIgnoreReturnValue + public Builder autoraterResponseParseConfig( + ReinforcementTuningParseResponseConfig.Builder autoraterResponseParseConfigBuilder) { + return autoraterResponseParseConfig(autoraterResponseParseConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder autoraterResponseParseConfig( + Optional autoraterResponseParseConfig); + + /** Clears the value of autoraterResponseParseConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAutoraterResponseParseConfig() { + return autoraterResponseParseConfig(Optional.empty()); + } + + /** + * Setter for parsedResponseConversionScorer. + * + *

parsedResponseConversionScorer: Scores autorater responses by directly converting parsed + * autorater response to float reward. + */ + @JsonProperty("parsedResponseConversionScorer") + public abstract Builder parsedResponseConversionScorer( + ReinforcementTuningAutoraterScorerParsedResponseConversionScorer + parsedResponseConversionScorer); + + /** + * Setter for parsedResponseConversionScorer builder. + * + *

parsedResponseConversionScorer: Scores autorater responses by directly converting parsed + * autorater response to float reward. + */ + @CanIgnoreReturnValue + public Builder parsedResponseConversionScorer( + ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.Builder + parsedResponseConversionScorerBuilder) { + return parsedResponseConversionScorer(parsedResponseConversionScorerBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder parsedResponseConversionScorer( + Optional + parsedResponseConversionScorer); + + /** Clears the value of parsedResponseConversionScorer field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearParsedResponseConversionScorer() { + return parsedResponseConversionScorer(Optional.empty()); + } + + /** + * Setter for exactMatchScorer. + * + *

exactMatchScorer: Scores autorater responses by using exact string match reward scorer. + */ + @JsonProperty("exactMatchScorer") + public abstract Builder exactMatchScorer( + ReinforcementTuningAutoraterScorerExactMatchScorer exactMatchScorer); + + /** + * Setter for exactMatchScorer builder. + * + *

exactMatchScorer: Scores autorater responses by using exact string match reward scorer. + */ + @CanIgnoreReturnValue + public Builder exactMatchScorer( + ReinforcementTuningAutoraterScorerExactMatchScorer.Builder exactMatchScorerBuilder) { + return exactMatchScorer(exactMatchScorerBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder exactMatchScorer( + Optional exactMatchScorer); + + /** Clears the value of exactMatchScorer field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExactMatchScorer() { + return exactMatchScorer(Optional.empty()); + } + public abstract ReinforcementTuningAutoraterScorer build(); } diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java new file mode 100644 index 00000000000..f2943ed801c --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerExactMatchScorer.java @@ -0,0 +1,135 @@ +/* + * 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; + +/** Scores autorater responses by using exact string match reward scorer. */ +@AutoValue +@JsonDeserialize(builder = ReinforcementTuningAutoraterScorerExactMatchScorer.Builder.class) +public abstract class ReinforcementTuningAutoraterScorerExactMatchScorer extends JsonSerializable { + /** Assigns this reward score if 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. */ + @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. + */ + @JsonProperty("expression") + public abstract Optional expression(); + + /** Instantiates a builder for ReinforcementTuningAutoraterScorerExactMatchScorer. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningAutoraterScorerExactMatchScorer.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningAutoraterScorerExactMatchScorer. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningAutoraterScorerExactMatchScorer.builder()` + * for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningAutoraterScorerExactMatchScorer.Builder(); + } + + /** + * Setter for correctAnswerReward. + * + *

correctAnswerReward: Assigns this reward score if parsed response string equals the + * expression. + */ + @JsonProperty("correctAnswerReward") + public abstract Builder correctAnswerReward(Float correctAnswerReward); + + @ExcludeFromGeneratedCoverageReport + abstract Builder correctAnswerReward(Optional correctAnswerReward); + + /** Clears the value of correctAnswerReward field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCorrectAnswerReward() { + return correctAnswerReward(Optional.empty()); + } + + /** + * Setter for wrongAnswerReward. + * + *

wrongAnswerReward: Assigns this reward score if parsed reward value does not equal the + * expression. + */ + @JsonProperty("wrongAnswerReward") + public abstract Builder wrongAnswerReward(Float wrongAnswerReward); + + @ExcludeFromGeneratedCoverageReport + abstract Builder wrongAnswerReward(Optional wrongAnswerReward); + + /** Clears the value of wrongAnswerReward field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWrongAnswerReward() { + return wrongAnswerReward(Optional.empty()); + } + + /** + * 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. + */ + @JsonProperty("expression") + public abstract Builder expression(String expression); + + @ExcludeFromGeneratedCoverageReport + abstract Builder expression(Optional expression); + + /** Clears the value of expression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExpression() { + return expression(Optional.empty()); + } + + public abstract ReinforcementTuningAutoraterScorerExactMatchScorer build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningAutoraterScorerExactMatchScorer object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningAutoraterScorerExactMatchScorer fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningAutoraterScorerExactMatchScorer.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java new file mode 100644 index 00000000000..722853eedec --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.java @@ -0,0 +1,73 @@ +/* + * 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.databind.annotation.JsonDeserialize; +import com.google.auto.value.AutoValue; +import com.google.genai.JsonSerializable; + +/** + * Scores responses by directly converting parsed autorater response to float reward (reward is + * clipped to be within [-1, 1]). + */ +@AutoValue +@JsonDeserialize( + builder = ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.Builder.class) +public abstract class ReinforcementTuningAutoraterScorerParsedResponseConversionScorer + extends JsonSerializable { + /** + * Instantiates a builder for ReinforcementTuningAutoraterScorerParsedResponseConversionScorer. + */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningAutoraterScorerParsedResponseConversionScorer. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use + * `ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningAutoraterScorerParsedResponseConversionScorer + .Builder(); + } + + public abstract ReinforcementTuningAutoraterScorerParsedResponseConversionScorer build(); + } + + /** + * Deserializes a JSON string to a + * ReinforcementTuningAutoraterScorerParsedResponseConversionScorer object. + */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningAutoraterScorerParsedResponseConversionScorer fromJson( + String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningAutoraterScorerParsedResponseConversionScorer.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java new file mode 100644 index 00000000000..d979f326d27 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningCloudRunRewardScorer.java @@ -0,0 +1,94 @@ +/* + * 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; + +/** Scores parsed responses by calling a Cloud Run service. */ +@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 + * granting `roles/run.invoker` in IAM) to invoke the Cloud Run service. + */ + @JsonProperty("cloudRunUri") + public abstract Optional cloudRunUri(); + + /** Instantiates a builder for ReinforcementTuningCloudRunRewardScorer. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningCloudRunRewardScorer.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningCloudRunRewardScorer. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningCloudRunRewardScorer.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningCloudRunRewardScorer.Builder(); + } + + /** + * 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. + */ + @JsonProperty("cloudRunUri") + public abstract Builder cloudRunUri(String cloudRunUri); + + @ExcludeFromGeneratedCoverageReport + abstract Builder cloudRunUri(Optional cloudRunUri); + + /** Clears the value of cloudRunUri field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCloudRunUri() { + return cloudRunUri(Optional.empty()); + } + + public abstract ReinforcementTuningCloudRunRewardScorer build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningCloudRunRewardScorer object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningCloudRunRewardScorer fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningCloudRunRewardScorer.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java new file mode 100644 index 00000000000..348de2a40df --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningCodeExecutionRewardScorer.java @@ -0,0 +1,89 @@ +/* + * 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; + +/** Scores parsed responses for code execution use cases. */ +@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. + */ + @JsonProperty("pythonCodeSnippet") + public abstract Optional pythonCodeSnippet(); + + /** Instantiates a builder for ReinforcementTuningCodeExecutionRewardScorer. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningCodeExecutionRewardScorer.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningCodeExecutionRewardScorer. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningCodeExecutionRewardScorer.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningCodeExecutionRewardScorer.Builder(); + } + + /** + * 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. + */ + @JsonProperty("pythonCodeSnippet") + public abstract Builder pythonCodeSnippet(String pythonCodeSnippet); + + @ExcludeFromGeneratedCoverageReport + abstract Builder pythonCodeSnippet(Optional pythonCodeSnippet); + + /** Clears the value of pythonCodeSnippet field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearPythonCodeSnippet() { + return pythonCodeSnippet(Optional.empty()); + } + + public abstract ReinforcementTuningCodeExecutionRewardScorer build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningCodeExecutionRewardScorer object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningCodeExecutionRewardScorer fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningCodeExecutionRewardScorer.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java b/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java new file mode 100644 index 00000000000..e8da39e72c3 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningHyperParameters.java @@ -0,0 +1,318 @@ +/* + * 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.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.genai.JsonSerializable; +import java.util.Optional; + +/** Hyperparameters for Reinforcement Tuning. */ +@AutoValue +@InternalApi +@JsonDeserialize(builder = ReinforcementTuningHyperParameters.Builder.class) +public abstract class ReinforcementTuningHyperParameters extends JsonSerializable { + /** Number of training epochs for the tuning job. */ + @JsonProperty("epochCount") + public abstract Optional epochCount(); + + /** Learning rate multiplier for Reinforcement Learning. */ + @JsonProperty("learningRateMultiplier") + public abstract Optional learningRateMultiplier(); + + /** Adapter size for Reinforcement Tuning. */ + @JsonProperty("adapterSize") + public abstract Optional adapterSize(); + + /** 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. + */ + @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. + */ + @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. + */ + @JsonProperty("checkpointInterval") + public abstract Optional checkpointInterval(); + + /** The maximum number of tokens to generate per prompt. If not set, defaults to 32768. */ + @JsonProperty("maxOutputTokens") + public abstract Optional maxOutputTokens(); + + /** Indicates the maximum thinking depth. Use with earlier models shall result in error. */ + @JsonProperty("thinkingLevel") + public abstract Optional thinkingLevel(); + + /** Instantiates a builder for ReinforcementTuningHyperParameters. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningHyperParameters.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningHyperParameters. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningHyperParameters.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningHyperParameters.Builder(); + } + + /** + * Setter for epochCount. + * + *

epochCount: Number of training epochs for the tuning job. + */ + @JsonProperty("epochCount") + public abstract Builder epochCount(Long epochCount); + + @ExcludeFromGeneratedCoverageReport + abstract Builder epochCount(Optional epochCount); + + /** Clears the value of epochCount field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearEpochCount() { + return epochCount(Optional.empty()); + } + + /** + * Setter for learningRateMultiplier. + * + *

learningRateMultiplier: Learning rate multiplier for Reinforcement Learning. + */ + @JsonProperty("learningRateMultiplier") + public abstract Builder learningRateMultiplier(Float learningRateMultiplier); + + @ExcludeFromGeneratedCoverageReport + abstract Builder learningRateMultiplier(Optional learningRateMultiplier); + + /** Clears the value of learningRateMultiplier field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearLearningRateMultiplier() { + return learningRateMultiplier(Optional.empty()); + } + + /** + * Setter for adapterSize. + * + *

adapterSize: Adapter size for Reinforcement Tuning. + */ + @JsonProperty("adapterSize") + public abstract Builder adapterSize(AdapterSize adapterSize); + + @ExcludeFromGeneratedCoverageReport + abstract Builder adapterSize(Optional adapterSize); + + /** Clears the value of adapterSize field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearAdapterSize() { + return adapterSize(Optional.empty()); + } + + /** + * Setter for adapterSize given a known enum. + * + *

adapterSize: Adapter size for Reinforcement Tuning. + */ + @CanIgnoreReturnValue + public Builder adapterSize(AdapterSize.Known knownType) { + return adapterSize(new AdapterSize(knownType)); + } + + /** + * Setter for adapterSize given a string. + * + *

adapterSize: Adapter size for Reinforcement Tuning. + */ + @CanIgnoreReturnValue + public Builder adapterSize(String adapterSize) { + return adapterSize(new AdapterSize(adapterSize)); + } + + /** + * Setter for samplesPerPrompt. + * + *

samplesPerPrompt: Number of different responses to generate per prompt during tuning. + */ + @JsonProperty("samplesPerPrompt") + public abstract Builder samplesPerPrompt(Integer samplesPerPrompt); + + @ExcludeFromGeneratedCoverageReport + abstract Builder samplesPerPrompt(Optional samplesPerPrompt); + + /** Clears the value of samplesPerPrompt field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSamplesPerPrompt() { + return samplesPerPrompt(Optional.empty()); + } + + /** + * 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. + */ + @JsonProperty("batchSize") + public abstract Builder batchSize(Integer batchSize); + + @ExcludeFromGeneratedCoverageReport + abstract Builder batchSize(Optional batchSize); + + /** Clears the value of batchSize field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearBatchSize() { + return batchSize(Optional.empty()); + } + + /** + * Setter for evaluateInterval. + * + *

evaluateInterval: How often (in steps) to evaluate the tuning job during training. If not + * set, evaluation will run per epoch. + */ + @JsonProperty("evaluateInterval") + public abstract Builder evaluateInterval(Integer evaluateInterval); + + @ExcludeFromGeneratedCoverageReport + abstract Builder evaluateInterval(Optional evaluateInterval); + + /** Clears the value of evaluateInterval field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearEvaluateInterval() { + return evaluateInterval(Optional.empty()); + } + + /** + * Setter for checkpointInterval. + * + *

checkpointInterval: How often (in steps) to save checkpoints during training. If not set, + * one checkpoint per epoch will be saved. + */ + @JsonProperty("checkpointInterval") + public abstract Builder checkpointInterval(Integer checkpointInterval); + + @ExcludeFromGeneratedCoverageReport + abstract Builder checkpointInterval(Optional checkpointInterval); + + /** Clears the value of checkpointInterval field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCheckpointInterval() { + return checkpointInterval(Optional.empty()); + } + + /** + * Setter for maxOutputTokens. + * + *

maxOutputTokens: The maximum number of tokens to generate per prompt. If not set, defaults + * to 32768. + */ + @JsonProperty("maxOutputTokens") + public abstract Builder maxOutputTokens(Integer maxOutputTokens); + + @ExcludeFromGeneratedCoverageReport + abstract Builder maxOutputTokens(Optional maxOutputTokens); + + /** Clears the value of maxOutputTokens field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMaxOutputTokens() { + return maxOutputTokens(Optional.empty()); + } + + /** + * Setter for thinkingLevel. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. + */ + @JsonProperty("thinkingLevel") + public abstract Builder thinkingLevel(ReinforcementTuningThinkingLevel thinkingLevel); + + @ExcludeFromGeneratedCoverageReport + abstract Builder thinkingLevel(Optional thinkingLevel); + + /** Clears the value of thinkingLevel field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearThinkingLevel() { + return thinkingLevel(Optional.empty()); + } + + /** + * Setter for thinkingLevel given a known enum. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. + */ + @CanIgnoreReturnValue + public Builder thinkingLevel(ReinforcementTuningThinkingLevel.Known knownType) { + return thinkingLevel(new ReinforcementTuningThinkingLevel(knownType)); + } + + /** + * Setter for thinkingLevel given a string. + * + *

thinkingLevel: Indicates the maximum thinking depth. Use with earlier models shall result + * in error. + */ + @CanIgnoreReturnValue + public Builder thinkingLevel(String thinkingLevel) { + return thinkingLevel(new ReinforcementTuningThinkingLevel(thinkingLevel)); + } + + public abstract ReinforcementTuningHyperParameters build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningHyperParameters object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningHyperParameters fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ReinforcementTuningHyperParameters.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java b/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java new file mode 100644 index 00000000000..00cd42c4e8b --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningParseResponseConfig.java @@ -0,0 +1,131 @@ +/* + * 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; + +/** Defines how to parse sample response for reinforcement tuning. */ +@AutoValue +@JsonDeserialize(builder = ReinforcementTuningParseResponseConfig.Builder.class) +public abstract class ReinforcementTuningParseResponseConfig extends JsonSerializable { + /** Defines how to parse 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`. + */ + @JsonProperty("regexExtractExpression") + public abstract Optional regexExtractExpression(); + + /** Instantiates a builder for ReinforcementTuningParseResponseConfig. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningParseResponseConfig.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningParseResponseConfig. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningParseResponseConfig.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningParseResponseConfig.Builder(); + } + + /** + * Setter for parseType. + * + *

parseType: Defines how to parse sample response. + */ + @JsonProperty("parseType") + public abstract Builder parseType(ResponseParseType parseType); + + @ExcludeFromGeneratedCoverageReport + abstract Builder parseType(Optional parseType); + + /** Clears the value of parseType field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearParseType() { + return parseType(Optional.empty()); + } + + /** + * Setter for parseType given a known enum. + * + *

parseType: Defines how to parse sample response. + */ + @CanIgnoreReturnValue + public Builder parseType(ResponseParseType.Known knownType) { + return parseType(new ResponseParseType(knownType)); + } + + /** + * Setter for parseType given a string. + * + *

parseType: Defines how to parse sample response. + */ + @CanIgnoreReturnValue + public Builder parseType(String parseType) { + return parseType(new ResponseParseType(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`. + */ + @JsonProperty("regexExtractExpression") + public abstract Builder regexExtractExpression(String regexExtractExpression); + + @ExcludeFromGeneratedCoverageReport + abstract Builder regexExtractExpression(Optional regexExtractExpression); + + /** Clears the value of regexExtractExpression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearRegexExtractExpression() { + return regexExtractExpression(Optional.empty()); + } + + public abstract ReinforcementTuningParseResponseConfig build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningParseResponseConfig object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningParseResponseConfig fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningParseResponseConfig.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java b/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java new file mode 100644 index 00000000000..552f3a73ec1 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningSpec.java @@ -0,0 +1,217 @@ +/* + * 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; + +/** Reinforcement tuning spec for tuning. */ +@AutoValue +@JsonDeserialize(builder = ReinforcementTuningSpec.Builder.class) +public abstract class ReinforcementTuningSpec extends JsonSerializable { + /** */ + @JsonProperty("compositeRewardConfig") + public abstract Optional compositeRewardConfig(); + + /** + * Cloud Storage path to 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. + */ + @JsonProperty("validationDatasetUri") + public abstract Optional validationDatasetUri(); + + /** Additional hyper-parameters to use during tuning. */ + @JsonProperty("hyperParameters") + public abstract Optional hyperParameters(); + + /** Single reward function configuration for reinforcement tuning. */ + @JsonProperty("singleRewardConfig") + public abstract Optional singleRewardConfig(); + + /** Instantiates a builder for ReinforcementTuningSpec. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningSpec.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningSpec. */ + @AutoValue.Builder + public abstract static class Builder { + /** For internal usage. Please use `ReinforcementTuningSpec.builder()` for instantiation. */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningSpec.Builder(); + } + + /** + * Setter for compositeRewardConfig. + * + *

compositeRewardConfig: + */ + @JsonProperty("compositeRewardConfig") + public abstract Builder compositeRewardConfig( + CompositeReinforcementTuningRewardConfig compositeRewardConfig); + + /** + * Setter for compositeRewardConfig builder. + * + *

compositeRewardConfig: + */ + @CanIgnoreReturnValue + public Builder compositeRewardConfig( + CompositeReinforcementTuningRewardConfig.Builder compositeRewardConfigBuilder) { + return compositeRewardConfig(compositeRewardConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder compositeRewardConfig( + Optional compositeRewardConfig); + + /** Clears the value of compositeRewardConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCompositeRewardConfig() { + return compositeRewardConfig(Optional.empty()); + } + + /** + * Setter for trainingDatasetUri. + * + *

trainingDatasetUri: Cloud Storage path to file containing training dataset for tuning. The + * dataset must be formatted as a JSONL file. + */ + @JsonProperty("trainingDatasetUri") + public abstract Builder trainingDatasetUri(String trainingDatasetUri); + + @ExcludeFromGeneratedCoverageReport + abstract Builder trainingDatasetUri(Optional trainingDatasetUri); + + /** Clears the value of trainingDatasetUri field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearTrainingDatasetUri() { + return trainingDatasetUri(Optional.empty()); + } + + /** + * 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. + */ + @JsonProperty("validationDatasetUri") + public abstract Builder validationDatasetUri(String validationDatasetUri); + + @ExcludeFromGeneratedCoverageReport + abstract Builder validationDatasetUri(Optional validationDatasetUri); + + /** Clears the value of validationDatasetUri field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearValidationDatasetUri() { + return validationDatasetUri(Optional.empty()); + } + + /** + * Setter for hyperParameters. + * + *

hyperParameters: Additional hyper-parameters to use during tuning. + */ + @JsonProperty("hyperParameters") + public abstract Builder hyperParameters(ReinforcementTuningHyperParameters hyperParameters); + + /** + * Setter for hyperParameters builder. + * + *

hyperParameters: Additional hyper-parameters to use during tuning. + */ + @CanIgnoreReturnValue + public Builder hyperParameters( + ReinforcementTuningHyperParameters.Builder hyperParametersBuilder) { + return hyperParameters(hyperParametersBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder hyperParameters(Optional hyperParameters); + + /** Clears the value of hyperParameters field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearHyperParameters() { + return hyperParameters(Optional.empty()); + } + + /** + * Setter for singleRewardConfig. + * + *

singleRewardConfig: Single reward function configuration for reinforcement tuning. + */ + @JsonProperty("singleRewardConfig") + public abstract Builder singleRewardConfig( + SingleReinforcementTuningRewardConfig singleRewardConfig); + + /** + * Setter for singleRewardConfig builder. + * + *

singleRewardConfig: Single reward function configuration for reinforcement tuning. + */ + @CanIgnoreReturnValue + public Builder singleRewardConfig( + SingleReinforcementTuningRewardConfig.Builder singleRewardConfigBuilder) { + return singleRewardConfig(singleRewardConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder singleRewardConfig( + Optional singleRewardConfig); + + /** Clears the value of singleRewardConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearSingleRewardConfig() { + return singleRewardConfig(Optional.empty()); + } + + public abstract ReinforcementTuningSpec build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningSpec object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningSpec fromJson(String jsonString) { + return JsonSerializable.fromJsonString(jsonString, ReinforcementTuningSpec.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java new file mode 100644 index 00000000000..c86ec10ffbc --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorer.java @@ -0,0 +1,191 @@ +/* + * 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; + +/** Scores parsed responses for string matching use cases. */ +@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. + */ + @JsonProperty("wrongAnswerReward") + public abstract Optional wrongAnswerReward(); + + /** + * Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the + * same reward. + */ + @JsonProperty("correctAnswerReward") + public abstract Optional correctAnswerReward(); + + /** Uses string match expression to evaluate parsed response. */ + @JsonProperty("stringMatchExpression") + public abstract Optional + stringMatchExpression(); + + /** Uses json match expression to evaluate parsed response. */ + @JsonProperty("jsonMatchExpression") + public abstract Optional + jsonMatchExpression(); + + /** Instantiates a builder for ReinforcementTuningStringMatchRewardScorer. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorer.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningStringMatchRewardScorer. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use `ReinforcementTuningStringMatchRewardScorer.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorer.Builder(); + } + + /** + * Setter for wrongAnswerReward. + * + *

wrongAnswerReward: Wrong answer reward is returned if evaluator evaluates to `false`. All + * wrong answers get the same reward. + */ + @JsonProperty("wrongAnswerReward") + public abstract Builder wrongAnswerReward(Float wrongAnswerReward); + + @ExcludeFromGeneratedCoverageReport + abstract Builder wrongAnswerReward(Optional wrongAnswerReward); + + /** Clears the value of wrongAnswerReward field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearWrongAnswerReward() { + return wrongAnswerReward(Optional.empty()); + } + + /** + * Setter for correctAnswerReward. + * + *

correctAnswerReward: Correct answer reward is returned if evaluator evaluates to `true`. + * All correct answers get the same reward. + */ + @JsonProperty("correctAnswerReward") + public abstract Builder correctAnswerReward(Float correctAnswerReward); + + @ExcludeFromGeneratedCoverageReport + abstract Builder correctAnswerReward(Optional correctAnswerReward); + + /** Clears the value of correctAnswerReward field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCorrectAnswerReward() { + return correctAnswerReward(Optional.empty()); + } + + /** + * Setter for stringMatchExpression. + * + *

stringMatchExpression: Uses string match expression to evaluate parsed response. + */ + @JsonProperty("stringMatchExpression") + public abstract Builder stringMatchExpression( + ReinforcementTuningStringMatchRewardScorerStringMatchExpression stringMatchExpression); + + /** + * Setter for stringMatchExpression builder. + * + *

stringMatchExpression: Uses string match expression to evaluate parsed response. + */ + @CanIgnoreReturnValue + public Builder stringMatchExpression( + ReinforcementTuningStringMatchRewardScorerStringMatchExpression.Builder + stringMatchExpressionBuilder) { + return stringMatchExpression(stringMatchExpressionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder stringMatchExpression( + Optional + stringMatchExpression); + + /** Clears the value of stringMatchExpression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearStringMatchExpression() { + return stringMatchExpression(Optional.empty()); + } + + /** + * Setter for jsonMatchExpression. + * + *

jsonMatchExpression: Uses json match expression to evaluate parsed response. + */ + @JsonProperty("jsonMatchExpression") + public abstract Builder jsonMatchExpression( + ReinforcementTuningStringMatchRewardScorerJsonMatchExpression jsonMatchExpression); + + /** + * Setter for jsonMatchExpression builder. + * + *

jsonMatchExpression: Uses json match expression to evaluate parsed response. + */ + @CanIgnoreReturnValue + public Builder jsonMatchExpression( + ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.Builder + jsonMatchExpressionBuilder) { + return jsonMatchExpression(jsonMatchExpressionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder jsonMatchExpression( + Optional + jsonMatchExpression); + + /** Clears the value of jsonMatchExpression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearJsonMatchExpression() { + return jsonMatchExpression(Optional.empty()); + } + + public abstract ReinforcementTuningStringMatchRewardScorer build(); + } + + /** Deserializes a JSON string to a ReinforcementTuningStringMatchRewardScorer object. */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningStringMatchRewardScorer fromJson(String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningStringMatchRewardScorer.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java new file mode 100644 index 00000000000..c6521a834c7 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.java @@ -0,0 +1,134 @@ +/* + * 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; + +/** + * Converts parsed responses to JSON format, finds the first-level matching key, then performs + * StringMatchExpression on the value. + */ +@AutoValue +@JsonDeserialize( + builder = ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.Builder.class) +public abstract class ReinforcementTuningStringMatchRewardScorerJsonMatchExpression + extends JsonSerializable { + /** Json key name to find the value to match against. */ + @JsonProperty("keyName") + public abstract Optional keyName(); + + /** String match expression to match against the value of json key. */ + @JsonProperty("valueStringMatchExpression") + public abstract Optional + valueStringMatchExpression(); + + /** Instantiates a builder for ReinforcementTuningStringMatchRewardScorerJsonMatchExpression. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningStringMatchRewardScorerJsonMatchExpression. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use + * `ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.builder()` for instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.Builder(); + } + + /** + * Setter for keyName. + * + *

keyName: Json key name to find the value to match against. + */ + @JsonProperty("keyName") + public abstract Builder keyName(String keyName); + + @ExcludeFromGeneratedCoverageReport + abstract Builder keyName(Optional keyName); + + /** Clears the value of keyName field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearKeyName() { + return keyName(Optional.empty()); + } + + /** + * Setter for valueStringMatchExpression. + * + *

valueStringMatchExpression: String match expression to match against the value of json + * key. + */ + @JsonProperty("valueStringMatchExpression") + public abstract Builder valueStringMatchExpression( + ReinforcementTuningStringMatchRewardScorerStringMatchExpression valueStringMatchExpression); + + /** + * Setter for valueStringMatchExpression builder. + * + *

valueStringMatchExpression: String match expression to match against the value of json + * key. + */ + @CanIgnoreReturnValue + public Builder valueStringMatchExpression( + ReinforcementTuningStringMatchRewardScorerStringMatchExpression.Builder + valueStringMatchExpressionBuilder) { + return valueStringMatchExpression(valueStringMatchExpressionBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder valueStringMatchExpression( + Optional + valueStringMatchExpression); + + /** Clears the value of valueStringMatchExpression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearValueStringMatchExpression() { + return valueStringMatchExpression(Optional.empty()); + } + + public abstract ReinforcementTuningStringMatchRewardScorerJsonMatchExpression build(); + } + + /** + * Deserializes a JSON string to a ReinforcementTuningStringMatchRewardScorerJsonMatchExpression + * object. + */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningStringMatchRewardScorerJsonMatchExpression fromJson( + String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningStringMatchRewardScorerJsonMatchExpression.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java new file mode 100644 index 00000000000..6cacc2a333a --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningStringMatchRewardScorerStringMatchExpression.java @@ -0,0 +1,141 @@ +/* + * 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; + +/** Evaluates parsed response using match type against expression. */ +@AutoValue +@JsonDeserialize( + builder = ReinforcementTuningStringMatchRewardScorerStringMatchExpression.Builder.class) +public abstract class ReinforcementTuningStringMatchRewardScorerStringMatchExpression + extends JsonSerializable { + /** Match operation to use for evaluation. */ + @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). + */ + @JsonProperty("expression") + public abstract Optional expression(); + + /** Instantiates a builder for ReinforcementTuningStringMatchRewardScorerStringMatchExpression. */ + @ExcludeFromGeneratedCoverageReport + public static Builder builder() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorerStringMatchExpression.Builder(); + } + + /** Creates a builder with the same values as this instance. */ + public abstract Builder toBuilder(); + + /** Builder for ReinforcementTuningStringMatchRewardScorerStringMatchExpression. */ + @AutoValue.Builder + public abstract static class Builder { + /** + * For internal usage. Please use + * `ReinforcementTuningStringMatchRewardScorerStringMatchExpression.builder()` for + * instantiation. + */ + @JsonCreator + private static Builder create() { + return new AutoValue_ReinforcementTuningStringMatchRewardScorerStringMatchExpression + .Builder(); + } + + /** + * Setter for matchOperation. + * + *

matchOperation: Match operation to use for evaluation. + */ + @JsonProperty("matchOperation") + public abstract Builder matchOperation(MatchOperation matchOperation); + + @ExcludeFromGeneratedCoverageReport + abstract Builder matchOperation(Optional matchOperation); + + /** Clears the value of matchOperation field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearMatchOperation() { + return matchOperation(Optional.empty()); + } + + /** + * Setter for matchOperation given a known enum. + * + *

matchOperation: Match operation to use for evaluation. + */ + @CanIgnoreReturnValue + public Builder matchOperation(MatchOperation.Known knownType) { + return matchOperation(new MatchOperation(knownType)); + } + + /** + * Setter for matchOperation given a string. + * + *

matchOperation: Match operation to use for evaluation. + */ + @CanIgnoreReturnValue + public Builder matchOperation(String matchOperation) { + return matchOperation(new MatchOperation(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). + */ + @JsonProperty("expression") + public abstract Builder expression(String expression); + + @ExcludeFromGeneratedCoverageReport + abstract Builder expression(Optional expression); + + /** Clears the value of expression field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearExpression() { + return expression(Optional.empty()); + } + + public abstract ReinforcementTuningStringMatchRewardScorerStringMatchExpression build(); + } + + /** + * Deserializes a JSON string to a ReinforcementTuningStringMatchRewardScorerStringMatchExpression + * object. + */ + @ExcludeFromGeneratedCoverageReport + public static ReinforcementTuningStringMatchRewardScorerStringMatchExpression fromJson( + String jsonString) { + return JsonSerializable.fromJsonString( + jsonString, ReinforcementTuningStringMatchRewardScorerStringMatchExpression.class); + } +} diff --git a/src/main/java/com/google/genai/types/ReinforcementTuningThinkingLevel.java b/src/main/java/com/google/genai/types/ReinforcementTuningThinkingLevel.java new file mode 100644 index 00000000000..927d771cc86 --- /dev/null +++ b/src/main/java/com/google/genai/types/ReinforcementTuningThinkingLevel.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 com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.google.common.base.Ascii; +import java.util.Objects; + +/** Represents how much to think for the tuning job. */ +public class ReinforcementTuningThinkingLevel { + + /** Enum representing the known values for ReinforcementTuningThinkingLevel. */ + public enum Known { + /** Unspecified thinking level. */ + REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED, + + /** Little to no thinking. */ + MINIMAL, + + /** High thinking level. */ + HIGH + } + + private Known reinforcementTuningThinkingLevelEnum; + private final String value; + + @JsonCreator + public ReinforcementTuningThinkingLevel(String value) { + this.value = value; + for (Known reinforcementTuningThinkingLevelEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(reinforcementTuningThinkingLevelEnum.toString(), value)) { + this.reinforcementTuningThinkingLevelEnum = reinforcementTuningThinkingLevelEnum; + break; + } + } + if (this.reinforcementTuningThinkingLevelEnum == null) { + this.reinforcementTuningThinkingLevelEnum = + Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED; + } + } + + public ReinforcementTuningThinkingLevel(Known knownValue) { + this.reinforcementTuningThinkingLevelEnum = 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 ReinforcementTuningThinkingLevel)) { + return false; + } + + ReinforcementTuningThinkingLevel other = (ReinforcementTuningThinkingLevel) o; + + if (this.reinforcementTuningThinkingLevelEnum + != Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED + && other.reinforcementTuningThinkingLevelEnum + != Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED) { + return this.reinforcementTuningThinkingLevelEnum + == other.reinforcementTuningThinkingLevelEnum; + } else if (this.reinforcementTuningThinkingLevelEnum + == Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED + && other.reinforcementTuningThinkingLevelEnum + == Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.reinforcementTuningThinkingLevelEnum + != Known.REINFORCEMENT_TUNING_THINKING_LEVEL_UNSPECIFIED) { + return this.reinforcementTuningThinkingLevelEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.reinforcementTuningThinkingLevelEnum; + } +} diff --git a/src/main/java/com/google/genai/types/ResponseParseType.java b/src/main/java/com/google/genai/types/ResponseParseType.java new file mode 100644 index 00000000000..e4e3068911a --- /dev/null +++ b/src/main/java/com/google/genai/types/ResponseParseType.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; + +/** Defines how to parse sample response. */ +public class ResponseParseType { + + /** Enum representing the known values for ResponseParseType. */ + public enum Known { + /** Default value. This value is unused. */ + RESPONSE_PARSE_TYPE_UNSPECIFIED, + + /** Use the sample response as is. */ + IDENTITY, + + /** Use regex to extract the important part of sample response. */ + REGEX_EXTRACT + } + + private Known responseParseTypeEnum; + private final String value; + + @JsonCreator + public ResponseParseType(String value) { + this.value = value; + for (Known responseParseTypeEnum : Known.values()) { + if (Ascii.equalsIgnoreCase(responseParseTypeEnum.toString(), value)) { + this.responseParseTypeEnum = responseParseTypeEnum; + break; + } + } + if (this.responseParseTypeEnum == null) { + this.responseParseTypeEnum = Known.RESPONSE_PARSE_TYPE_UNSPECIFIED; + } + } + + public ResponseParseType(Known knownValue) { + this.responseParseTypeEnum = 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 ResponseParseType)) { + return false; + } + + ResponseParseType other = (ResponseParseType) o; + + if (this.responseParseTypeEnum != Known.RESPONSE_PARSE_TYPE_UNSPECIFIED + && other.responseParseTypeEnum != Known.RESPONSE_PARSE_TYPE_UNSPECIFIED) { + return this.responseParseTypeEnum == other.responseParseTypeEnum; + } else if (this.responseParseTypeEnum == Known.RESPONSE_PARSE_TYPE_UNSPECIFIED + && other.responseParseTypeEnum == Known.RESPONSE_PARSE_TYPE_UNSPECIFIED) { + return this.value.equals(other.value); + } + return false; + } + + @ExcludeFromGeneratedCoverageReport + @Override + public int hashCode() { + if (this.responseParseTypeEnum != Known.RESPONSE_PARSE_TYPE_UNSPECIFIED) { + return this.responseParseTypeEnum.hashCode(); + } else { + return Objects.hashCode(this.value); + } + } + + @ExcludeFromGeneratedCoverageReport + public Known knownEnum() { + return this.responseParseTypeEnum; + } +} diff --git a/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java b/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java index c52ca38b20f..b04cd3d81cd 100644 --- a/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java +++ b/src/main/java/com/google/genai/types/SingleReinforcementTuningRewardConfig.java @@ -30,10 +30,34 @@ @AutoValue @JsonDeserialize(builder = SingleReinforcementTuningRewardConfig.Builder.class) public abstract class SingleReinforcementTuningRewardConfig extends JsonSerializable { - /** */ + /** Scores parsed responses for autorater use cases by using a model to compute the reward. */ @JsonProperty("autoraterScorer") public abstract Optional autoraterScorer(); + /** A unique reward name used to identify each single reinforcement tuning reward. */ + @JsonProperty("rewardName") + public abstract Optional rewardName(); + + /** Defines how to parse sample response. */ + @JsonProperty("parseResponseConfig") + public abstract Optional parseResponseConfig(); + + /** Scores 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. + */ + @JsonProperty("stringMatchRewardScorer") + public abstract Optional stringMatchRewardScorer(); + + /** Scores parsed responses by calling a Cloud Run service. */ + @JsonProperty("cloudRunRewardScorer") + public abstract Optional cloudRunRewardScorer(); + /** Instantiates a builder for SingleReinforcementTuningRewardConfig. */ @ExcludeFromGeneratedCoverageReport public static Builder builder() { @@ -58,7 +82,8 @@ private static Builder create() { /** * Setter for autoraterScorer. * - *

autoraterScorer: + *

autoraterScorer: Scores parsed responses for autorater use cases by using a model to + * compute the reward. */ @JsonProperty("autoraterScorer") public abstract Builder autoraterScorer(ReinforcementTuningAutoraterScorer autoraterScorer); @@ -66,7 +91,8 @@ private static Builder create() { /** * Setter for autoraterScorer builder. * - *

autoraterScorer: + *

autoraterScorer: Scores parsed responses for autorater use cases by using a model to + * compute the reward. */ @CanIgnoreReturnValue public Builder autoraterScorer( @@ -84,6 +110,150 @@ public Builder clearAutoraterScorer() { return autoraterScorer(Optional.empty()); } + /** + * Setter for rewardName. + * + *

rewardName: A unique reward name used to identify each single reinforcement tuning reward. + */ + @JsonProperty("rewardName") + public abstract Builder rewardName(String rewardName); + + @ExcludeFromGeneratedCoverageReport + abstract Builder rewardName(Optional rewardName); + + /** Clears the value of rewardName field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearRewardName() { + return rewardName(Optional.empty()); + } + + /** + * Setter for parseResponseConfig. + * + *

parseResponseConfig: Defines how to parse sample response. + */ + @JsonProperty("parseResponseConfig") + public abstract Builder parseResponseConfig( + ReinforcementTuningParseResponseConfig parseResponseConfig); + + /** + * Setter for parseResponseConfig builder. + * + *

parseResponseConfig: Defines how to parse sample response. + */ + @CanIgnoreReturnValue + public Builder parseResponseConfig( + ReinforcementTuningParseResponseConfig.Builder parseResponseConfigBuilder) { + return parseResponseConfig(parseResponseConfigBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder parseResponseConfig( + Optional parseResponseConfig); + + /** Clears the value of parseResponseConfig field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearParseResponseConfig() { + return parseResponseConfig(Optional.empty()); + } + + /** + * Setter for codeExecutionRewardScorer. + * + *

codeExecutionRewardScorer: Scores parsed responses for code execution use cases. + */ + @JsonProperty("codeExecutionRewardScorer") + public abstract Builder codeExecutionRewardScorer( + ReinforcementTuningCodeExecutionRewardScorer codeExecutionRewardScorer); + + /** + * Setter for codeExecutionRewardScorer builder. + * + *

codeExecutionRewardScorer: Scores parsed responses for code execution use cases. + */ + @CanIgnoreReturnValue + public Builder codeExecutionRewardScorer( + ReinforcementTuningCodeExecutionRewardScorer.Builder codeExecutionRewardScorerBuilder) { + return codeExecutionRewardScorer(codeExecutionRewardScorerBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder codeExecutionRewardScorer( + Optional codeExecutionRewardScorer); + + /** Clears the value of codeExecutionRewardScorer field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCodeExecutionRewardScorer() { + return codeExecutionRewardScorer(Optional.empty()); + } + + /** + * Setter for stringMatchRewardScorer. + * + *

stringMatchRewardScorer: Scores parsed responses for simple string matching use cases + * against reference answer without writing python code. + */ + @JsonProperty("stringMatchRewardScorer") + public abstract Builder stringMatchRewardScorer( + ReinforcementTuningStringMatchRewardScorer stringMatchRewardScorer); + + /** + * Setter for stringMatchRewardScorer builder. + * + *

stringMatchRewardScorer: Scores parsed responses for simple string matching use cases + * against reference answer without writing python code. + */ + @CanIgnoreReturnValue + public Builder stringMatchRewardScorer( + ReinforcementTuningStringMatchRewardScorer.Builder stringMatchRewardScorerBuilder) { + return stringMatchRewardScorer(stringMatchRewardScorerBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder stringMatchRewardScorer( + Optional stringMatchRewardScorer); + + /** Clears the value of stringMatchRewardScorer field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearStringMatchRewardScorer() { + return stringMatchRewardScorer(Optional.empty()); + } + + /** + * Setter for cloudRunRewardScorer. + * + *

cloudRunRewardScorer: Scores parsed responses by calling a Cloud Run service. + */ + @JsonProperty("cloudRunRewardScorer") + public abstract Builder cloudRunRewardScorer( + ReinforcementTuningCloudRunRewardScorer cloudRunRewardScorer); + + /** + * Setter for cloudRunRewardScorer builder. + * + *

cloudRunRewardScorer: Scores parsed responses by calling a Cloud Run service. + */ + @CanIgnoreReturnValue + public Builder cloudRunRewardScorer( + ReinforcementTuningCloudRunRewardScorer.Builder cloudRunRewardScorerBuilder) { + return cloudRunRewardScorer(cloudRunRewardScorerBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder cloudRunRewardScorer( + Optional cloudRunRewardScorer); + + /** Clears the value of cloudRunRewardScorer field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearCloudRunRewardScorer() { + return cloudRunRewardScorer(Optional.empty()); + } + public abstract SingleReinforcementTuningRewardConfig build(); } diff --git a/src/main/java/com/google/genai/types/TuningJob.java b/src/main/java/com/google/genai/types/TuningJob.java index 4eb482efab6..f6dc5db8533 100644 --- a/src/main/java/com/google/genai/types/TuningJob.java +++ b/src/main/java/com/google/genai/types/TuningJob.java @@ -109,6 +109,10 @@ public abstract class TuningJob extends JsonSerializable { @JsonProperty("distillationSpec") public abstract Optional distillationSpec(); + /** */ + @JsonProperty("reinforcementTuningSpec") + public abstract Optional reinforcementTuningSpec(); + /** Output only. The tuning data statistics associated with this TuningJob. */ @JsonProperty("tuningDataStats") public abstract Optional tuningDataStats(); @@ -600,6 +604,37 @@ public Builder clearDistillationSpec() { return distillationSpec(Optional.empty()); } + /** + * Setter for reinforcementTuningSpec. + * + *

reinforcementTuningSpec: + */ + @JsonProperty("reinforcementTuningSpec") + public abstract Builder reinforcementTuningSpec( + ReinforcementTuningSpec reinforcementTuningSpec); + + /** + * Setter for reinforcementTuningSpec builder. + * + *

reinforcementTuningSpec: + */ + @CanIgnoreReturnValue + public Builder reinforcementTuningSpec( + ReinforcementTuningSpec.Builder reinforcementTuningSpecBuilder) { + return reinforcementTuningSpec(reinforcementTuningSpecBuilder.build()); + } + + @ExcludeFromGeneratedCoverageReport + abstract Builder reinforcementTuningSpec( + Optional reinforcementTuningSpec); + + /** Clears the value of reinforcementTuningSpec field. */ + @ExcludeFromGeneratedCoverageReport + @CanIgnoreReturnValue + public Builder clearReinforcementTuningSpec() { + return reinforcementTuningSpec(Optional.empty()); + } + /** * Setter for tuningDataStats. *