Skip to content
Open
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
186 changes: 175 additions & 11 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,50 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode audioTranscriptionConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (Common.getValueByPath(fromObject, new String[] {"languageCodes"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"languageCodes"},
Common.getValueByPath(fromObject, new String[] {"languageCodes"}));
}

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"},
languageHintsToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"languageHints"})),
toObject));
}

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();
Expand Down Expand Up @@ -256,6 +300,24 @@ ObjectNode contentToVertex(JsonNode fromObject, ObjectNode parentObject) {
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode contextWindowCompressionConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"triggerTokens"}))) {
throw new IllegalArgumentException(
"triggerTokens parameter is only supported in Gemini Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
}

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

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode executableCodeToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -583,6 +645,31 @@ ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode historyConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"initialHistoryInClientContent"}))) {
throw new IllegalArgumentException(
"initialHistoryInClientContent parameter is only supported in Gemini Developer API mode,"
+ " not in Gemini Enterprise Agent Platform mode.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode languageHintsToVertex(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 Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode liveClientContentToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -1032,35 +1119,50 @@ ObjectNode liveClientSetupToVertex(JsonNode fromObject, ObjectNode parentObject)
Common.setValueByPath(
toObject,
new String[] {"realtimeInputConfig"},
Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}));
realtimeInputConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"sessionResumption"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"sessionResumption"},
Common.getValueByPath(fromObject, new String[] {"sessionResumption"}));
sessionResumptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"sessionResumption"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"contextWindowCompression"},
Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"}));
contextWindowCompressionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"inputAudioTranscription"},
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}));
audioTranscriptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"outputAudioTranscription"},
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}));
audioTranscriptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"proactivity"}) != null) {
Expand Down Expand Up @@ -1095,7 +1197,10 @@ ObjectNode liveClientSetupToVertex(JsonNode fromObject, ObjectNode parentObject)
Common.setValueByPath(
toObject,
new String[] {"historyConfig"},
Common.getValueByPath(fromObject, new String[] {"historyConfig"}));
historyConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"historyConfig"})),
toObject));
}

return toObject;
Expand Down Expand Up @@ -1392,35 +1497,50 @@ ObjectNode liveConnectConfigToVertex(JsonNode fromObject, ObjectNode parentObjec
Common.setValueByPath(
parentObject,
new String[] {"setup", "sessionResumption"},
Common.getValueByPath(fromObject, new String[] {"sessionResumption"}));
sessionResumptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"sessionResumption"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "inputAudioTranscription"},
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}));
audioTranscriptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "outputAudioTranscription"},
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}));
audioTranscriptionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "realtimeInputConfig"},
Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"}));
realtimeInputConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"realtimeInputConfig"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"}) != null) {
Common.setValueByPath(
parentObject,
new String[] {"setup", "contextWindowCompression"},
Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"}));
contextWindowCompressionConfigToVertex(
JsonSerializable.toJsonNode(
Common.getValueByPath(fromObject, new String[] {"contextWindowCompression"})),
toObject));
}

if (Common.getValueByPath(fromObject, new String[] {"proactivity"}) != null) {
Expand Down Expand Up @@ -2038,6 +2158,31 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode realtimeInputConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"automaticActivityDetection"}))) {
throw new IllegalArgumentException(
"automaticActivityDetection parameter is only supported in Gemini Developer API mode, not"
+ " in Gemini Enterprise Agent Platform mode.");
}

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

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

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode replicatedVoiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -2115,6 +2260,25 @@ ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parent
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode sessionResumptionConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"handle"}))) {
throw new IllegalArgumentException(
"handle parameter is only supported in Gemini Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
}

if (Common.getValueByPath(fromObject, new String[] {"transparent"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"transparent"},
Common.getValueByPath(fromObject, new String[] {"transparent"}));
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode speakerVoiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/google/genai/types/ActivityHandling.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.google.common.base.Ascii;
import java.util.Objects;

/** The different ways of handling user activity. */
/** Defines what effect activity has. This enum is not supported in Vertex AI. */
public class ActivityHandling {

/** Enum representing the known values for ActivityHandling. */
Expand Down
Loading
Loading