From 76f4126a18dbb6c4606f649e1f8400003364f785 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Tue, 2 Jun 2026 12:24:00 -0700 Subject: [PATCH] feat: Add TranslationConfig for live translation. PiperOrigin-RevId: 925512170 --- live_converters.go | 10 +++++----- types.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/live_converters.go b/live_converters.go index 070ece64..f5b9e946 100644 --- a/live_converters.go +++ b/live_converters.go @@ -547,9 +547,9 @@ func liveConnectConfigToMldev(fromObject map[string]any, parentObject map[string InternalSetValueByPath(parentObject, []string{"setup", "safetySettings"}, fromSafetySettings) } - fromStreamTranslationConfig := InternalGetValueByPath(fromObject, []string{"streamTranslationConfig"}) - if fromStreamTranslationConfig != nil { - InternalSetValueByPath(parentObject, []string{"setup", "generationConfig", "streamTranslationConfig"}, fromStreamTranslationConfig) + fromTranslationConfig := InternalGetValueByPath(fromObject, []string{"translationConfig"}) + if fromTranslationConfig != nil { + InternalSetValueByPath(parentObject, []string{"setup", "generationConfig", "translationConfig"}, fromTranslationConfig) } return toObject, nil @@ -693,8 +693,8 @@ func liveConnectConfigToVertex(fromObject map[string]any, parentObject map[strin InternalSetValueByPath(parentObject, []string{"setup", "safetySettings"}, fromSafetySettings) } - if InternalGetValueByPath(fromObject, []string{"streamTranslationConfig"}) != nil { - return nil, fmt.Errorf("streamTranslationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.") + if InternalGetValueByPath(fromObject, []string{"translationConfig"}) != nil { + return nil, fmt.Errorf("translationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.") } return toObject, nil diff --git a/types.go b/types.go index 1237f57e..13c6be9f 100644 --- a/types.go +++ b/types.go @@ -7626,7 +7626,7 @@ type LiveClientMessage struct { } // Config for stream translation. -type StreamTranslationConfig struct { +type TranslationConfig struct { // Optional. If true, the model will generate audio when the target language is // spoken, essentially it will parrot the input. If false, we will not produce // audio for the target language. @@ -7710,8 +7710,8 @@ type LiveConnectConfig struct { // Optional. Safety settings in the request to block unsafe content in the // response. SafetySettings []*SafetySetting `json:"safetySettings,omitempty"` - // Optional. Config for stream translation. - StreamTranslationConfig *StreamTranslationConfig `json:"streamTranslationConfig,omitempty"` + // Optional. Config for translation. + TranslationConfig *TranslationConfig `json:"translationConfig,omitempty"` } // Parameters for sending client content to the live API.