Skip to content

Commit 19bb720

Browse files
wanlin31copybara-github
authored andcommitted
feat: [GenerateContent] Add GenerationConfig.audio_transcription_config and Part.audio_transcription.
PiperOrigin-RevId: 948653928
1 parent fadd4ce commit 19bb720

57 files changed

Lines changed: 3788 additions & 3190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 180 additions & 108 deletions
Large diffs are not rendered by default.

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

Lines changed: 145 additions & 131 deletions
Large diffs are not rendered by default.

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

Lines changed: 202 additions & 167 deletions
Large diffs are not rendered by default.

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

Lines changed: 262 additions & 167 deletions
Large diffs are not rendered by default.

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

Lines changed: 80 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ ObjectNode audioTranscriptionConfigToMldev(JsonNode fromObject, ObjectNode paren
6868
Common.getValueByPath(fromObject, new String[] {"adaptationPhrases"}));
6969
}
7070

71+
if (Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}) != null) {
72+
Common.setValueByPath(
73+
toObject,
74+
new String[] {"wordTimestamp"},
75+
Common.getValueByPath(fromObject, new String[] {"wordTimestamp"}));
76+
}
77+
78+
if (Common.getValueByPath(fromObject, new String[] {"diarization"}) != null) {
79+
Common.setValueByPath(
80+
toObject,
81+
new String[] {"diarization"},
82+
Common.getValueByPath(fromObject, new String[] {"diarization"}));
83+
}
84+
7185
return toObject;
7286
}
7387

@@ -277,18 +291,18 @@ ObjectNode fileDataToMldev(JsonNode fromObject, ObjectNode parentObject) {
277291
@ExcludeFromGeneratedCoverageReport
278292
ObjectNode functionCallToMldev(JsonNode fromObject, ObjectNode parentObject) {
279293
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
280-
if (Common.getValueByPath(fromObject, new String[] {"id"}) != null) {
281-
Common.setValueByPath(
282-
toObject, new String[] {"id"}, Common.getValueByPath(fromObject, new String[] {"id"}));
283-
}
284-
285294
if (Common.getValueByPath(fromObject, new String[] {"args"}) != null) {
286295
Common.setValueByPath(
287296
toObject,
288297
new String[] {"args"},
289298
Common.getValueByPath(fromObject, new String[] {"args"}));
290299
}
291300

301+
if (Common.getValueByPath(fromObject, new String[] {"id"}) != null) {
302+
Common.setValueByPath(
303+
toObject, new String[] {"id"}, Common.getValueByPath(fromObject, new String[] {"id"}));
304+
}
305+
292306
if (Common.getValueByPath(fromObject, new String[] {"name"}) != null) {
293307
Common.setValueByPath(
294308
toObject,
@@ -337,13 +351,6 @@ ObjectNode googleMapsToMldev(JsonNode fromObject, ObjectNode parentObject) {
337351
@ExcludeFromGeneratedCoverageReport
338352
ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
339353
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
340-
if (Common.getValueByPath(fromObject, new String[] {"searchTypes"}) != null) {
341-
Common.setValueByPath(
342-
toObject,
343-
new String[] {"searchTypes"},
344-
Common.getValueByPath(fromObject, new String[] {"searchTypes"}));
345-
}
346-
347354
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"blockingConfidence"}))) {
348355
throw new IllegalArgumentException(
349356
"blockingConfidence parameter is only supported in Gemini Enterprise Agent Platform mode,"
@@ -356,6 +363,13 @@ ObjectNode googleSearchToMldev(JsonNode fromObject, ObjectNode parentObject) {
356363
+ " in Gemini Developer API mode.");
357364
}
358365

366+
if (Common.getValueByPath(fromObject, new String[] {"searchTypes"}) != null) {
367+
Common.setValueByPath(
368+
toObject,
369+
new String[] {"searchTypes"},
370+
Common.getValueByPath(fromObject, new String[] {"searchTypes"}));
371+
}
372+
359373
if (Common.getValueByPath(fromObject, new String[] {"timeRangeFilter"}) != null) {
360374
Common.setValueByPath(
361375
toObject,
@@ -586,6 +600,27 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
586600
Common.getValueByPath(fromObject, new String[] {"mediaResolution"}));
587601
}
588602

603+
if (Common.getValueByPath(fromObject, new String[] {"toolCall"}) != null) {
604+
Common.setValueByPath(
605+
toObject,
606+
new String[] {"toolCall"},
607+
Common.getValueByPath(fromObject, new String[] {"toolCall"}));
608+
}
609+
610+
if (Common.getValueByPath(fromObject, new String[] {"toolResponse"}) != null) {
611+
Common.setValueByPath(
612+
toObject,
613+
new String[] {"toolResponse"},
614+
Common.getValueByPath(fromObject, new String[] {"toolResponse"}));
615+
}
616+
617+
if (Common.getValueByPath(fromObject, new String[] {"audioTranscription"}) != null) {
618+
Common.setValueByPath(
619+
toObject,
620+
new String[] {"audioTranscription"},
621+
Common.getValueByPath(fromObject, new String[] {"audioTranscription"}));
622+
}
623+
589624
if (Common.getValueByPath(fromObject, new String[] {"codeExecutionResult"}) != null) {
590625
Common.setValueByPath(
591626
toObject,
@@ -665,20 +700,6 @@ ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
665700
Common.getValueByPath(fromObject, new String[] {"videoMetadata"}));
666701
}
667702

668-
if (Common.getValueByPath(fromObject, new String[] {"toolCall"}) != null) {
669-
Common.setValueByPath(
670-
toObject,
671-
new String[] {"toolCall"},
672-
Common.getValueByPath(fromObject, new String[] {"toolCall"}));
673-
}
674-
675-
if (Common.getValueByPath(fromObject, new String[] {"toolResponse"}) != null) {
676-
Common.setValueByPath(
677-
toObject,
678-
new String[] {"toolResponse"},
679-
Common.getValueByPath(fromObject, new String[] {"toolResponse"}));
680-
}
681-
682703
if (Common.getValueByPath(fromObject, new String[] {"partMetadata"}) != null) {
683704
Common.setValueByPath(
684705
toObject,
@@ -743,30 +764,6 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
743764
+ " Gemini Developer API mode.");
744765
}
745766

746-
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
747-
Common.setValueByPath(
748-
toObject,
749-
new String[] {"computerUse"},
750-
Common.getValueByPath(fromObject, new String[] {"computerUse"}));
751-
}
752-
753-
if (Common.getValueByPath(fromObject, new String[] {"fileSearch"}) != null) {
754-
Common.setValueByPath(
755-
toObject,
756-
new String[] {"fileSearch"},
757-
Common.getValueByPath(fromObject, new String[] {"fileSearch"}));
758-
}
759-
760-
if (Common.getValueByPath(fromObject, new String[] {"googleSearch"}) != null) {
761-
Common.setValueByPath(
762-
toObject,
763-
new String[] {"googleSearch"},
764-
googleSearchToMldev(
765-
JsonSerializable.toJsonNode(
766-
Common.getValueByPath(fromObject, new String[] {"googleSearch"})),
767-
toObject));
768-
}
769-
770767
if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
771768
Common.setValueByPath(
772769
toObject,
@@ -777,26 +774,56 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
777774
toObject));
778775
}
779776

777+
if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
778+
Common.setValueByPath(
779+
toObject,
780+
new String[] {"mcpServers"},
781+
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
782+
}
783+
780784
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
781785
Common.setValueByPath(
782786
toObject,
783787
new String[] {"codeExecution"},
784788
Common.getValueByPath(fromObject, new String[] {"codeExecution"}));
785789
}
786790

791+
if (Common.getValueByPath(fromObject, new String[] {"computerUse"}) != null) {
792+
Common.setValueByPath(
793+
toObject,
794+
new String[] {"computerUse"},
795+
Common.getValueByPath(fromObject, new String[] {"computerUse"}));
796+
}
797+
787798
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}))) {
788799
throw new IllegalArgumentException(
789800
"enterpriseWebSearch parameter is only supported in Gemini Enterprise Agent Platform"
790801
+ " mode, not in Gemini Developer API mode.");
791802
}
792803

804+
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) {
805+
throw new IllegalArgumentException(
806+
"exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
807+
+ " Gemini Developer API mode.");
808+
}
809+
793810
if (Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}) != null) {
794811
Common.setValueByPath(
795812
toObject,
796813
new String[] {"functionDeclarations"},
797814
Common.getValueByPath(fromObject, new String[] {"functionDeclarations"}));
798815
}
799816

817+
if (Common.getValueByPath(fromObject, new String[] {"googleSearch"}) != null) {
818+
Common.setValueByPath(
819+
toObject,
820+
new String[] {"googleSearch"},
821+
googleSearchToMldev(
822+
JsonSerializable.toJsonNode(
823+
Common.getValueByPath(fromObject, new String[] {"googleSearch"})),
824+
toObject));
825+
}
826+
800827
if (Common.getValueByPath(fromObject, new String[] {"googleSearchRetrieval"}) != null) {
801828
Common.setValueByPath(
802829
toObject,
@@ -817,17 +844,11 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
817844
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
818845
}
819846

820-
if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
847+
if (Common.getValueByPath(fromObject, new String[] {"fileSearch"}) != null) {
821848
Common.setValueByPath(
822849
toObject,
823-
new String[] {"mcpServers"},
824-
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
825-
}
826-
827-
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"exaAiSearch"}))) {
828-
throw new IllegalArgumentException(
829-
"exaAiSearch parameter is only supported in Gemini Enterprise Agent Platform mode, not in"
830-
+ " Gemini Developer API mode.");
850+
new String[] {"fileSearch"},
851+
Common.getValueByPath(fromObject, new String[] {"fileSearch"}));
831852
}
832853

833854
return toObject;

0 commit comments

Comments
 (0)