Skip to content

Commit 695e17a

Browse files
sararobcopybara-github
authored andcommitted
feat: Add labels to create tuning job config
PiperOrigin-RevId: 805069788
1 parent 3773fe7 commit 695e17a

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/main/java/com/google/genai/Tunings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ ObjectNode createTuningJobConfigToMldev(JsonNode fromObject, ObjectNode parentOb
248248
Common.getValueByPath(fromObject, new String[] {"learningRate"}));
249249
}
250250

251+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"labels"}))) {
252+
throw new IllegalArgumentException("labels parameter is not supported in Gemini API.");
253+
}
254+
251255
return toObject;
252256
}
253257

@@ -490,6 +494,13 @@ ObjectNode createTuningJobConfigToVertex(JsonNode fromObject, ObjectNode parentO
490494
throw new IllegalArgumentException("learningRate parameter is not supported in Vertex AI.");
491495
}
492496

497+
if (Common.getValueByPath(fromObject, new String[] {"labels"}) != null) {
498+
Common.setValueByPath(
499+
parentObject,
500+
new String[] {"labels"},
501+
Common.getValueByPath(fromObject, new String[] {"labels"}));
502+
}
503+
493504
return toObject;
494505
}
495506

src/main/java/com/google/genai/types/CreateTuningJobConfig.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.auto.value.AutoValue;
2525
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2626
import com.google.genai.JsonSerializable;
27+
import java.util.Map;
2728
import java.util.Optional;
2829

2930
/** Supervised fine-tuning job creation request - optional fields. */
@@ -89,6 +90,16 @@ public abstract class CreateTuningJobConfig extends JsonSerializable {
8990
@JsonProperty("learningRate")
9091
public abstract Optional<Float> learningRate();
9192

93+
/**
94+
* Optional. The labels with user-defined metadata to organize TuningJob and generated resources
95+
* such as Model and Endpoint. Label keys and values can be no longer than 64 characters (Unicode
96+
* codepoints), can only contain lowercase letters, numeric characters, underscores and dashes.
97+
* International characters are allowed. See https://goo.gl/xmQnxf for more information and
98+
* examples of labels.
99+
*/
100+
@JsonProperty("labels")
101+
public abstract Optional<Map<String, String>> labels();
102+
92103
/** Instantiates a builder for CreateTuningJobConfig. */
93104
@ExcludeFromGeneratedCoverageReport
94105
public static Builder builder() {
@@ -242,6 +253,18 @@ public Builder adapterSize(String adapterSize) {
242253
@JsonProperty("learningRate")
243254
public abstract Builder learningRate(Float learningRate);
244255

256+
/**
257+
* Setter for labels.
258+
*
259+
* <p>labels: Optional. The labels with user-defined metadata to organize TuningJob and
260+
* generated resources such as Model and Endpoint. Label keys and values can be no longer than
261+
* 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters,
262+
* underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for
263+
* more information and examples of labels.
264+
*/
265+
@JsonProperty("labels")
266+
public abstract Builder labels(Map<String, String> labels);
267+
245268
public abstract CreateTuningJobConfig build();
246269
}
247270

0 commit comments

Comments
 (0)