Skip to content

Commit a03472b

Browse files
MarkDaoustcopybara-github
authored andcommitted
chore: Add tests for generate content transcription.
PiperOrigin-RevId: 945196602
1 parent 5ad990b commit a03472b

12 files changed

Lines changed: 582 additions & 0 deletions

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,53 @@ public Batches(ApiClient apiClient) {
6464
this.apiClient = apiClient;
6565
}
6666

67+
@ExcludeFromGeneratedCoverageReport
68+
ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
69+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
70+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) {
71+
throw new IllegalArgumentException(
72+
"languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not"
73+
+ " in Gemini Developer API mode.");
74+
}
75+
76+
if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) {
77+
Common.setValueByPath(
78+
toObject,
79+
new String[] {"languageAuto"},
80+
Common.getValueByPath(fromObject, new String[] {"languageAuto"}));
81+
}
82+
83+
if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) {
84+
Common.setValueByPath(
85+
toObject,
86+
new String[] {"languageHints"},
87+
Common.getValueByPath(fromObject, new String[] {"languageHints"}));
88+
}
89+
90+
if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) {
91+
Common.setValueByPath(
92+
toObject,
93+
new String[] {"adaptationPhrases"},
94+
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
95+
}
96+
97+
if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) {
98+
Common.setValueByPath(
99+
toObject,
100+
new String[] {"wordTimestamp"},
101+
Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}));
102+
}
103+
104+
if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) {
105+
Common.setValueByPath(
106+
toObject,
107+
new String[] {"diarization"},
108+
Common.getValueByPath(fromObject, new String[] {"diarization"}));
109+
}
110+
111+
return toObject;
112+
}
113+
67114
@ExcludeFromGeneratedCoverageReport
68115
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
69116
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -1430,6 +1477,16 @@ ObjectNode generateContentConfigToMldev(
14301477
Common.getValueByPath(fromObject, new String[] {"serviceTier"}));
14311478
}
14321479

1480+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
1481+
Common.setValueByPath(
1482+
toObject,
1483+
new String[] {"audioTranscriptionConfig"},
1484+
audioTranscriptionConfigToMldev(
1485+
JsonSerializable.toJsonNode(
1486+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})),
1487+
toObject));
1488+
}
1489+
14331490
return toObject;
14341491
}
14351492

@@ -1966,6 +2023,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
19662023
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
19672024
}
19682025

2026+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
2027+
Common.setValueByPath(
2028+
toObject,
2029+
new String[] {"audioTranscription"},
2030+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
2031+
}
2032+
19692033
return toObject;
19702034
}
19712035

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
959959
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
960960
}
961961

962+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
963+
Common.setValueByPath(
964+
toObject,
965+
new String[] {"audioTranscription"},
966+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
967+
}
968+
962969
return toObject;
963970
}
964971

@@ -1066,6 +1073,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
10661073
+ " Enterprise Agent Platform mode.");
10671074
}
10681075

1076+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
1077+
Common.setValueByPath(
1078+
toObject,
1079+
new String[] {"audioTranscription"},
1080+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
1081+
}
1082+
10691083
return toObject;
10701084
}
10711085

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren
6161
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
6262
}
6363

64+
if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) {
65+
Common.setValueByPath(
66+
toObject,
67+
new String[] {"wordTimestamp"},
68+
Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}));
69+
}
70+
71+
if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) {
72+
Common.setValueByPath(
73+
toObject,
74+
new String[] {"diarization"},
75+
Common.getValueByPath(fromObject, new String[] {"diarization"}));
76+
}
77+
6478
return toObject;
6579
}
6680

@@ -518,6 +532,13 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject
518532
+ " Gemini Enterprise Agent Platform mode.");
519533
}
520534

535+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
536+
Common.setValueByPath(
537+
toObject,
538+
new String[] {"audioTranscriptionConfig"},
539+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}));
540+
}
541+
521542
return toObject;
522543
}
523544

@@ -1907,6 +1928,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
19071928
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
19081929
}
19091930

1931+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
1932+
Common.setValueByPath(
1933+
toObject,
1934+
new String[] {"audioTranscription"},
1935+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
1936+
}
1937+
19101938
return toObject;
19111939
}
19121940

@@ -2014,6 +2042,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
20142042
+ " Enterprise Agent Platform mode.");
20152043
}
20162044

2045+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
2046+
Common.setValueByPath(
2047+
toObject,
2048+
new String[] {"audioTranscription"},
2049+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
2050+
}
2051+
20172052
return toObject;
20182053
}
20192054

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

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,54 @@ void videoGenerationReferenceTypeMldevEnumValidate(Object enumValue) {
144144
}
145145
}
146146

147+
@ExcludeFromGeneratedCoverageReport
148+
ObjectNode audioTranscriptionConfigToMldev(
149+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
150+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
151+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"languageCodes"}))) {
152+
throw new IllegalArgumentException(
153+
"languageCodes parameter is only supported in Gemini Enterprise Agent Platform mode, not"
154+
+ " in Gemini Developer API mode.");
155+
}
156+
157+
if (Common.getValueByPath(fromObject, new String[] {"languageAuto"}) != null) {
158+
Common.setValueByPath(
159+
toObject,
160+
new String[] {"languageAuto"},
161+
Common.getValueByPath(fromObject, new String[] {"languageAuto"}));
162+
}
163+
164+
if (Common.getValueByPath(fromObject, new String[] {"languageHints"}) != null) {
165+
Common.setValueByPath(
166+
toObject,
167+
new String[] {"languageHints"},
168+
Common.getValueByPath(fromObject, new String[] {"languageHints"}));
169+
}
170+
171+
if (Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}) != null) {
172+
Common.setValueByPath(
173+
toObject,
174+
new String[] {"adaptationPhrases"},
175+
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
176+
}
177+
178+
if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) {
179+
Common.setValueByPath(
180+
toObject,
181+
new String[] {"wordTimestamp"},
182+
Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}));
183+
}
184+
185+
if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) {
186+
Common.setValueByPath(
187+
toObject,
188+
new String[] {"diarization"},
189+
Common.getValueByPath(fromObject, new String[] {"diarization"}));
190+
}
191+
192+
return toObject;
193+
}
194+
147195
@ExcludeFromGeneratedCoverageReport
148196
ObjectNode authConfigToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
149197
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -1746,6 +1794,17 @@ ObjectNode generateContentConfigToMldev(
17461794
Common.getValueByPath(fromObject, new String[] {"serviceTier"}));
17471795
}
17481796

1797+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
1798+
Common.setValueByPath(
1799+
toObject,
1800+
new String[] {"audioTranscriptionConfig"},
1801+
audioTranscriptionConfigToMldev(
1802+
JsonSerializable.toJsonNode(
1803+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"})),
1804+
toObject,
1805+
rootObject));
1806+
}
1807+
17491808
return toObject;
17501809
}
17511810

@@ -1998,6 +2057,13 @@ ObjectNode generateContentConfigToVertex(
19982057
Common.getValueByPath(fromObject, new String[] {"serviceTier"}));
19992058
}
20002059

2060+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
2061+
Common.setValueByPath(
2062+
toObject,
2063+
new String[] {"audioTranscriptionConfig"},
2064+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}));
2065+
}
2066+
20012067
return toObject;
20022068
}
20032069

@@ -3568,6 +3634,13 @@ ObjectNode generationConfigToVertex(
35683634
+ " Gemini Enterprise Agent Platform mode.");
35693635
}
35703636

3637+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
3638+
Common.setValueByPath(
3639+
toObject,
3640+
new String[] {"audioTranscriptionConfig"},
3641+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}));
3642+
}
3643+
35713644
return toObject;
35723645
}
35733646

@@ -4401,6 +4474,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode ro
44014474
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
44024475
}
44034476

4477+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
4478+
Common.setValueByPath(
4479+
toObject,
4480+
new String[] {"audioTranscription"},
4481+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
4482+
}
4483+
44044484
return toObject;
44054485
}
44064486

@@ -4510,6 +4590,13 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode r
45104590
+ " Enterprise Agent Platform mode.");
45114591
}
45124592

4593+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
4594+
Common.setValueByPath(
4595+
toObject,
4596+
new String[] {"audioTranscription"},
4597+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
4598+
}
4599+
45134600
return toObject;
45144601
}
45154602

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren
6161
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
6262
}
6363

64+
if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) {
65+
Common.setValueByPath(
66+
toObject,
67+
new String[] {"wordTimestamp"},
68+
Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}));
69+
}
70+
71+
if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) {
72+
Common.setValueByPath(
73+
toObject,
74+
new String[] {"diarization"},
75+
Common.getValueByPath(fromObject, new String[] {"diarization"}));
76+
}
77+
6478
return toObject;
6579
}
6680

@@ -679,6 +693,13 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
679693
Common.getValueByPath(fromObject, new String[] {"partMetadata"}));
680694
}
681695

696+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
697+
Common.setValueByPath(
698+
toObject,
699+
new String[] {"audioTranscription"},
700+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
701+
}
702+
682703
return toObject;
683704
}
684705

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,13 @@ ObjectNode generationConfigFromVertex(
12261226
Common.getValueByPath(fromObject, new String[] {"responseFormat"}));
12271227
}
12281228

1229+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
1230+
Common.setValueByPath(
1231+
toObject,
1232+
new String[] {"audioTranscriptionConfig"},
1233+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}));
1234+
}
1235+
12291236
return toObject;
12301237
}
12311238

@@ -1411,6 +1418,13 @@ ObjectNode generationConfigToVertex(
14111418
+ " Gemini Enterprise Agent Platform mode.");
14121419
}
14131420

1421+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}) != null) {
1422+
Common.setValueByPath(
1423+
toObject,
1424+
new String[] {"audioTranscriptionConfig"},
1425+
Common.getValueByPath(fromObject, new String[] {"audioTranscriptionConfig"}));
1426+
}
1427+
14141428
return toObject;
14151429
}
14161430

0 commit comments

Comments
 (0)