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
27 changes: 27 additions & 0 deletions google/genai/_live_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def _AudioTranscriptionConfig_to_mldev(
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


Expand Down Expand Up @@ -409,6 +415,13 @@ def _GenerationConfig_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['audio_transcription_config']) is not None:
setv(
to_object,
['audioTranscriptionConfig'],
getv(from_object, ['audio_transcription_config']),
)

return to_object


Expand Down Expand Up @@ -1689,6 +1702,13 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down Expand Up @@ -1770,6 +1790,13 @@ def _Part_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down
13 changes: 13 additions & 0 deletions google/genai/_tokens_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def _AudioTranscriptionConfig_to_mldev(
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


Expand Down Expand Up @@ -595,6 +601,13 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down
49 changes: 49 additions & 0 deletions google/genai/batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,39 @@
logger = logging.getLogger('google_genai.batches')


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -1182,6 +1215,15 @@ def _GenerateContentConfig_to_mldev(
if getv(from_object, ['service_tier']) is not None:
setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier']))

if getv(from_object, ['audio_transcription_config']) is not None:
setv(
to_object,
['audioTranscriptionConfig'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['audio_transcription_config']), to_object
),
)

return to_object


Expand Down Expand Up @@ -1606,6 +1648,13 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down
14 changes: 14 additions & 0 deletions google/genai/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,13 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down Expand Up @@ -870,6 +877,13 @@ def _Part_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down
73 changes: 73 additions & 0 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,40 @@ def _VideoGenerationReferenceType_to_mldev_enum_validate(
)


def _AudioTranscriptionConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
root_object: Optional[Union[dict[str, Any], object]] = None,
) -> dict[str, Any]:
to_object: dict[str, Any] = {}
if getv(from_object, ['language_codes']) is not None:
raise ValueError(
'language_codes parameter is only supported in Gemini Enterprise Agent'
' Platform mode, not in Gemini Developer API mode.'
)

if getv(from_object, ['language_auto']) is not None:
setv(to_object, ['languageAuto'], getv(from_object, ['language_auto']))

if getv(from_object, ['language_hints']) is not None:
setv(to_object, ['languageHints'], getv(from_object, ['language_hints']))

if getv(from_object, ['adaptation_phrases']) is not None:
setv(
to_object,
['adaptationPhrases'],
getv(from_object, ['adaptation_phrases']),
)

if getv(from_object, ['word_timestamp']) is not None:
setv(to_object, ['wordTimestamp'], getv(from_object, ['word_timestamp']))

if getv(from_object, ['diarization']) is not None:
setv(to_object, ['diarization'], getv(from_object, ['diarization']))

return to_object


def _AuthConfig_to_mldev(
from_object: Union[dict[str, Any], object],
parent_object: Optional[dict[str, Any]] = None,
Expand Down Expand Up @@ -1453,6 +1487,17 @@ def _GenerateContentConfig_to_mldev(
if getv(from_object, ['service_tier']) is not None:
setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier']))

if getv(from_object, ['audio_transcription_config']) is not None:
setv(
to_object,
['audioTranscriptionConfig'],
_AudioTranscriptionConfig_to_mldev(
getv(from_object, ['audio_transcription_config']),
to_object,
root_object,
),
)

return to_object


Expand Down Expand Up @@ -1643,6 +1688,13 @@ def _GenerateContentConfig_to_vertex(
if getv(from_object, ['service_tier']) is not None:
setv(parent_object, ['serviceTier'], getv(from_object, ['service_tier']))

if getv(from_object, ['audio_transcription_config']) is not None:
setv(
to_object,
['audioTranscriptionConfig'],
getv(from_object, ['audio_transcription_config']),
)

return to_object


Expand Down Expand Up @@ -2990,6 +3042,13 @@ def _GenerationConfig_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['audio_transcription_config']) is not None:
setv(
to_object,
['audioTranscriptionConfig'],
getv(from_object, ['audio_transcription_config']),
)

return to_object


Expand Down Expand Up @@ -3664,6 +3723,13 @@ def _Part_to_mldev(
if getv(from_object, ['part_metadata']) is not None:
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down Expand Up @@ -3746,6 +3812,13 @@ def _Part_to_vertex(
' mode, not in Gemini Enterprise Agent Platform mode.'
)

if getv(from_object, ['audio_transcription']) is not None:
setv(
to_object,
['audioTranscription'],
getv(from_object, ['audio_transcription']),
)

return to_object


Expand Down
Loading
Loading