Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/main/java/com/google/genai/Tunings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down
78 changes: 78 additions & 0 deletions src/main/java/com/google/genai/types/CreateTuningJobConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ public abstract class CreateTuningJobConfig extends JsonSerializable {
@JsonProperty("maxOutputTokens")
public abstract Optional<Integer> maxOutputTokens();

/**
* Indicates the maximum thinking depth. Use with earlier models shall result in error.
* Reinforcement tuning only.
*/
@JsonProperty("thinkingLevel")
public abstract Optional<ReinforcementTuningThinkingLevel> 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<String> validationDatasetUri();

/** Instantiates a builder for CreateTuningJobConfig. */
@ExcludeFromGeneratedCoverageReport
public static Builder builder() {
Expand Down Expand Up @@ -853,6 +869,68 @@ public Builder clearMaxOutputTokens() {
return maxOutputTokens(Optional.empty());
}

/**
* Setter for thinkingLevel.
*
* <p>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<ReinforcementTuningThinkingLevel> thinkingLevel);

/** Clears the value of thinkingLevel field. */
@ExcludeFromGeneratedCoverageReport
@CanIgnoreReturnValue
public Builder clearThinkingLevel() {
return thinkingLevel(Optional.empty());
}

/**
* Setter for thinkingLevel given a known enum.
*
* <p>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.
*
* <p>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.
*
* <p>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<String> validationDatasetUri);

/** Clears the value of validationDatasetUri field. */
@ExcludeFromGeneratedCoverageReport
@CanIgnoreReturnValue
public Builder clearValidationDatasetUri() {
return validationDatasetUri(Optional.empty());
}

public abstract CreateTuningJobConfig build();
}

Expand Down
114 changes: 114 additions & 0 deletions src/main/java/com/google/genai/types/MatchOperation.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading
Loading