Skip to content

Commit d7e928b

Browse files
Add tools and guardrails back to CES agent tests (#15712)
1 parent ff45078 commit d7e928b

File tree

2 files changed

+109
-109
lines changed

2 files changed

+109
-109
lines changed

mmv1/templates/terraform/examples/ces_agent_basic.tf.tmpl

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ resource "google_ces_app" "ces_app_for_agent" {
1616
}
1717
}
1818

19-
#resource "google_ces_tool" "ces_tool_for_agent" {
20-
# location = "us"
21-
# app = google_ces_app.ces_app_for_agent.app_id
22-
# tool_id = "tool-1"
23-
# execution_type = "SYNCHRONOUS"
24-
# python_function {
25-
# name = "example_function"
26-
# python_code = "def example_function() -> int: return 0"
27-
# }
28-
#}
19+
resource "google_ces_tool" "ces_tool_for_agent" {
20+
location = "us"
21+
app = google_ces_app.ces_app_for_agent.app_id
22+
tool_id = "tool-1"
23+
execution_type = "SYNCHRONOUS"
24+
python_function {
25+
name = "example_function"
26+
python_code = "def example_function() -> int: return 0"
27+
}
28+
}
2929

3030
resource "google_ces_toolset" "ces_toolset_for_agent" {
3131
toolset_id = "{{index $.Vars "toolset_id"}}"
@@ -81,28 +81,28 @@ resource "google_ces_agent" "ces_child_agent" {
8181
}
8282

8383

84-
#resource "google_ces_guardrail" "ces_guardrail_for_agent" {
85-
# guardrail_id = "guardrail-id"
86-
# location = google_ces_app.ces_app_for_agent.location
87-
# app = google_ces_app.ces_app_for_agent.app_id
88-
# display_name = "Example guardrail"
89-
# description = "Guardrail description"
90-
# action {
91-
# respond_immediately {
92-
# responses {
93-
# text = "Text"
94-
# disabled = false
95-
# }
96-
# }
97-
# }
98-
# enabled = true
99-
# model_safety {
100-
# safety_settings {
101-
# category = "HARM_CATEGORY_HATE_SPEECH"
102-
# threshold = "BLOCK_NONE"
103-
# }
104-
# }
105-
#}
84+
resource "google_ces_guardrail" "ces_guardrail_for_agent" {
85+
guardrail_id = "guardrail-id"
86+
location = google_ces_app.ces_app_for_agent.location
87+
app = google_ces_app.ces_app_for_agent.app_id
88+
display_name = "Example guardrail"
89+
description = "Guardrail description"
90+
action {
91+
respond_immediately {
92+
responses {
93+
text = "Text"
94+
disabled = false
95+
}
96+
}
97+
}
98+
enabled = true
99+
model_safety {
100+
safety_settings {
101+
category = "HARM_CATEGORY_HATE_SPEECH"
102+
threshold = "BLOCK_NONE"
103+
}
104+
}
105+
}
106106

107107

108108

@@ -157,13 +157,13 @@ resource "google_ces_agent" "ces_agent_basic" {
157157
python_code = "def callback(context):\n return {'override': False}"
158158
}
159159

160-
# tools = [
161-
# google_ces_tool.ces_tool_for_agent.id
162-
# ]
163-
#
164-
# guardrails = [
165-
# google_ces_guardrail.ces_guardrail_for_agent.id
166-
# ]
160+
tools = [
161+
google_ces_tool.ces_tool_for_agent.id
162+
]
163+
164+
guardrails = [
165+
google_ces_guardrail.ces_guardrail_for_agent.id
166+
]
167167

168168
toolsets {
169169
toolset = google_ces_toolset.ces_toolset_for_agent.id

mmv1/third_party/terraform/services/ces/ces_agent_test.go

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ resource "google_ces_app" "ces_app_for_agent" {
6767
}
6868
}
6969
70-
// resource "google_ces_tool" "ces_tool_for_agent" {
71-
// location = "us"
72-
// app = google_ces_app.ces_app_for_agent.app_id
73-
// tool_id = "tool-1"
74-
// execution_type = "SYNCHRONOUS"
75-
// python_function {
76-
// name = "example_function"
77-
// python_code = "def example_function() -> int: return 0"
78-
// }
79-
// }
70+
resource "google_ces_tool" "ces_tool_for_agent" {
71+
location = "us"
72+
app = google_ces_app.ces_app_for_agent.app_id
73+
tool_id = "tool-1"
74+
execution_type = "SYNCHRONOUS"
75+
python_function {
76+
name = "example_function"
77+
python_code = "def example_function() -> int: return 0"
78+
}
79+
}
8080
8181
resource "google_ces_toolset" "ces_toolset_for_agent" {
8282
toolset_id = "tf-test-toolset-id%{random_suffix}"
@@ -131,28 +131,28 @@ resource "google_ces_agent" "ces_child_agent" {
131131
}
132132
133133
134-
// resource "google_ces_guardrail" "ces_guardrail_for_agent" {
135-
// guardrail_id = "guardrail-id"
136-
// location = google_ces_app.ces_app_for_agent.location
137-
// app = google_ces_app.ces_app_for_agent.app_id
138-
// display_name = "Example guardrail"
139-
// description = "Guardrail description"
140-
// action {
141-
// respond_immediately {
142-
// responses {
143-
// text = "Text"
144-
// disabled = false
145-
// }
146-
// }
147-
// }
148-
// enabled = true
149-
// model_safety {
150-
// safety_settings {
151-
// category = "HARM_CATEGORY_HATE_SPEECH"
152-
// threshold = "BLOCK_NONE"
153-
// }
154-
// }
155-
// }
134+
resource "google_ces_guardrail" "ces_guardrail_for_agent" {
135+
guardrail_id = "guardrail-id"
136+
location = google_ces_app.ces_app_for_agent.location
137+
app = google_ces_app.ces_app_for_agent.app_id
138+
display_name = "Example guardrail"
139+
description = "Guardrail description"
140+
action {
141+
respond_immediately {
142+
responses {
143+
text = "Text"
144+
disabled = false
145+
}
146+
}
147+
}
148+
enabled = true
149+
model_safety {
150+
safety_settings {
151+
category = "HARM_CATEGORY_HATE_SPEECH"
152+
threshold = "BLOCK_NONE"
153+
}
154+
}
155+
}
156156
157157
158158
@@ -203,13 +203,13 @@ resource "google_ces_agent" "ces_agent_basic" {
203203
python_code = "def callback(context):\n return {'override': False}"
204204
}
205205
206-
// tools = [
207-
// google_ces_tool.ces_tool_for_agent.id
208-
// ]
206+
tools = [
207+
google_ces_tool.ces_tool_for_agent.id
208+
]
209209
210-
// guardrails = [
211-
// google_ces_guardrail.ces_guardrail_for_agent.id
212-
// ]
210+
guardrails = [
211+
google_ces_guardrail.ces_guardrail_for_agent.id
212+
]
213213
214214
toolsets {
215215
toolset = google_ces_toolset.ces_toolset_for_agent.id
@@ -243,16 +243,16 @@ resource "google_ces_app" "ces_app_for_agent" {
243243
}
244244
}
245245
246-
// resource "google_ces_tool" "ces_tool_for_agent" {
247-
// location = "us"
248-
// app = google_ces_app.ces_app_for_agent.app_id
249-
// tool_id = "tool-1"
250-
// execution_type = "SYNCHRONOUS"
251-
// python_function {
252-
// name = "example_function"
253-
// python_code = "def example_function() -> int: return 0"
254-
// }
255-
// }
246+
resource "google_ces_tool" "ces_tool_for_agent" {
247+
location = "us"
248+
app = google_ces_app.ces_app_for_agent.app_id
249+
tool_id = "tool-1"
250+
execution_type = "SYNCHRONOUS"
251+
python_function {
252+
name = "example_function"
253+
python_code = "def example_function() -> int: return 0"
254+
}
255+
}
256256
257257
resource "google_ces_toolset" "ces_toolset_for_agent" {
258258
toolset_id = "tf-test-toolset-id%{random_suffix}"
@@ -302,28 +302,28 @@ resource "google_ces_agent" "ces_child_agent" {
302302
}
303303
304304
305-
// resource "google_ces_guardrail" "ces_guardrail_for_agent" {
306-
// guardrail_id = "guardrail-id"
307-
// location = google_ces_app.ces_app_for_agent.location
308-
// app = google_ces_app.ces_app_for_agent.app_id
309-
// display_name = "Example guardrail"
310-
// description = "Guardrail description"
311-
// action {
312-
// respond_immediately {
313-
// responses {
314-
// text = "Text"
315-
// disabled = false
316-
// }
317-
// }
318-
// }
319-
// enabled = true
320-
// model_safety {
321-
// safety_settings {
322-
// category = "HARM_CATEGORY_HATE_SPEECH"
323-
// threshold = "BLOCK_NONE"
324-
// }
325-
// }
326-
// }
305+
resource "google_ces_guardrail" "ces_guardrail_for_agent" {
306+
guardrail_id = "guardrail-id"
307+
location = google_ces_app.ces_app_for_agent.location
308+
app = google_ces_app.ces_app_for_agent.app_id
309+
display_name = "Example guardrail"
310+
description = "Guardrail description"
311+
action {
312+
respond_immediately {
313+
responses {
314+
text = "Text"
315+
disabled = false
316+
}
317+
}
318+
}
319+
enabled = true
320+
model_safety {
321+
safety_settings {
322+
category = "HARM_CATEGORY_HATE_SPEECH"
323+
threshold = "BLOCK_NONE"
324+
}
325+
}
326+
}
327327
328328
329329

0 commit comments

Comments
 (0)