Skip to content

Commit be2303f

Browse files
committed
addressed review comments
1 parent 4c7728b commit be2303f

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

model_armor/create_template.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ def create_model_armor_template(project_id: str, location: str, template_id: str
1919
# [START modelarmor_create_template]
2020

2121
from google.api_core.client_options import ClientOptions
22-
from google.cloud import modelarmor_v1
23-
from google.cloud.modelarmor_v1 import Template, DetectionConfidenceLevel, FilterConfig, PiAndJailbreakFilterSettings, \
24-
MaliciousUriFilterSettings
22+
from google.cloud.modelarmor_v1 import (
23+
Template,
24+
DetectionConfidenceLevel,
25+
FilterConfig,
26+
PiAndJailbreakFilterSettings,
27+
MaliciousUriFilterSettings,
28+
)
2529

2630
client = modelarmor_v1.ModelArmorClient(
2731
transport="rest",
@@ -34,7 +38,6 @@ def create_model_armor_template(project_id: str, location: str, template_id: str
3438
# template_id = "template_id"
3539

3640
template = Template(
37-
name=f"projects/{project_id}/locations/{location}/templates/{template_id}",
3841
filter_config=FilterConfig(
3942
pi_and_jailbreak_filter_settings=PiAndJailbreakFilterSettings(
4043
filter_enforcement=PiAndJailbreakFilterSettings.PiAndJailbreakFilterEnforcement.ENABLED,

model_armor/delete_template.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ def delete_model_armor_template(project_id: str, location: str, template_id: str
1717
# [START modelarmor_delete_template]
1818

1919
from google.api_core.client_options import ClientOptions
20-
from google.cloud import modelarmor_v1
20+
from google.cloud.modelarmor_v1 import (
21+
ModelArmorClient,
22+
DeleteTemplateRequest,
23+
)
2124

2225
client = modelarmor_v1.ModelArmorClient(
2326
transport="rest",
2427
client_options=ClientOptions(api_endpoint=f"modelarmor.{location}.rep.googleapis.com"),
2528
)
2629

2730
# TODO(Developer): Uncomment these variables and initialize
28-
# project_id = "your-google-cloud-project-id"
31+
# project_id = "YOUR_PROJECT_ID"
2932
# location = "us-central1"
3033
# template_id = "template_id"
3134

model_armor/get_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_model_armor_template(project_id: str, location: str, template_id: str) -
2727
)
2828

2929
# TODO(Developer): Uncomment these variables and initialize
30-
# project_id = "your-google-cloud-project-id"
30+
# project_id = "YOUR_PROJECT_ID"
3131
# location = "us-central1"
3232
# template_id = "template_id"
3333

model_armor/list_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def list_model_armor_templates(project_id: str, location: str) -> ListTemplatesP
2626
)
2727

2828
# TODO(Developer): Uncomment these variables and initialize
29-
# project_id = "your-google-cloud-project-id"
29+
# project_id = "YOUR_PROJECT_ID"
3030
# location = "us-central1"
3131

3232
# Initialize request argument(s)

model_armor/sanitize_user_prompt.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ def sanitize_user_prompt(
2929
)
3030

3131
# TODO(Developer): Uncomment these variables and initialize
32-
# project_id = "your-google-cloud-project-id"
32+
# project_id = "YOUR_PROJECT_ID"
3333
# location = "us-central1"
3434
# template_id = "template_id"
3535

3636
# Define the prompt
3737
user_prompt = "Can you describe this link? https://testsafebrowsing.appspot.com/s/malware.html"
3838

3939
# Initialize request argument(s)
40-
user_prompt_data = modelarmor_v1.DataItem()
41-
user_prompt_data.text = user_prompt
40+
user_prompt_data = modelarmor_v1.DataItem(
41+
text=user_prompt
42+
)
4243

4344
request = modelarmor_v1.SanitizeUserPromptRequest(
4445
name=f"projects/{project_id}/locations/{location}/templates/{template_id}",

model_armor/update_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def update_model_armor_template(project_id: str, location: str, template_id: str
2929
)
3030

3131
# TODO(Developer): Uncomment these variables and initialize
32-
# project_id = "your-google-cloud-project-id"
32+
# project_id = "YOUR_PROJECT_ID"
3333
# location = "us-central1"
3434
# template_id = "template_id"
3535

0 commit comments

Comments
 (0)