Skip to content

Commit 84bf19c

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: update discovery doc
PiperOrigin-RevId: 994529596
1 parent 6e36aaa commit 84bf19c

6 files changed

Lines changed: 33 additions & 184 deletions

File tree

‎google/genai/_live_converters.py‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -70,37 +70,6 @@ def _AuthConfig_to_mldev(
7070
return to_object
7171

7272

73-
def _ComputerUse_to_vertex(
74-
from_object: Union[dict[str, Any], object],
75-
parent_object: Optional[dict[str, Any]] = None,
76-
) -> dict[str, Any]:
77-
to_object: dict[str, Any] = {}
78-
if getv(from_object, ['environment']) is not None:
79-
setv(to_object, ['environment'], getv(from_object, ['environment']))
80-
81-
if getv(from_object, ['excluded_predefined_functions']) is not None:
82-
setv(
83-
to_object,
84-
['excludedPredefinedFunctions'],
85-
getv(from_object, ['excluded_predefined_functions']),
86-
)
87-
88-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
89-
setv(
90-
to_object,
91-
['enablePromptInjectionDetection'],
92-
getv(from_object, ['enable_prompt_injection_detection']),
93-
)
94-
95-
if getv(from_object, ['disabled_safety_policies']) is not None:
96-
raise ValueError(
97-
'disabled_safety_policies parameter is only supported in Gemini'
98-
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
99-
)
100-
101-
return to_object
102-
103-
10473
def _Content_to_mldev(
10574
from_object: Union[dict[str, Any], object],
10675
parent_object: Optional[dict[str, Any]] = None,
@@ -1841,11 +1810,7 @@ def _Tool_to_vertex(
18411810
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
18421811

18431812
if getv(from_object, ['computer_use']) is not None:
1844-
setv(
1845-
to_object,
1846-
['computerUse'],
1847-
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
1848-
)
1813+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
18491814

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

‎google/genai/caches.py‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -79,37 +79,6 @@ def _AuthConfig_to_mldev(
7979
return to_object
8080

8181

82-
def _ComputerUse_to_vertex(
83-
from_object: Union[dict[str, Any], object],
84-
parent_object: Optional[dict[str, Any]] = None,
85-
) -> dict[str, Any]:
86-
to_object: dict[str, Any] = {}
87-
if getv(from_object, ['environment']) is not None:
88-
setv(to_object, ['environment'], getv(from_object, ['environment']))
89-
90-
if getv(from_object, ['excluded_predefined_functions']) is not None:
91-
setv(
92-
to_object,
93-
['excludedPredefinedFunctions'],
94-
getv(from_object, ['excluded_predefined_functions']),
95-
)
96-
97-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
98-
setv(
99-
to_object,
100-
['enablePromptInjectionDetection'],
101-
getv(from_object, ['enable_prompt_injection_detection']),
102-
)
103-
104-
if getv(from_object, ['disabled_safety_policies']) is not None:
105-
raise ValueError(
106-
'disabled_safety_policies parameter is only supported in Gemini'
107-
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
108-
)
109-
110-
return to_object
111-
112-
11382
def _Content_to_mldev(
11483
from_object: Union[dict[str, Any], object],
11584
parent_object: Optional[dict[str, Any]] = None,
@@ -957,11 +926,7 @@ def _Tool_to_vertex(
957926
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
958927

959928
if getv(from_object, ['computer_use']) is not None:
960-
setv(
961-
to_object,
962-
['computerUse'],
963-
_ComputerUse_to_vertex(getv(from_object, ['computer_use']), to_object),
964-
)
929+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
965930

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

‎google/genai/models.py‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -225,38 +225,6 @@ def _ComputeTokensResponse_from_vertex(
225225
return to_object
226226

227227

228-
def _ComputerUse_to_vertex(
229-
from_object: Union[dict[str, Any], object],
230-
parent_object: Optional[dict[str, Any]] = None,
231-
root_object: Optional[Union[dict[str, Any], object]] = None,
232-
) -> dict[str, Any]:
233-
to_object: dict[str, Any] = {}
234-
if getv(from_object, ['environment']) is not None:
235-
setv(to_object, ['environment'], getv(from_object, ['environment']))
236-
237-
if getv(from_object, ['excluded_predefined_functions']) is not None:
238-
setv(
239-
to_object,
240-
['excludedPredefinedFunctions'],
241-
getv(from_object, ['excluded_predefined_functions']),
242-
)
243-
244-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
245-
setv(
246-
to_object,
247-
['enablePromptInjectionDetection'],
248-
getv(from_object, ['enable_prompt_injection_detection']),
249-
)
250-
251-
if getv(from_object, ['disabled_safety_policies']) is not None:
252-
raise ValueError(
253-
'disabled_safety_policies parameter is only supported in Gemini'
254-
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
255-
)
256-
257-
return to_object
258-
259-
260228
def _ContentEmbeddingStatistics_from_vertex(
261229
from_object: Union[dict[str, Any], object],
262230
parent_object: Optional[dict[str, Any]] = None,
@@ -4127,13 +4095,7 @@ def _Tool_to_vertex(
41274095
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
41284096

41294097
if getv(from_object, ['computer_use']) is not None:
4130-
setv(
4131-
to_object,
4132-
['computerUse'],
4133-
_ComputerUse_to_vertex(
4134-
getv(from_object, ['computer_use']), to_object, root_object
4135-
),
4136-
)
4098+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
41374099

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

‎google/genai/tests/models/test_generate_content_tools.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,6 @@ def divide_floats(a: float, b: float) -> float:
529529
}]
530530
},
531531
),
532-
exception_if_vertex='only supported in Gemini Developer API mode',
533-
skip_in_private=(
534-
'disabled_safety_policies parameter is supported on Vertex AI in'
535-
' Private SDK'
536-
),
537532
),
538533
pytest_helper.TestTableItem(
539534
name='test_computer_use_multi_turn',

‎google/genai/tunings.py‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -222,38 +222,6 @@ def _CompositeReinforcementTuningRewardConfig_to_vertex(
222222
return to_object
223223

224224

225-
def _ComputerUse_to_vertex(
226-
from_object: Union[dict[str, Any], object],
227-
parent_object: Optional[dict[str, Any]] = None,
228-
root_object: Optional[Union[dict[str, Any], object]] = None,
229-
) -> dict[str, Any]:
230-
to_object: dict[str, Any] = {}
231-
if getv(from_object, ['environment']) is not None:
232-
setv(to_object, ['environment'], getv(from_object, ['environment']))
233-
234-
if getv(from_object, ['excluded_predefined_functions']) is not None:
235-
setv(
236-
to_object,
237-
['excludedPredefinedFunctions'],
238-
getv(from_object, ['excluded_predefined_functions']),
239-
)
240-
241-
if getv(from_object, ['enable_prompt_injection_detection']) is not None:
242-
setv(
243-
to_object,
244-
['enablePromptInjectionDetection'],
245-
getv(from_object, ['enable_prompt_injection_detection']),
246-
)
247-
248-
if getv(from_object, ['disabled_safety_policies']) is not None:
249-
raise ValueError(
250-
'disabled_safety_policies parameter is only supported in Gemini'
251-
' Developer API mode, not in Gemini Enterprise Agent Platform mode.'
252-
)
253-
254-
return to_object
255-
256-
257225
def _Content_to_vertex(
258226
from_object: Union[dict[str, Any], object],
259227
parent_object: Optional[dict[str, Any]] = None,
@@ -1981,13 +1949,7 @@ def _Tool_to_vertex(
19811949
setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
19821950

19831951
if getv(from_object, ['computer_use']) is not None:
1984-
setv(
1985-
to_object,
1986-
['computerUse'],
1987-
_ComputerUse_to_vertex(
1988-
getv(from_object, ['computer_use']), to_object, root_object
1989-
),
1990-
)
1952+
setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
19911953

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

‎google/genai/types.py‎

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -292,38 +292,38 @@ class ApiSpec(_common.CaseInSensitiveEnum):
292292
"""Elastic search API spec."""
293293

294294

295-
class Environment(_common.CaseInSensitiveEnum):
296-
"""The environment being operated."""
297-
298-
ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'
299-
"""Defaults to browser."""
300-
ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'
301-
"""Operates in a web browser."""
302-
ENVIRONMENT_MOBILE = 'ENVIRONMENT_MOBILE'
303-
"""Operates in a mobile environment."""
304-
ENVIRONMENT_DESKTOP = 'ENVIRONMENT_DESKTOP'
305-
"""Operates in a desktop environment."""
306-
307-
308295
class SafetyPolicy(_common.CaseInSensitiveEnum):
309296
"""SafetyPolicy"""
310297

311298
SAFETY_POLICY_UNSPECIFIED = 'SAFETY_POLICY_UNSPECIFIED'
312-
"""Unspecified safety policy."""
299+
"""Unspecified safety policy. This value should not be used."""
313300
FINANCIAL_TRANSACTIONS = 'FINANCIAL_TRANSACTIONS'
314-
"""Safety policy for financial transactions."""
301+
"""Financial transactions safety policy."""
315302
SENSITIVE_DATA_MODIFICATION = 'SENSITIVE_DATA_MODIFICATION'
316-
"""Safety policy for sensitive data modification."""
303+
"""Sensitive data modification safety policy."""
317304
COMMUNICATION_TOOL = 'COMMUNICATION_TOOL'
318-
"""Safety policy for communication tools (e.g. Gmail, Chat, Meet)."""
305+
"""Communication tool safety policy."""
319306
ACCOUNT_CREATION = 'ACCOUNT_CREATION'
320-
"""Safety policy for account creation."""
307+
"""Account creation safety policy."""
321308
DATA_MODIFICATION = 'DATA_MODIFICATION'
322-
"""Safety policy for data modification."""
309+
"""Data modification safety policy."""
323310
USER_CONSENT_MANAGEMENT = 'USER_CONSENT_MANAGEMENT'
324-
"""Safety policy for user consent management."""
311+
"""User consent management safety policy."""
325312
LEGAL_TERMS_AND_AGREEMENTS = 'LEGAL_TERMS_AND_AGREEMENTS'
326-
"""Safety policy for legal terms and agreements."""
313+
"""Legal terms and agreements safety policy."""
314+
315+
316+
class Environment(_common.CaseInSensitiveEnum):
317+
"""The environment being operated."""
318+
319+
ENVIRONMENT_UNSPECIFIED = 'ENVIRONMENT_UNSPECIFIED'
320+
"""Defaults to browser."""
321+
ENVIRONMENT_BROWSER = 'ENVIRONMENT_BROWSER'
322+
"""Operates in a web browser."""
323+
ENVIRONMENT_MOBILE = 'ENVIRONMENT_MOBILE'
324+
"""Operates in a mobile environment."""
325+
ENVIRONMENT_DESKTOP = 'ENVIRONMENT_DESKTOP'
326+
"""Operates in a desktop environment."""
327327

328328

329329
class PhishBlockThreshold(_common.CaseInSensitiveEnum):
@@ -4571,7 +4571,7 @@ class ComputerUse(_common.BaseModel):
45714571
)
45724572
disabled_safety_policies: Optional[list[SafetyPolicy]] = Field(
45734573
default=None,
4574-
description="""Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI.""",
4574+
description="""Optional. Disabled safety policies for computer use.""",
45754575
)
45764576

45774577

@@ -4588,7 +4588,7 @@ class ComputerUseDict(TypedDict, total=False):
45884588
"""Optional. Enables the prompt injection detection check on computer-use request."""
45894589

45904590
disabled_safety_policies: Optional[list[SafetyPolicy]]
4591-
"""Optional. Disabled safety policies for computer use. This field is not supported in Vertex AI."""
4591+
"""Optional. Disabled safety policies for computer use."""
45924592

45934593

45944594
ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]
@@ -15684,7 +15684,7 @@ class TuningJob(_common.BaseModel):
1568415684
)
1568515685
gcs_metrics_uri: Optional[str] = Field(
1568615686
default=None,
15687-
description="""The Cloud Storage metrics URI associated with this tuning job.""",
15687+
description="""Output only. The Cloud Storage metrics URI associated with this TuningJob.""",
1568815688
)
1568915689

1569015690
@property
@@ -15804,7 +15804,7 @@ class TuningJobDict(TypedDict, total=False):
1580415804
""""""
1580515805

1580615806
gcs_metrics_uri: Optional[str]
15807-
"""The Cloud Storage metrics URI associated with this tuning job."""
15807+
"""Output only. The Cloud Storage metrics URI associated with this TuningJob."""
1580815808

1580915809

1581015810
TuningJobOrDict = Union[TuningJob, TuningJobDict]
@@ -23203,7 +23203,7 @@ class EvaluationParserConfigCustomCodeParserConfig(_common.BaseModel):
2320323203
)
2320423204
code_execution_region: Optional[str] = Field(
2320523205
default=None,
23206-
description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used.""",
23206+
description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request's originating region is used.""",
2320723207
)
2320823208

2320923209

@@ -23217,7 +23217,7 @@ class EvaluationParserConfigCustomCodeParserConfigDict(TypedDict, total=False):
2321723217
"""Required. Python function for parsing results. The function should be defined within this string. The function takes a list of strings (LLM responses) and should return either a list of dictionaries (for rubrics) or a single dictionary (for a metric result). Example function signature: def parse(responses: list[str]) -> list[dict[str, Any]] | dict[str, Any]: When parsing rubrics, return a list of dictionaries, where each dictionary represents a Rubric. Example for rubrics: [ { "content": {"property": {"description": "The response is factual."}}, "type": "FACTUALITY", "importance": "HIGH" }, { "content": {"property": {"description": "The response is fluent."}}, "type": "FLUENCY", "importance": "MEDIUM" } ] When parsing critique results, return a dictionary representing a MetricResult. Example for a metric result: { "score": 0.8, "explanation": "The model followed most instructions.", "rubric_verdicts": [...] } ... code for result extraction and aggregation"""
2321823218

2321923219
code_execution_region: Optional[str]
23220-
"""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used."""
23220+
"""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request's originating region is used."""
2322123221

2322223222

2322323223
EvaluationParserConfigCustomCodeParserConfigOrDict = Union[
@@ -23344,7 +23344,7 @@ def evaluate(instance: dict[str, Any]) -> float:
2334423344
)
2334523345
code_execution_region: Optional[str] = Field(
2334623346
default=None,
23347-
description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""",
23347+
description="""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED.""",
2334823348
)
2334923349

2335023350

@@ -23360,7 +23360,7 @@ def evaluate(instance: dict[str, Any]) -> float:
2336023360
are available to the function as instance[field_name]."""
2336123361

2336223362
code_execution_region: Optional[str]
23363-
"""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. Supported regions: northamerica-northeast1, southamerica-east1, us-central1, us-east1, us-east4, us-west1, us-west4, europe-central2, europe-north1, europe-southwest1, europe-west1, europe-west2, europe-west3, europe-west4, europe-west6, europe-west8, europe-west9, me-west1, asia-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-south2, asia-southeast1, australia-southeast2. If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED."""
23363+
"""Optional. The region to use for code execution. If set, the Code Execution Sandbox will be invoked in the specified region regardless of the request's originating region. Must be a region where the Code Execution Sandbox is available. For the current list of [supported regions](https://cloud.google.com/vertex-ai/generative-ai/docs/agent-engine/locations). If unset, the request's originating region is used; requests from regions where the sandbox is unavailable will fail with UNIMPLEMENTED."""
2336423364

2336523365

2336623366
CustomCodeExecutionSpecOrDict = Union[

0 commit comments

Comments
 (0)