Skip to content

Commit b4828fa

Browse files
MarkDaoustcopybara-github
authored andcommitted
feat: additional computer_use field support for vertex.
PiperOrigin-RevId: 922388134
1 parent 543137b commit b4828fa

3 files changed

Lines changed: 3 additions & 120 deletions

File tree

google/genai/_live_converters.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323
from ._common import set_value_by_path as setv
2424

2525

26-
def _Environment_to_vertex_enum_validate(enum_value: Any) -> None:
27-
if enum_value in set(['ENVIRONMENT_MOBILE', 'ENVIRONMENT_DESKTOP']):
28-
raise ValueError(
29-
f'{enum_value} enum value is only supported in Gemini Developer API'
30-
' mode, not in Gemini Enterprise Agent Platform mode.'
31-
)
32-
33-
3426
def _AudioTranscriptionConfig_to_mldev(
3527
from_object: Union[dict[str, Any], object],
3628
parent_object: Optional[dict[str, Any]] = None,
@@ -132,32 +124,6 @@ def _CodeExecutionResult_to_vertex(
132124
return to_object
133125

134126

135-
def _ComputerUse_to_vertex(
136-
from_object: Union[dict[str, Any], object],
137-
parent_object: Optional[dict[str, Any]] = None,
138-
) -> dict[str, Any]:
139-
to_object: dict[str, Any] = {}
140-
if getv(from_object, ['environment']) is not None:
141-
_Environment_to_vertex_enum_validate(getv(from_object, ['environment']))
142-
setv(to_object, ['environment'], getv(from_object, ['environment']))
143-
144-
if getv(from_object, ['excluded_predefined_functions']) is not None:
145-
setv(
146-
to_object,
147-
['excludedPredefinedFunctions'],
148-
getv(from_object, ['excluded_predefined_functions']),
149-
)
150-
151-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
152-
raise ValueError(
153-
'enable_prompt_injection_detection parameter is only supported in'
154-
' Gemini Developer API mode, not in Gemini Enterprise Agent Platform'
155-
' mode.'
156-
)
157-
158-
return to_object
159-
160-
161127
def _Content_to_mldev(
162128
from_object: Union[dict[str, Any], object],
163129
parent_object: Optional[dict[str, Any]] = None,
@@ -1926,11 +1892,7 @@ def _Tool_to_vertex(
19261892
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
19271893

19281894
if getv(from_object, ['computer_use']) is not None:
1929-
setv(
1930-
to_object,
1931-
['computerUse'],
1932-
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
1933-
)
1895+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
19341896

19351897
if getv(from_object, ['file_search']) is not None:
19361898
raise ValueError(

google/genai/caches.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@
3232
logger = logging.getLogger('google_genai.caches')
3333

3434

35-
def _Environment_to_vertex_enum_validate(enum_value: Any) -> None:
36-
if enum_value in set(['ENVIRONMENT_MOBILE', 'ENVIRONMENT_DESKTOP']):
37-
raise ValueError(
38-
f'{enum_value} enum value is only supported in Gemini Developer API'
39-
' mode, not in Gemini Enterprise Agent Platform mode.'
40-
)
41-
42-
4335
def _AuthConfig_to_mldev(
4436
from_object: Union[dict[str, Any], object],
4537
parent_object: Optional[dict[str, Any]] = None,
@@ -127,32 +119,6 @@ def _CodeExecutionResult_to_vertex(
127119
return to_object
128120

129121

130-
def _ComputerUse_to_vertex(
131-
from_object: Union[dict[str, Any], object],
132-
parent_object: Optional[dict[str, Any]] = None,
133-
) -> dict[str, Any]:
134-
to_object: dict[str, Any] = {}
135-
if getv(from_object, ['environment']) is not None:
136-
_Environment_to_vertex_enum_validate(getv(from_object, ['environment']))
137-
setv(to_object, ['environment'], getv(from_object, ['environment']))
138-
139-
if getv(from_object, ['excluded_predefined_functions']) is not None:
140-
setv(
141-
to_object,
142-
['excludedPredefinedFunctions'],
143-
getv(from_object, ['excluded_predefined_functions']),
144-
)
145-
146-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
147-
raise ValueError(
148-
'enable_prompt_injection_detection parameter is only supported in'
149-
' Gemini Developer API mode, not in Gemini Enterprise Agent Platform'
150-
' mode.'
151-
)
152-
153-
return to_object
154-
155-
156122
def _Content_to_mldev(
157123
from_object: Union[dict[str, Any], object],
158124
parent_object: Optional[dict[str, Any]] = None,
@@ -994,11 +960,7 @@ def _Tool_to_vertex(
994960
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
995961

996962
if getv(from_object, ['computer_use']) is not None:
997-
setv(
998-
to_object,
999-
['computerUse'],
1000-
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
1001-
)
963+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1002964

1003965
if getv(from_object, ['file_search']) is not None:
1004966
raise ValueError(

google/genai/models.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@
3636
logger = logging.getLogger('google_genai.models')
3737

3838

39-
def _Environment_to_vertex_enum_validate(enum_value: Any) -> None:
40-
if enum_value in set(['ENVIRONMENT_MOBILE', 'ENVIRONMENT_DESKTOP']):
41-
raise ValueError(
42-
f'{enum_value} enum value is only supported in Gemini Developer API'
43-
' mode, not in Gemini Enterprise Agent Platform mode.'
44-
)
45-
46-
4739
def _PersonGeneration_to_mldev_enum_validate(enum_value: Any) -> None:
4840
if enum_value in set(['ALLOW_ALL']):
4941
raise ValueError(
@@ -281,33 +273,6 @@ def _ComputeTokensResponse_from_vertex(
281273
return to_object
282274

283275

284-
def _ComputerUse_to_vertex(
285-
from_object: Union[dict[str, Any], object],
286-
parent_object: Optional[dict[str, Any]] = None,
287-
root_object: Optional[Union[dict[str, Any], object]] = None,
288-
) -> dict[str, Any]:
289-
to_object: dict[str, Any] = {}
290-
if getv(from_object, ['environment']) is not None:
291-
_Environment_to_vertex_enum_validate(getv(from_object, ['environment']))
292-
setv(to_object, ['environment'], getv(from_object, ['environment']))
293-
294-
if getv(from_object, ['excluded_predefined_functions']) is not None:
295-
setv(
296-
to_object,
297-
['excludedPredefinedFunctions'],
298-
getv(from_object, ['excluded_predefined_functions']),
299-
)
300-
301-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
302-
raise ValueError(
303-
'enable_prompt_injection_detection parameter is only supported in'
304-
' Gemini Developer API mode, not in Gemini Enterprise Agent Platform'
305-
' mode.'
306-
)
307-
308-
return to_object
309-
310-
311276
def _ContentEmbeddingStatistics_from_vertex(
312277
from_object: Union[dict[str, Any], object],
313278
parent_object: Optional[dict[str, Any]] = None,
@@ -4385,13 +4350,7 @@ def _Tool_to_vertex(
43854350
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
43864351

43874352
if getv(from_object, ['computer_use']) is not None:
4388-
setv(
4389-
to_object,
4390-
['computerUse'],
4391-
_ComputerUse_to_vertex(
4392-
getv(from_object, ['computer_use']), to_object, root_object
4393-
),
4394-
)
4353+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
43954354

43964355
if getv(from_object, ['file_search']) is not None:
43974356
raise ValueError(

0 commit comments

Comments
 (0)