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
11 changes: 5 additions & 6 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -1183,11 +1183,11 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject
Common.setValueByPath(parentObject, new String[] {"setup", "safetySettings"}, result);
}

if (Common.getValueByPath(fromObject, new String[] {"streamTranslationConfig"}) != null) {
if (Common.getValueByPath(fromObject, new String[] {"translationConfig"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "generationConfig", "streamTranslationConfig"},
Common.getValueByPath(fromObject, new String[] {"streamTranslationConfig"}));
new String[] {"setup", "generationConfig", "translationConfig"},
Common.getValueByPath(fromObject, new String[] {"translationConfig"}));
}

return toObject;
Expand Down Expand Up @@ -1355,10 +1355,9 @@ ObjectNode liveConnectConfigToVertex(JsonNode fromObject, ObjectNode parentObjec
Common.getValueByPath(fromObject, new String[] {"safetySettings"}));
}

if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"streamTranslationConfig"}))) {
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"translationConfig"}))) {
throw new IllegalArgumentException(
"streamTranslationConfig parameter is only supported in Gemini Developer API mode, not in"
"translationConfig parameter is only supported in Gemini Developer API mode, not in"
+ " Gemini Enterprise Agent Platform mode.");
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/google/genai/TokensConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,11 @@ ObjectNode liveConnectConfigToMldev(JsonNode fromObject, ObjectNode parentObject
Common.setValueByPath(parentObject, new String[] {"setup", "safetySettings"}, result);
}

if (Common.getValueByPath(fromObject, new String[] {"streamTranslationConfig"}) != null) {
if (Common.getValueByPath(fromObject, new String[] {"translationConfig"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "generationConfig", "streamTranslationConfig"},
Common.getValueByPath(fromObject, new String[] {"streamTranslationConfig"}));
new String[] {"setup", "generationConfig", "translationConfig"},
Common.getValueByPath(fromObject, new String[] {"translationConfig"}));
}

return toObject;
Expand Down
33 changes: 15 additions & 18 deletions src/main/java/com/google/genai/types/LiveConnectConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public abstract class LiveConnectConfig extends JsonSerializable {
@JsonProperty("safetySettings")
public abstract Optional<List<SafetySetting>> safetySettings();

/** Config for stream translation. */
@JsonProperty("streamTranslationConfig")
public abstract Optional<StreamTranslationConfig> streamTranslationConfig();
/** Config for translation. */
@JsonProperty("translationConfig")
public abstract Optional<TranslationConfig> translationConfig();

/** Instantiates a builder for LiveConnectConfig. */
@ExcludeFromGeneratedCoverageReport
Expand Down Expand Up @@ -871,34 +871,31 @@ public Builder clearSafetySettings() {
}

/**
* Setter for streamTranslationConfig.
* Setter for translationConfig.
*
* <p>streamTranslationConfig: Config for stream translation.
* <p>translationConfig: Config for translation.
*/
@JsonProperty("streamTranslationConfig")
public abstract Builder streamTranslationConfig(
StreamTranslationConfig streamTranslationConfig);
@JsonProperty("translationConfig")
public abstract Builder translationConfig(TranslationConfig translationConfig);

/**
* Setter for streamTranslationConfig builder.
* Setter for translationConfig builder.
*
* <p>streamTranslationConfig: Config for stream translation.
* <p>translationConfig: Config for translation.
*/
@CanIgnoreReturnValue
public Builder streamTranslationConfig(
StreamTranslationConfig.Builder streamTranslationConfigBuilder) {
return streamTranslationConfig(streamTranslationConfigBuilder.build());
public Builder translationConfig(TranslationConfig.Builder translationConfigBuilder) {
return translationConfig(translationConfigBuilder.build());
}

@ExcludeFromGeneratedCoverageReport
abstract Builder streamTranslationConfig(
Optional<StreamTranslationConfig> streamTranslationConfig);
abstract Builder translationConfig(Optional<TranslationConfig> translationConfig);

/** Clears the value of streamTranslationConfig field. */
/** Clears the value of translationConfig field. */
@ExcludeFromGeneratedCoverageReport
@CanIgnoreReturnValue
public Builder clearStreamTranslationConfig() {
return streamTranslationConfig(Optional.empty());
public Builder clearTranslationConfig() {
return translationConfig(Optional.empty());
}

public abstract LiveConnectConfig build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

/** Config for stream translation. */
@AutoValue
@JsonDeserialize(builder = StreamTranslationConfig.Builder.class)
public abstract class StreamTranslationConfig extends JsonSerializable {
@JsonDeserialize(builder = TranslationConfig.Builder.class)
public abstract class TranslationConfig extends JsonSerializable {
/**
* 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.
Expand All @@ -44,22 +44,22 @@ public abstract class StreamTranslationConfig extends JsonSerializable {
@JsonProperty("targetLanguageCode")
public abstract Optional<String> targetLanguageCode();

/** Instantiates a builder for StreamTranslationConfig. */
/** Instantiates a builder for TranslationConfig. */
@ExcludeFromGeneratedCoverageReport
public static Builder builder() {
return new AutoValue_StreamTranslationConfig.Builder();
return new AutoValue_TranslationConfig.Builder();
}

/** Creates a builder with the same values as this instance. */
public abstract Builder toBuilder();

/** Builder for StreamTranslationConfig. */
/** Builder for TranslationConfig. */
@AutoValue.Builder
public abstract static class Builder {
/** For internal usage. Please use `StreamTranslationConfig.builder()` for instantiation. */
/** For internal usage. Please use `TranslationConfig.builder()` for instantiation. */
@JsonCreator
private static Builder create() {
return new AutoValue_StreamTranslationConfig.Builder();
return new AutoValue_TranslationConfig.Builder();
}

/**
Expand Down Expand Up @@ -101,12 +101,12 @@ public Builder clearTargetLanguageCode() {
return targetLanguageCode(Optional.empty());
}

public abstract StreamTranslationConfig build();
public abstract TranslationConfig build();
}

/** Deserializes a JSON string to a StreamTranslationConfig object. */
/** Deserializes a JSON string to a TranslationConfig object. */
@ExcludeFromGeneratedCoverageReport
public static StreamTranslationConfig fromJson(String jsonString) {
return JsonSerializable.fromJsonString(jsonString, StreamTranslationConfig.class);
public static TranslationConfig fromJson(String jsonString) {
return JsonSerializable.fromJsonString(jsonString, TranslationConfig.class);
}
}
Loading