Skip to content

Commit 524f3aa

Browse files
jaycee-licopybara-github
authored andcommitted
chore: Update discovery docs
PiperOrigin-RevId: 882224524
1 parent 2856c0a commit 524f3aa

File tree

7 files changed

+1021
-383
lines changed

7 files changed

+1021
-383
lines changed

google/genai/_live_converters.py

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ def _Content_to_mldev(
106106
return to_object
107107

108108

109+
def _Content_to_vertex(
110+
from_object: Union[dict[str, Any], object],
111+
parent_object: Optional[dict[str, Any]] = None,
112+
) -> dict[str, Any]:
113+
to_object: dict[str, Any] = {}
114+
if getv(from_object, ['parts']) is not None:
115+
setv(
116+
to_object,
117+
['parts'],
118+
[
119+
_Part_to_vertex(item, to_object)
120+
for item in getv(from_object, ['parts'])
121+
],
122+
)
123+
124+
if getv(from_object, ['role']) is not None:
125+
setv(to_object, ['role'], getv(from_object, ['role']))
126+
127+
return to_object
128+
129+
109130
def _FileData_to_mldev(
110131
from_object: Union[dict[str, Any], object],
111132
parent_object: Optional[dict[str, Any]] = None,
@@ -361,6 +382,27 @@ def _LiveClientContent_to_mldev(
361382
return to_object
362383

363384

385+
def _LiveClientContent_to_vertex(
386+
from_object: Union[dict[str, Any], object],
387+
parent_object: Optional[dict[str, Any]] = None,
388+
) -> dict[str, Any]:
389+
to_object: dict[str, Any] = {}
390+
if getv(from_object, ['turns']) is not None:
391+
setv(
392+
to_object,
393+
['turns'],
394+
[
395+
_Content_to_vertex(item, to_object)
396+
for item in getv(from_object, ['turns'])
397+
],
398+
)
399+
400+
if getv(from_object, ['turn_complete']) is not None:
401+
setv(to_object, ['turnComplete'], getv(from_object, ['turn_complete']))
402+
403+
return to_object
404+
405+
364406
def _LiveClientMessage_to_mldev(
365407
api_client: BaseApiClient,
366408
from_object: Union[dict[str, Any], object],
@@ -416,7 +458,13 @@ def _LiveClientMessage_to_vertex(
416458
)
417459

418460
if getv(from_object, ['client_content']) is not None:
419-
setv(to_object, ['clientContent'], getv(from_object, ['client_content']))
461+
setv(
462+
to_object,
463+
['clientContent'],
464+
_LiveClientContent_to_vertex(
465+
getv(from_object, ['client_content']), to_object
466+
),
467+
)
420468

421469
if getv(from_object, ['realtime_input']) is not None:
422470
setv(
@@ -617,7 +665,9 @@ def _LiveClientSetup_to_vertex(
617665
setv(
618666
to_object,
619667
['systemInstruction'],
620-
t.t_content(getv(from_object, ['system_instruction'])),
668+
_Content_to_vertex(
669+
t.t_content(getv(from_object, ['system_instruction'])), to_object
670+
),
621671
)
622672

623673
if getv(from_object, ['tools']) is not None:
@@ -930,7 +980,9 @@ def _LiveConnectConfig_to_vertex(
930980
setv(
931981
parent_object,
932982
['setup', 'systemInstruction'],
933-
t.t_content(getv(from_object, ['system_instruction'])),
983+
_Content_to_vertex(
984+
t.t_content(getv(from_object, ['system_instruction'])), to_object
985+
),
934986
)
935987

936988
if getv(from_object, ['tools']) is not None:
@@ -1403,6 +1455,67 @@ def _Part_to_mldev(
14031455
if getv(from_object, ['video_metadata']) is not None:
14041456
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
14051457

1458+
if getv(from_object, ['part_metadata']) is not None:
1459+
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))
1460+
1461+
return to_object
1462+
1463+
1464+
def _Part_to_vertex(
1465+
from_object: Union[dict[str, Any], object],
1466+
parent_object: Optional[dict[str, Any]] = None,
1467+
) -> dict[str, Any]:
1468+
to_object: dict[str, Any] = {}
1469+
if getv(from_object, ['media_resolution']) is not None:
1470+
setv(
1471+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
1472+
)
1473+
1474+
if getv(from_object, ['code_execution_result']) is not None:
1475+
setv(
1476+
to_object,
1477+
['codeExecutionResult'],
1478+
getv(from_object, ['code_execution_result']),
1479+
)
1480+
1481+
if getv(from_object, ['executable_code']) is not None:
1482+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
1483+
1484+
if getv(from_object, ['file_data']) is not None:
1485+
setv(to_object, ['fileData'], getv(from_object, ['file_data']))
1486+
1487+
if getv(from_object, ['function_call']) is not None:
1488+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
1489+
1490+
if getv(from_object, ['function_response']) is not None:
1491+
setv(
1492+
to_object,
1493+
['functionResponse'],
1494+
getv(from_object, ['function_response']),
1495+
)
1496+
1497+
if getv(from_object, ['inline_data']) is not None:
1498+
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
1499+
1500+
if getv(from_object, ['text']) is not None:
1501+
setv(to_object, ['text'], getv(from_object, ['text']))
1502+
1503+
if getv(from_object, ['thought']) is not None:
1504+
setv(to_object, ['thought'], getv(from_object, ['thought']))
1505+
1506+
if getv(from_object, ['thought_signature']) is not None:
1507+
setv(
1508+
to_object,
1509+
['thoughtSignature'],
1510+
getv(from_object, ['thought_signature']),
1511+
)
1512+
1513+
if getv(from_object, ['video_metadata']) is not None:
1514+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
1515+
1516+
if getv(from_object, ['part_metadata']) is not None:
1517+
raise ValueError('part_metadata parameter is not supported in Vertex AI.')
1518+
14061519
return to_object
14071520

14081521

google/genai/_tokens_converters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ def _Part_to_mldev(
515515
if getv(from_object, ['video_metadata']) is not None:
516516
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
517517

518+
if getv(from_object, ['part_metadata']) is not None:
519+
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))
520+
518521
return to_object
519522

520523

google/genai/batches.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,9 @@ def _GenerateContentResponse_from_mldev(
10871087
if getv(from_object, ['usageMetadata']) is not None:
10881088
setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
10891089

1090+
if getv(from_object, ['modelStatus']) is not None:
1091+
setv(to_object, ['model_status'], getv(from_object, ['modelStatus']))
1092+
10901093
return to_object
10911094

10921095

@@ -1454,6 +1457,9 @@ def _Part_to_mldev(
14541457
if getv(from_object, ['video_metadata']) is not None:
14551458
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
14561459

1460+
if getv(from_object, ['part_metadata']) is not None:
1461+
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))
1462+
14571463
return to_object
14581464

14591465

google/genai/caches.py

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ def _Content_to_mldev(
105105
return to_object
106106

107107

108+
def _Content_to_vertex(
109+
from_object: Union[dict[str, Any], object],
110+
parent_object: Optional[dict[str, Any]] = None,
111+
) -> dict[str, Any]:
112+
to_object: dict[str, Any] = {}
113+
if getv(from_object, ['parts']) is not None:
114+
setv(
115+
to_object,
116+
['parts'],
117+
[
118+
_Part_to_vertex(item, to_object)
119+
for item in getv(from_object, ['parts'])
120+
],
121+
)
122+
123+
if getv(from_object, ['role']) is not None:
124+
setv(to_object, ['role'], getv(from_object, ['role']))
125+
126+
return to_object
127+
128+
108129
def _CreateCachedContentConfig_to_mldev(
109130
from_object: Union[dict[str, Any], object],
110131
parent_object: Optional[dict[str, Any]] = None,
@@ -181,14 +202,19 @@ def _CreateCachedContentConfig_to_vertex(
181202
setv(
182203
parent_object,
183204
['contents'],
184-
[item for item in t.t_contents(getv(from_object, ['contents']))],
205+
[
206+
_Content_to_vertex(item, to_object)
207+
for item in t.t_contents(getv(from_object, ['contents']))
208+
],
185209
)
186210

187211
if getv(from_object, ['system_instruction']) is not None:
188212
setv(
189213
parent_object,
190214
['systemInstruction'],
191-
t.t_content(getv(from_object, ['system_instruction'])),
215+
_Content_to_vertex(
216+
t.t_content(getv(from_object, ['system_instruction'])), to_object
217+
),
192218
)
193219

194220
if getv(from_object, ['tools']) is not None:
@@ -667,6 +693,67 @@ def _Part_to_mldev(
667693
if getv(from_object, ['video_metadata']) is not None:
668694
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
669695

696+
if getv(from_object, ['part_metadata']) is not None:
697+
setv(to_object, ['partMetadata'], getv(from_object, ['part_metadata']))
698+
699+
return to_object
700+
701+
702+
def _Part_to_vertex(
703+
from_object: Union[dict[str, Any], object],
704+
parent_object: Optional[dict[str, Any]] = None,
705+
) -> dict[str, Any]:
706+
to_object: dict[str, Any] = {}
707+
if getv(from_object, ['media_resolution']) is not None:
708+
setv(
709+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
710+
)
711+
712+
if getv(from_object, ['code_execution_result']) is not None:
713+
setv(
714+
to_object,
715+
['codeExecutionResult'],
716+
getv(from_object, ['code_execution_result']),
717+
)
718+
719+
if getv(from_object, ['executable_code']) is not None:
720+
setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
721+
722+
if getv(from_object, ['file_data']) is not None:
723+
setv(to_object, ['fileData'], getv(from_object, ['file_data']))
724+
725+
if getv(from_object, ['function_call']) is not None:
726+
setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
727+
728+
if getv(from_object, ['function_response']) is not None:
729+
setv(
730+
to_object,
731+
['functionResponse'],
732+
getv(from_object, ['function_response']),
733+
)
734+
735+
if getv(from_object, ['inline_data']) is not None:
736+
setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
737+
738+
if getv(from_object, ['text']) is not None:
739+
setv(to_object, ['text'], getv(from_object, ['text']))
740+
741+
if getv(from_object, ['thought']) is not None:
742+
setv(to_object, ['thought'], getv(from_object, ['thought']))
743+
744+
if getv(from_object, ['thought_signature']) is not None:
745+
setv(
746+
to_object,
747+
['thoughtSignature'],
748+
getv(from_object, ['thought_signature']),
749+
)
750+
751+
if getv(from_object, ['video_metadata']) is not None:
752+
setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
753+
754+
if getv(from_object, ['part_metadata']) is not None:
755+
raise ValueError('part_metadata parameter is not supported in Vertex AI.')
756+
670757
return to_object
671758

672759

0 commit comments

Comments
 (0)