From 973e322c1bf92e0119f1167724e58b7535b31f73 Mon Sep 17 00:00:00 2001 From: Google Team Member Date: Tue, 21 Jul 2026 12:51:14 -0700 Subject: [PATCH] feat: Add flat `language_codes` field to `AudioTranscriptionConfig`. FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/googleapis/java-genai/pull/1128 from googleapis:release-please--branches--main 5ffdc7901c37dc0f506495eaf3d0964e4a29bd82 PiperOrigin-RevId: 951647323 --- .../java/com/google/genai/LiveConverters.java | 60 ++----------------- .../com/google/genai/TokensConverters.java | 50 +--------------- .../genai/types/AudioTranscriptionConfig.java | 37 ++++++++---- .../com/google/genai/types/LanguageAuto.java | 2 +- .../com/google/genai/types/LanguageHints.java | 8 +-- 5 files changed, 35 insertions(+), 122 deletions(-) diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java index 56ea4c4cc49..d8d0a44838c 100644 --- a/src/main/java/com/google/genai/LiveConverters.java +++ b/src/main/java/com/google/genai/LiveConverters.java @@ -31,46 +31,6 @@ public LiveConverters(ApiClient apiClient) { this.apiClient = apiClient; } - @ExcludeFromGeneratedCoverageReport - ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { - ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) { - throw new IllegalArgumentException( - "languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not" - + " in Gemini Developer API mode."); - } - - if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"languageAuto"}, - Common.getValueByPath(fromObject, new String[] {"languageAuto"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"languageHints"}, - Common.getValueByPath(fromObject, new String[] {"languageHints"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"customVocabulary"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"customVocabulary"}, - Common.getValueByPath(fromObject, new String[] {"customVocabulary"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"adaptationPhrases"}, - Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); - } - - return toObject; - } - @ExcludeFromGeneratedCoverageReport ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); @@ -926,20 +886,14 @@ ObjectNode liveClientSetupToMldev(JsonNode fromObject, ObjectNode parentObject) Common.setValueByPath( toObject, new String[] {"inputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) { Common.setValueByPath( toObject, new String[] {"outputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"proactivity"}) != null) { @@ -1214,20 +1168,14 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject Common.setValueByPath( parentObject, new String[] {"setup", "inputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) { Common.setValueByPath( parentObject, new String[] {"setup", "outputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}) != null) { diff --git a/src/main/java/com/google/genai/TokensConverters.java b/src/main/java/com/google/genai/TokensConverters.java index ed18412e544..511f8f202e7 100644 --- a/src/main/java/com/google/genai/TokensConverters.java +++ b/src/main/java/com/google/genai/TokensConverters.java @@ -31,46 +31,6 @@ public TokensConverters(ApiClient apiClient) { this.apiClient = apiClient; } - @ExcludeFromGeneratedCoverageReport - ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { - ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); - if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) { - throw new IllegalArgumentException( - "languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not" - + " in Gemini Developer API mode."); - } - - if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"languageAuto"}, - Common.getValueByPath(fromObject, new String[] {"languageAuto"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"languageHints"}, - Common.getValueByPath(fromObject, new String[] {"languageHints"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"customVocabulary"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"customVocabulary"}, - Common.getValueByPath(fromObject, new String[] {"customVocabulary"})); - } - - if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) { - Common.setValueByPath( - toObject, - new String[] {"adaptationPhrases"}, - Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"})); - } - - return toObject; - } - @ExcludeFromGeneratedCoverageReport ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) { ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode(); @@ -479,20 +439,14 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject Common.setValueByPath( parentObject, new String[] {"setup", "inputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) { Common.setValueByPath( parentObject, new String[] {"setup", "outputAudioTranscription"}, - audioTranscriptionConfigToMldev( - JsonSerializable.toJsonNode( - Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})), - toObject)); + Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})); } if (Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}) != null) { diff --git a/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java b/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java index 1b35bd23970..027f6c641e2 100644 --- a/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java +++ b/src/main/java/com/google/genai/types/AudioTranscriptionConfig.java @@ -32,15 +32,24 @@ @AutoValue @JsonDeserialize(builder = AudioTranscriptionConfig.Builder.class) public abstract class AudioTranscriptionConfig extends JsonSerializable { - /** Deprecated: use LanguageAuto or LanguageHints instead. */ + /** + * BCP-47 language codes providing hints about the languages present in the audio. If omitted or + * empty, defaults to automatic language detection. + */ @JsonProperty("languageCodes") public abstract Optional> languageCodes(); - /** The model will detect the language automatically. Do not use together with LanguageHints. */ + /** + * Deprecated: Auto-detection is now the default when language_codes is omitted. This field will + * be removed in a future version. + */ @JsonProperty("languageAuto") public abstract Optional languageAuto(); - /** Specifies one or more languages in the audio. Do not use together with LanguageAuto. */ + /** + * Deprecated: Use top-level language_codes instead. This field will be removed in a future + * version. + */ @JsonProperty("languageHints") public abstract Optional languageHints(); @@ -79,7 +88,8 @@ private static Builder create() { /** * Setter for languageCodes. * - *

languageCodes: Deprecated: use LanguageAuto or LanguageHints instead. + *

languageCodes: BCP-47 language codes providing hints about the languages present in the + * audio. If omitted or empty, defaults to automatic language detection. */ @JsonProperty("languageCodes") public abstract Builder languageCodes(List languageCodes); @@ -87,7 +97,8 @@ private static Builder create() { /** * Setter for languageCodes. * - *

languageCodes: Deprecated: use LanguageAuto or LanguageHints instead. + *

languageCodes: BCP-47 language codes providing hints about the languages present in the + * audio. If omitted or empty, defaults to automatic language detection. */ @CanIgnoreReturnValue public Builder languageCodes(String... languageCodes) { @@ -107,8 +118,8 @@ public Builder clearLanguageCodes() { /** * Setter for languageAuto. * - *

languageAuto: The model will detect the language automatically. Do not use together with - * LanguageHints. + *

languageAuto: Deprecated: Auto-detection is now the default when language_codes is + * omitted. This field will be removed in a future version. */ @JsonProperty("languageAuto") public abstract Builder languageAuto(LanguageAuto languageAuto); @@ -116,8 +127,8 @@ public Builder clearLanguageCodes() { /** * Setter for languageAuto builder. * - *

languageAuto: The model will detect the language automatically. Do not use together with - * LanguageHints. + *

languageAuto: Deprecated: Auto-detection is now the default when language_codes is + * omitted. This field will be removed in a future version. */ @CanIgnoreReturnValue public Builder languageAuto(LanguageAuto.Builder languageAutoBuilder) { @@ -137,8 +148,8 @@ public Builder clearLanguageAuto() { /** * Setter for languageHints. * - *

languageHints: Specifies one or more languages in the audio. Do not use together with - * LanguageAuto. + *

languageHints: Deprecated: Use top-level language_codes instead. This field will be + * removed in a future version. */ @JsonProperty("languageHints") public abstract Builder languageHints(LanguageHints languageHints); @@ -146,8 +157,8 @@ public Builder clearLanguageAuto() { /** * Setter for languageHints builder. * - *

languageHints: Specifies one or more languages in the audio. Do not use together with - * LanguageAuto. + *

languageHints: Deprecated: Use top-level language_codes instead. This field will be + * removed in a future version. */ @CanIgnoreReturnValue public Builder languageHints(LanguageHints.Builder languageHintsBuilder) { diff --git a/src/main/java/com/google/genai/types/LanguageAuto.java b/src/main/java/com/google/genai/types/LanguageAuto.java index b675299ea38..98c1c5c1114 100644 --- a/src/main/java/com/google/genai/types/LanguageAuto.java +++ b/src/main/java/com/google/genai/types/LanguageAuto.java @@ -23,7 +23,7 @@ import com.google.auto.value.AutoValue; import com.google.genai.JsonSerializable; -/** Indicates the language of the audio should be automatically detected. */ +/** Deprecated: Language auto-detection is now the default when language_codes is omitted. */ @AutoValue @JsonDeserialize(builder = LanguageAuto.Builder.class) public abstract class LanguageAuto extends JsonSerializable { diff --git a/src/main/java/com/google/genai/types/LanguageHints.java b/src/main/java/com/google/genai/types/LanguageHints.java index 68c82eae239..9fd72cfb37b 100644 --- a/src/main/java/com/google/genai/types/LanguageHints.java +++ b/src/main/java/com/google/genai/types/LanguageHints.java @@ -28,11 +28,11 @@ import java.util.List; import java.util.Optional; -/** Provides hints to the model about possible languages present in the audio. */ +/** Deprecated: Use AudioTranscriptionConfig.language_codes instead. */ @AutoValue @JsonDeserialize(builder = LanguageHints.Builder.class) public abstract class LanguageHints extends JsonSerializable { - /** BCP-47 language codes. At least one must be specified. */ + /** Deprecated. BCP-47 language codes. */ @JsonProperty("languageCodes") public abstract Optional> languageCodes(); @@ -57,7 +57,7 @@ private static Builder create() { /** * Setter for languageCodes. * - *

languageCodes: BCP-47 language codes. At least one must be specified. + *

languageCodes: Deprecated. BCP-47 language codes. */ @JsonProperty("languageCodes") public abstract Builder languageCodes(List languageCodes); @@ -65,7 +65,7 @@ private static Builder create() { /** * Setter for languageCodes. * - *

languageCodes: BCP-47 language codes. At least one must be specified. + *

languageCodes: Deprecated. BCP-47 language codes. */ @CanIgnoreReturnValue public Builder languageCodes(String... languageCodes) {