Skip to content

Commit eb3a7b1

Browse files
google-genai-botcopybara-github
authored andcommitted
feat(interaction-api): Add ModelArmorConfig to Interaction proto.
FUTURE_COPYBARA_INTEGRATE_REVIEW=#2380 from googleapis:release-please--branches--main 10645e4 PiperOrigin-RevId: 911590846
1 parent e64fc2a commit eb3a7b1

6 files changed

Lines changed: 170 additions & 1 deletion

File tree

google/genai/_interactions/resources/interactions.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222

2323
import httpx
2424

25-
from ..types import interaction_get_params, interaction_create_params
25+
from ..types import (
26+
interaction_get_params,
27+
interaction_create_params,
28+
)
2629
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
2730
from .._utils import required_args, maybe_transform, async_maybe_transform
2831
from .._compat import cached_property
@@ -41,6 +44,7 @@
4144
from ..types.webhook_config_param import WebhookConfigParam
4245
from ..types.interaction_sse_event import InteractionSSEEvent
4346
from ..types.generation_config_param import GenerationConfigParam
47+
from ..types.model_armor_config_param import ModelArmorConfigParam
4448

4549
__all__ = ["InteractionsResource", "AsyncInteractionsResource"]
4650

@@ -74,6 +78,7 @@ def create(
7478
model: ModelParam,
7579
background: bool | Omit = omit,
7680
generation_config: GenerationConfigParam | Omit = omit,
81+
model_armor_config: ModelArmorConfigParam | Omit = omit,
7782
previous_interaction_id: str | Omit = omit,
7883
response_format: interaction_create_params.ResponseFormat | Omit = omit,
7984
response_mime_type: str | Omit = omit,
@@ -103,6 +108,8 @@ def create(
103108
104109
generation_config: Input only. Configuration parameters for the model interaction.
105110
111+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
112+
106113
previous_interaction_id: The ID of the previous interaction, if any.
107114
108115
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -145,6 +152,7 @@ def create(
145152
stream: Literal[True],
146153
background: bool | Omit = omit,
147154
generation_config: GenerationConfigParam | Omit = omit,
155+
model_armor_config: ModelArmorConfigParam | Omit = omit,
148156
previous_interaction_id: str | Omit = omit,
149157
response_format: interaction_create_params.ResponseFormat | Omit = omit,
150158
response_mime_type: str | Omit = omit,
@@ -175,6 +183,8 @@ def create(
175183
176184
generation_config: Input only. Configuration parameters for the model interaction.
177185
186+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
187+
178188
previous_interaction_id: The ID of the previous interaction, if any.
179189
180190
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -221,6 +231,7 @@ def create(
221231
input: interaction_create_params.Input,
222232
agent_config: interaction_create_params.AgentConfig | Omit = omit,
223233
background: bool | Omit = omit,
234+
model_armor_config: ModelArmorConfigParam | Omit = omit,
224235
previous_interaction_id: str | Omit = omit,
225236
response_format: interaction_create_params.ResponseFormat | Omit = omit,
226237
response_mime_type: str | Omit = omit,
@@ -250,6 +261,8 @@ def create(
250261
251262
background: Input only. Whether to run the model interaction in the background.
252263
264+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
265+
253266
previous_interaction_id: The ID of the previous interaction, if any.
254267
255268
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -299,6 +312,7 @@ def create(
299312
stream: Literal[True],
300313
agent_config: interaction_create_params.AgentConfig | Omit = omit,
301314
background: bool | Omit = omit,
315+
model_armor_config: ModelArmorConfigParam | Omit = omit,
302316
previous_interaction_id: str | Omit = omit,
303317
response_format: interaction_create_params.ResponseFormat | Omit = omit,
304318
response_mime_type: str | Omit = omit,
@@ -329,6 +343,8 @@ def create(
329343
330344
background: Input only. Whether to run the model interaction in the background.
331345
346+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
347+
332348
previous_interaction_id: The ID of the previous interaction, if any.
333349
334350
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -369,6 +385,7 @@ def create(
369385
stream: bool,
370386
background: bool | Omit = omit,
371387
generation_config: GenerationConfigParam | Omit = omit,
388+
model_armor_config: ModelArmorConfigParam | Omit = omit,
372389
previous_interaction_id: str | Omit = omit,
373390
response_format: interaction_create_params.ResponseFormat | Omit = omit,
374391
response_mime_type: str | Omit = omit,
@@ -399,6 +416,8 @@ def create(
399416
400417
generation_config: Input only. Configuration parameters for the model interaction.
401418
419+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
420+
402421
previous_interaction_id: The ID of the previous interaction, if any.
403422
404423
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -438,6 +457,7 @@ def create(
438457
model: ModelParam | Omit = omit,
439458
background: bool | Omit = omit,
440459
generation_config: GenerationConfigParam | Omit = omit,
460+
model_armor_config: ModelArmorConfigParam | Omit = omit,
441461
previous_interaction_id: str | Omit = omit,
442462
response_format: interaction_create_params.ResponseFormat | Omit = omit,
443463
response_mime_type: str | Omit = omit,
@@ -481,6 +501,7 @@ def create(
481501
"model": model,
482502
"background": background,
483503
"generation_config": generation_config,
504+
"model_armor_config": model_armor_config,
484505
"previous_interaction_id": previous_interaction_id,
485506
"response_format": response_format,
486507
"response_mime_type": response_mime_type,
@@ -770,6 +791,7 @@ async def create(
770791
model: ModelParam,
771792
background: bool | Omit = omit,
772793
generation_config: GenerationConfigParam | Omit = omit,
794+
model_armor_config: ModelArmorConfigParam | Omit = omit,
773795
previous_interaction_id: str | Omit = omit,
774796
response_format: interaction_create_params.ResponseFormat | Omit = omit,
775797
response_mime_type: str | Omit = omit,
@@ -799,6 +821,8 @@ async def create(
799821
800822
generation_config: Input only. Configuration parameters for the model interaction.
801823
824+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
825+
802826
previous_interaction_id: The ID of the previous interaction, if any.
803827
804828
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -841,6 +865,7 @@ async def create(
841865
stream: Literal[True],
842866
background: bool | Omit = omit,
843867
generation_config: GenerationConfigParam | Omit = omit,
868+
model_armor_config: ModelArmorConfigParam | Omit = omit,
844869
previous_interaction_id: str | Omit = omit,
845870
response_format: interaction_create_params.ResponseFormat | Omit = omit,
846871
response_mime_type: str | Omit = omit,
@@ -871,6 +896,8 @@ async def create(
871896
872897
generation_config: Input only. Configuration parameters for the model interaction.
873898
899+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
900+
874901
previous_interaction_id: The ID of the previous interaction, if any.
875902
876903
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -917,6 +944,7 @@ async def create(
917944
input: interaction_create_params.Input,
918945
agent_config: interaction_create_params.AgentConfig | Omit = omit,
919946
background: bool | Omit = omit,
947+
model_armor_config: ModelArmorConfigParam | Omit = omit,
920948
previous_interaction_id: str | Omit = omit,
921949
response_format: interaction_create_params.ResponseFormat | Omit = omit,
922950
response_mime_type: str | Omit = omit,
@@ -946,6 +974,8 @@ async def create(
946974
947975
background: Input only. Whether to run the model interaction in the background.
948976
977+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
978+
949979
previous_interaction_id: The ID of the previous interaction, if any.
950980
951981
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -995,6 +1025,7 @@ async def create(
9951025
stream: Literal[True],
9961026
agent_config: interaction_create_params.AgentConfig | Omit = omit,
9971027
background: bool | Omit = omit,
1028+
model_armor_config: ModelArmorConfigParam | Omit = omit,
9981029
previous_interaction_id: str | Omit = omit,
9991030
response_format: interaction_create_params.ResponseFormat | Omit = omit,
10001031
response_mime_type: str | Omit = omit,
@@ -1025,6 +1056,8 @@ async def create(
10251056
10261057
background: Input only. Whether to run the model interaction in the background.
10271058
1059+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
1060+
10281061
previous_interaction_id: The ID of the previous interaction, if any.
10291062
10301063
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -1065,6 +1098,7 @@ async def create(
10651098
stream: bool,
10661099
background: bool | Omit = omit,
10671100
generation_config: GenerationConfigParam | Omit = omit,
1101+
model_armor_config: ModelArmorConfigParam | Omit = omit,
10681102
previous_interaction_id: str | Omit = omit,
10691103
response_format: interaction_create_params.ResponseFormat | Omit = omit,
10701104
response_mime_type: str | Omit = omit,
@@ -1095,6 +1129,8 @@ async def create(
10951129
10961130
generation_config: Input only. Configuration parameters for the model interaction.
10971131
1132+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
1133+
10981134
previous_interaction_id: The ID of the previous interaction, if any.
10991135
11001136
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -1134,6 +1170,7 @@ async def create(
11341170
model: ModelParam | Omit = omit,
11351171
background: bool | Omit = omit,
11361172
generation_config: GenerationConfigParam | Omit = omit,
1173+
model_armor_config: ModelArmorConfigParam | Omit = omit,
11371174
previous_interaction_id: str | Omit = omit,
11381175
response_format: interaction_create_params.ResponseFormat | Omit = omit,
11391176
response_mime_type: str | Omit = omit,
@@ -1177,6 +1214,7 @@ async def create(
11771214
"model": model,
11781215
"background": background,
11791216
"generation_config": generation_config,
1217+
"model_armor_config": model_armor_config,
11801218
"previous_interaction_id": previous_interaction_id,
11811219
"response_format": response_format,
11821220
"response_mime_type": response_mime_type,

google/genai/_interactions/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
from .model_output_step import ModelOutputStep as ModelOutputStep
5959
from .function_call_step import FunctionCallStep as FunctionCallStep
6060
from .image_config_param import ImageConfigParam as ImageConfigParam
61+
from .model_armor_config import ModelArmorConfig as ModelArmorConfig
6162
from .text_content_param import TextContentParam as TextContentParam
6263
from .thought_step_param import ThoughtStepParam as ThoughtStepParam
6364
from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig
@@ -98,6 +99,7 @@
9899
from .webhook_delete_response import WebhookDeleteResponse as WebhookDeleteResponse
99100
from .code_execution_call_step import CodeExecutionCallStep as CodeExecutionCallStep
100101
from .function_call_step_param import FunctionCallStepParam as FunctionCallStepParam
102+
from .model_armor_config_param import ModelArmorConfigParam as ModelArmorConfigParam
101103
from .tool_choice_config_param import ToolChoiceConfigParam as ToolChoiceConfigParam
102104
from .google_search_result_step import GoogleSearchResultStep as GoogleSearchResultStep
103105
from .interaction_create_params import InteractionCreateParams as InteractionCreateParams

google/genai/_interactions/types/interaction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from datetime import datetime
2020
from typing_extensions import Literal, Annotated, TypeAlias
2121

22+
from pydantic import Field as FieldInfo
23+
2224
from .step import Step
2325
from .tool import Tool
2426
from .model import Model
@@ -32,6 +34,7 @@
3234
from .video_content import VideoContent
3335
from .webhook_config import WebhookConfig
3436
from .document_content import DocumentContent
37+
from .model_armor_config import ModelArmorConfig
3538
from .dynamic_agent_config import DynamicAgentConfig
3639
from .text_response_format import TextResponseFormat
3740
from .audio_response_format import AudioResponseFormat
@@ -104,6 +107,9 @@ class Interaction(BaseModel):
104107
model: Optional[Model] = None
105108
"""The name of the `Model` used for generating the interaction."""
106109

110+
api_model_armor_config: Optional[ModelArmorConfig] = FieldInfo(alias="model_armor_config", default=None)
111+
"""Settings for prompt and response sanitization using the Model Armor service."""
112+
107113
previous_interaction_id: Optional[str] = None
108114
"""The ID of the previous interaction, if any."""
109115

google/genai/_interactions/types/interaction_create_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .webhook_config_param import WebhookConfigParam
3232
from .document_content_param import DocumentContentParam
3333
from .generation_config_param import GenerationConfigParam
34+
from .model_armor_config_param import ModelArmorConfigParam
3435
from .dynamic_agent_config_param import DynamicAgentConfigParam
3536
from .text_response_format_param import TextResponseFormatParam
3637
from .audio_response_format_param import AudioResponseFormatParam
@@ -67,6 +68,9 @@ class BaseCreateModelInteractionParams(TypedDict, total=False):
6768
generation_config: GenerationConfigParam
6869
"""Input only. Configuration parameters for the model interaction."""
6970

71+
model_armor_config: ModelArmorConfigParam
72+
"""Settings for prompt and response sanitization using the Model Armor service."""
73+
7074
previous_interaction_id: str
7175
"""The ID of the previous interaction, if any."""
7276

@@ -151,6 +155,9 @@ class BaseCreateAgentInteractionParams(TypedDict, total=False):
151155
background: bool
152156
"""Input only. Whether to run the model interaction in the background."""
153157

158+
model_armor_config: ModelArmorConfigParam
159+
"""Settings for prompt and response sanitization using the Model Armor service."""
160+
154161
previous_interaction_id: str
155162
"""The ID of the previous interaction, if any."""
156163

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
17+
18+
from typing import Optional
19+
20+
from pydantic import Field as FieldInfo
21+
22+
from .._models import BaseModel
23+
24+
__all__ = ["ModelArmorConfig"]
25+
26+
27+
class ModelArmorConfig(BaseModel):
28+
"""Configuration for Model Armor.
29+
30+
Model Armor is a Google Cloud service that provides safety and security
31+
filtering for prompts and responses. It helps protect your AI applications
32+
from risks such as harmful content, sensitive data leakage, and prompt
33+
injection attacks.
34+
"""
35+
36+
prompt_template_name: Optional[str] = FieldInfo(alias="promptTemplateName", default=None)
37+
"""The resource name of the Model Armor template to use for prompt screening.
38+
39+
A Model Armor template is a set of customized filters and thresholds that define
40+
how Model Armor screens content. If specified, Model Armor will use this
41+
template to check the user's prompt for safety and security risks before it is
42+
sent to the model.
43+
44+
The name must be in the format
45+
`projects/{project}/locations/{location}/templates/{template}`.
46+
"""
47+
48+
response_template_name: Optional[str] = FieldInfo(alias="responseTemplateName", default=None)
49+
"""The resource name of the Model Armor template to use for response screening.
50+
51+
A Model Armor template is a set of customized filters and thresholds that define
52+
how Model Armor screens content. If specified, Model Armor will use this
53+
template to check the model's response for safety and security risks before it
54+
is returned to the user.
55+
56+
The name must be in the format
57+
`projects/{project}/locations/{location}/templates/{template}`.
58+
"""

0 commit comments

Comments
 (0)