Skip to content

Commit a6e92c9

Browse files
google-genai-botcopybara-github
authored andcommitted
feat(interaction-api): Add ModelArmorConfig to Interaction proto.
PiperOrigin-RevId: 911590846
1 parent 2ce0298 commit a6e92c9

4 files changed

Lines changed: 54 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
@@ -48,6 +51,7 @@
4851
from ..types.webhook_config_param import WebhookConfigParam
4952
from ..types.interaction_sse_event import InteractionSSEEvent
5053
from ..types.generation_config_param import GenerationConfigParam
54+
from ..types.model_armor_config_param import ModelArmorConfigParam
5155

5256
__all__ = ["InteractionsResource", "AsyncInteractionsResource"]
5357

@@ -81,6 +85,7 @@ def create(
8185
model: ModelParam,
8286
background: bool | Omit = omit,
8387
generation_config: GenerationConfigParam | Omit = omit,
88+
model_armor_config: ModelArmorConfigParam | Omit = omit,
8489
previous_interaction_id: str | Omit = omit,
8590
response_format: interaction_create_params.ResponseFormat | Omit = omit,
8691
response_mime_type: str | Omit = omit,
@@ -110,6 +115,8 @@ def create(
110115
111116
generation_config: Input only. Configuration parameters for the model interaction.
112117
118+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
119+
113120
previous_interaction_id: The ID of the previous interaction, if any.
114121
115122
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -152,6 +159,7 @@ def create(
152159
stream: Literal[True],
153160
background: bool | Omit = omit,
154161
generation_config: GenerationConfigParam | Omit = omit,
162+
model_armor_config: ModelArmorConfigParam | Omit = omit,
155163
previous_interaction_id: str | Omit = omit,
156164
response_format: interaction_create_params.ResponseFormat | Omit = omit,
157165
response_mime_type: str | Omit = omit,
@@ -182,6 +190,8 @@ def create(
182190
183191
generation_config: Input only. Configuration parameters for the model interaction.
184192
193+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
194+
185195
previous_interaction_id: The ID of the previous interaction, if any.
186196
187197
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -228,6 +238,7 @@ def create(
228238
input: interaction_create_params.Input,
229239
agent_config: interaction_create_params.AgentConfig | Omit = omit,
230240
background: bool | Omit = omit,
241+
model_armor_config: ModelArmorConfigParam | Omit = omit,
231242
previous_interaction_id: str | Omit = omit,
232243
response_format: interaction_create_params.ResponseFormat | Omit = omit,
233244
response_mime_type: str | Omit = omit,
@@ -257,6 +268,8 @@ def create(
257268
258269
background: Input only. Whether to run the model interaction in the background.
259270
271+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
272+
260273
previous_interaction_id: The ID of the previous interaction, if any.
261274
262275
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -306,6 +319,7 @@ def create(
306319
stream: Literal[True],
307320
agent_config: interaction_create_params.AgentConfig | Omit = omit,
308321
background: bool | Omit = omit,
322+
model_armor_config: ModelArmorConfigParam | Omit = omit,
309323
previous_interaction_id: str | Omit = omit,
310324
response_format: interaction_create_params.ResponseFormat | Omit = omit,
311325
response_mime_type: str | Omit = omit,
@@ -336,6 +350,8 @@ def create(
336350
337351
background: Input only. Whether to run the model interaction in the background.
338352
353+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
354+
339355
previous_interaction_id: The ID of the previous interaction, if any.
340356
341357
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -376,6 +392,7 @@ def create(
376392
stream: bool,
377393
background: bool | Omit = omit,
378394
generation_config: GenerationConfigParam | Omit = omit,
395+
model_armor_config: ModelArmorConfigParam | Omit = omit,
379396
previous_interaction_id: str | Omit = omit,
380397
response_format: interaction_create_params.ResponseFormat | Omit = omit,
381398
response_mime_type: str | Omit = omit,
@@ -406,6 +423,8 @@ def create(
406423
407424
generation_config: Input only. Configuration parameters for the model interaction.
408425
426+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
427+
409428
previous_interaction_id: The ID of the previous interaction, if any.
410429
411430
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -445,6 +464,7 @@ def create(
445464
model: ModelParam | Omit = omit,
446465
background: bool | Omit = omit,
447466
generation_config: GenerationConfigParam | Omit = omit,
467+
model_armor_config: ModelArmorConfigParam | Omit = omit,
448468
previous_interaction_id: str | Omit = omit,
449469
response_format: interaction_create_params.ResponseFormat | Omit = omit,
450470
response_mime_type: str | Omit = omit,
@@ -499,6 +519,7 @@ def create(
499519
"model": model,
500520
"background": background,
501521
"generation_config": generation_config,
522+
"model_armor_config": model_armor_config,
502523
"previous_interaction_id": previous_interaction_id,
503524
"response_format": response_format,
504525
"response_mime_type": response_mime_type,
@@ -799,6 +820,7 @@ async def create(
799820
model: ModelParam,
800821
background: bool | Omit = omit,
801822
generation_config: GenerationConfigParam | Omit = omit,
823+
model_armor_config: ModelArmorConfigParam | Omit = omit,
802824
previous_interaction_id: str | Omit = omit,
803825
response_format: interaction_create_params.ResponseFormat | Omit = omit,
804826
response_mime_type: str | Omit = omit,
@@ -828,6 +850,8 @@ async def create(
828850
829851
generation_config: Input only. Configuration parameters for the model interaction.
830852
853+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
854+
831855
previous_interaction_id: The ID of the previous interaction, if any.
832856
833857
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -870,6 +894,7 @@ async def create(
870894
stream: Literal[True],
871895
background: bool | Omit = omit,
872896
generation_config: GenerationConfigParam | Omit = omit,
897+
model_armor_config: ModelArmorConfigParam | Omit = omit,
873898
previous_interaction_id: str | Omit = omit,
874899
response_format: interaction_create_params.ResponseFormat | Omit = omit,
875900
response_mime_type: str | Omit = omit,
@@ -900,6 +925,8 @@ async def create(
900925
901926
generation_config: Input only. Configuration parameters for the model interaction.
902927
928+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
929+
903930
previous_interaction_id: The ID of the previous interaction, if any.
904931
905932
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -946,6 +973,7 @@ async def create(
946973
input: interaction_create_params.Input,
947974
agent_config: interaction_create_params.AgentConfig | Omit = omit,
948975
background: bool | Omit = omit,
976+
model_armor_config: ModelArmorConfigParam | Omit = omit,
949977
previous_interaction_id: str | Omit = omit,
950978
response_format: interaction_create_params.ResponseFormat | Omit = omit,
951979
response_mime_type: str | Omit = omit,
@@ -975,6 +1003,8 @@ async def create(
9751003
9761004
background: Input only. Whether to run the model interaction in the background.
9771005
1006+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
1007+
9781008
previous_interaction_id: The ID of the previous interaction, if any.
9791009
9801010
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -1024,6 +1054,7 @@ async def create(
10241054
stream: Literal[True],
10251055
agent_config: interaction_create_params.AgentConfig | Omit = omit,
10261056
background: bool | Omit = omit,
1057+
model_armor_config: ModelArmorConfigParam | Omit = omit,
10271058
previous_interaction_id: str | Omit = omit,
10281059
response_format: interaction_create_params.ResponseFormat | Omit = omit,
10291060
response_mime_type: str | Omit = omit,
@@ -1054,6 +1085,8 @@ async def create(
10541085
10551086
background: Input only. Whether to run the model interaction in the background.
10561087
1088+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
1089+
10571090
previous_interaction_id: The ID of the previous interaction, if any.
10581091
10591092
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -1094,6 +1127,7 @@ async def create(
10941127
stream: bool,
10951128
background: bool | Omit = omit,
10961129
generation_config: GenerationConfigParam | Omit = omit,
1130+
model_armor_config: ModelArmorConfigParam | Omit = omit,
10971131
previous_interaction_id: str | Omit = omit,
10981132
response_format: interaction_create_params.ResponseFormat | Omit = omit,
10991133
response_mime_type: str | Omit = omit,
@@ -1124,6 +1158,8 @@ async def create(
11241158
11251159
generation_config: Input only. Configuration parameters for the model interaction.
11261160
1161+
model_armor_config: Settings for prompt and response sanitization using the Model Armor service.
1162+
11271163
previous_interaction_id: The ID of the previous interaction, if any.
11281164
11291165
response_format: Enforces that the generated response is a JSON object that complies with the
@@ -1163,6 +1199,7 @@ async def create(
11631199
model: ModelParam | Omit = omit,
11641200
background: bool | Omit = omit,
11651201
generation_config: GenerationConfigParam | Omit = omit,
1202+
model_armor_config: ModelArmorConfigParam | Omit = omit,
11661203
previous_interaction_id: str | Omit = omit,
11671204
response_format: interaction_create_params.ResponseFormat | Omit = omit,
11681205
response_mime_type: str | Omit = omit,
@@ -1213,6 +1250,7 @@ async def create(
12131250
"model": model,
12141251
"background": background,
12151252
"generation_config": generation_config,
1253+
"model_armor_config": model_armor_config,
12161254
"previous_interaction_id": previous_interaction_id,
12171255
"response_format": response_format,
12181256
"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
@@ -59,6 +59,7 @@
5959
from .function_call_step import FunctionCallStep as FunctionCallStep
6060
from .google_maps_result import GoogleMapsResult as GoogleMapsResult
6161
from .image_config_param import ImageConfigParam as ImageConfigParam
62+
from .model_armor_config import ModelArmorConfig as ModelArmorConfig
6263
from .text_content_param import TextContentParam as TextContentParam
6364
from .thought_step_param import ThoughtStepParam as ThoughtStepParam
6465
from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig
@@ -100,6 +101,7 @@
100101
from .webhook_delete_response import WebhookDeleteResponse as WebhookDeleteResponse
101102
from .code_execution_call_step import CodeExecutionCallStep as CodeExecutionCallStep
102103
from .function_call_step_param import FunctionCallStepParam as FunctionCallStepParam
104+
from .model_armor_config_param import ModelArmorConfigParam as ModelArmorConfigParam
103105
from .tool_choice_config_param import ToolChoiceConfigParam as ToolChoiceConfigParam
104106
from .google_search_result_step import GoogleSearchResultStep as GoogleSearchResultStep
105107
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, override
2121

22+
from pydantic import Field as FieldInfo
23+
2224
from .step import Step
2325
from .tool import Tool
2426
from .model import Model
@@ -34,6 +36,7 @@
3436
from .._legacy_lyria import is_legacy_lyria_response_body
3537
from .webhook_config import WebhookConfig
3638
from .document_content import DocumentContent
39+
from .model_armor_config import ModelArmorConfig
3740
from .dynamic_agent_config import DynamicAgentConfig
3841
from .text_response_format import TextResponseFormat
3942
from .audio_response_format import AudioResponseFormat
@@ -103,6 +106,9 @@ class Interaction(BaseModel):
103106
model: Optional[Model] = None
104107
"""The name of the `Model` used for generating the interaction."""
105108

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

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
@@ -66,6 +67,9 @@ class BaseCreateModelInteractionParams(TypedDict, total=False):
6667
generation_config: GenerationConfigParam
6768
"""Input only. Configuration parameters for the model interaction."""
6869

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

@@ -149,6 +153,9 @@ class BaseCreateAgentInteractionParams(TypedDict, total=False):
149153
background: bool
150154
"""Input only. Whether to run the model interaction in the background."""
151155

156+
model_armor_config: ModelArmorConfigParam
157+
"""Settings for prompt and response sanitization using the Model Armor service."""
158+
152159
previous_interaction_id: str
153160
"""The ID of the previous interaction, if any."""
154161

0 commit comments

Comments
 (0)