diff --git a/google/genai/tests/models/test_generate_content_tools.py b/google/genai/tests/models/test_generate_content_tools.py index 4c48c6c73..b932725e0 100644 --- a/google/genai/tests/models/test_generate_content_tools.py +++ b/google/genai/tests/models/test_generate_content_tools.py @@ -501,6 +501,27 @@ def divide_floats(a: float, b: float) -> float: ), exception_if_vertex='404', ), + pytest_helper.TestTableItem( + name='test_computer_use_with_disabled_safety_policies', + parameters=types._GenerateContentParameters( + model='gemini-2.5-computer-use-preview-10-2025', + contents=t.t_contents('Go to google and search nano banana'), + config={ + 'tools': [ + { + 'computer_use': { + 'environment': 'ENVIRONMENT_BROWSER', + 'disabled_safety_policies': [ + 'FINANCIAL_TRANSACTIONS', + 'COMMUNICATION_TOOL', + ], + } + } + ] + }, + ), + exception_if_vertex='404', + ), pytest_helper.TestTableItem( name='test_computer_use_multi_turn', parameters=types._GenerateContentParameters( diff --git a/google/genai/tests/types/test_types.py b/google/genai/tests/types/test_types.py index 099ff2a2d..5fdde3e9b 100644 --- a/google/genai/tests/types/test_types.py +++ b/google/genai/tests/types/test_types.py @@ -2925,3 +2925,19 @@ def test_instantiate_response_from_batch_json(): parsed.candidates[0].citation_metadata.citations[0].uri == 'http://someurl.com' ) + + +def test_computer_use_types(): + c = types.ComputerUse( + environment=types.Environment.ENVIRONMENT_MOBILE, + enable_prompt_injection_detection=True, + disabled_safety_policies=[ + types.SafetyPolicy.FINANCIAL_TRANSACTIONS, + types.SafetyPolicy.COMMUNICATION_TOOL, + ], + ) + assert c.environment == types.Environment.ENVIRONMENT_MOBILE + assert c.enable_prompt_injection_detection is True + assert len(c.disabled_safety_policies) == 2 + assert types.SafetyPolicy.FINANCIAL_TRANSACTIONS in c.disabled_safety_policies + diff --git a/google/genai/types.py b/google/genai/types.py index c43b58c3c..0b507afc2 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -923,6 +923,27 @@ class FeatureSelectionPreference(_common.CaseInSensitiveEnum): PRIORITIZE_COST = 'PRIORITIZE_COST' +class SafetyPolicy(_common.CaseInSensitiveEnum): + """Disabled safety policies for computer use.""" + + SAFETY_POLICY_UNSPECIFIED = 'SAFETY_POLICY_UNSPECIFIED' + """Unspecified safety policy. This value should not be used.""" + FINANCIAL_TRANSACTIONS = 'FINANCIAL_TRANSACTIONS' + """Financial transactions safety policy.""" + SENSITIVE_DATA_MODIFICATION = 'SENSITIVE_DATA_MODIFICATION' + """Sensitive data modification safety policy.""" + COMMUNICATION_TOOL = 'COMMUNICATION_TOOL' + """Communication tool safety policy.""" + ACCOUNT_CREATION = 'ACCOUNT_CREATION' + """Account creation safety policy.""" + DATA_MODIFICATION = 'DATA_MODIFICATION' + """Data modification safety policy.""" + USER_CONSENT_MANAGEMENT = 'USER_CONSENT_MANAGEMENT' + """User consent management safety policy.""" + LEGAL_TERMS_AND_AGREEMENTS = 'LEGAL_TERMS_AND_AGREEMENTS' + """Legal terms and agreements safety policy.""" + + class EmbeddingApiType(_common.CaseInSensitiveEnum): """Enum representing the Gemini Enterprise Agent Platform embedding API to use.""" @@ -3348,6 +3369,10 @@ class ComputerUse(_common.BaseModel): description="""Optional. Whether enable the prompt injection detection check on computer-use request. """, ) + disabled_safety_policies: Optional[list[SafetyPolicy]] = Field( + default=None, + description="""Optional. Disabled safety policies for computer use.""", + ) class ComputerUseDict(TypedDict, total=False): @@ -3367,6 +3392,9 @@ class ComputerUseDict(TypedDict, total=False): """Optional. Whether enable the prompt injection detection check on computer-use request. """ + disabled_safety_policies: Optional[list[SafetyPolicy]] + """Optional. Disabled safety policies for computer use.""" + ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]