File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515Sample code for updating the model armor folder settings of a folder.
1616"""
1717
18- # TODO: Update to change rai filter configs using floor setting
19- # once floor settings API works correctly.
20-
2118from google .cloud import modelarmor_v1
2219
2320
@@ -53,7 +50,12 @@ def update_folder_floor_settings(folder_id: str) -> modelarmor_v1.FloorSetting:
5350 name = floor_settings_name ,
5451 filter_config = modelarmor_v1 .FilterConfig (
5552 rai_settings = modelarmor_v1 .RaiFilterSettings (
56- rai_filters = []
53+ rai_filters = [
54+ modelarmor_v1 .RaiFilterSettings .RaiFilter (
55+ filter_type = modelarmor_v1 .RaiFilterType .HATE_SPEECH ,
56+ confidence_level = modelarmor_v1 .DetectionConfidenceLevel .HIGH ,
57+ )
58+ ]
5759 ),
5860 ),
5961 enable_floor_setting_enforcement = True ,
Original file line number Diff line number Diff line change 1515Sample code for updating the model armor floor settings of an organization.
1616"""
1717
18- # TODO: Update to change rai filter configs using floor setting
19- # once floor settings API works correctly.
20-
2118from google .cloud import modelarmor_v1
2219
2320
@@ -57,7 +54,12 @@ def update_organization_floor_settings(
5754 name = floor_settings_name ,
5855 filter_config = modelarmor_v1 .FilterConfig (
5956 rai_settings = modelarmor_v1 .RaiFilterSettings (
60- rai_filters = []
57+ rai_filters = [
58+ modelarmor_v1 .RaiFilterSettings .RaiFilter (
59+ filter_type = modelarmor_v1 .RaiFilterType .HATE_SPEECH ,
60+ confidence_level = modelarmor_v1 .DetectionConfidenceLevel .HIGH ,
61+ )
62+ ]
6163 ),
6264 ),
6365 enable_floor_setting_enforcement = True ,
Original file line number Diff line number Diff line change 1515Sample code for updating the model armor project floor settings.
1616"""
1717
18- # TODO: Update to change rai filter configs using floor setting
19- # once floor settings API works correctly.
20-
2118from google .cloud import modelarmor_v1
2219
2320
24- def update_project_floor_settings (
25- project_id : str ,
26- ) -> modelarmor_v1 .FloorSetting :
21+ def update_project_floor_settings (project_id : str ) -> modelarmor_v1 .FloorSetting :
2722 """Update the floor settings of a project.
2823
2924 Args:
@@ -55,7 +50,12 @@ def update_project_floor_settings(
5550 name = floor_settings_name ,
5651 filter_config = modelarmor_v1 .FilterConfig (
5752 rai_settings = modelarmor_v1 .RaiFilterSettings (
58- rai_filters = []
53+ rai_filters = [
54+ modelarmor_v1 .RaiFilterSettings .RaiFilter (
55+ filter_type = modelarmor_v1 .RaiFilterType .HATE_SPEECH ,
56+ confidence_level = modelarmor_v1 .DetectionConfidenceLevel .HIGH ,
57+ )
58+ ]
5959 ),
6060 ),
6161 enable_floor_setting_enforcement = True ,
You can’t perform that action at this time.
0 commit comments