Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion google/genai/_interactions/resources/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

import httpx

from ..types import interaction_get_params, interaction_create_params
from ..types import (
interaction_get_params,
interaction_create_params,
)
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from .._utils import required_args, maybe_transform, async_maybe_transform
from .._compat import cached_property
Expand All @@ -41,6 +44,7 @@
from ..types.webhook_config_param import WebhookConfigParam
from ..types.interaction_sse_event import InteractionSSEEvent
from ..types.generation_config_param import GenerationConfigParam
from ..types.model_armor_config_param import ModelArmorConfigParam

__all__ = ["InteractionsResource", "AsyncInteractionsResource"]

Expand Down Expand Up @@ -74,6 +78,7 @@ def create(
model: ModelParam,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -103,6 +108,8 @@ def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -145,6 +152,7 @@ def create(
stream: Literal[True],
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -175,6 +183,8 @@ def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -221,6 +231,7 @@ def create(
input: interaction_create_params.Input,
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -250,6 +261,8 @@ def create(

background: Input only. Whether to run the model interaction in the background.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -299,6 +312,7 @@ def create(
stream: Literal[True],
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -329,6 +343,8 @@ def create(

background: Input only. Whether to run the model interaction in the background.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -369,6 +385,7 @@ def create(
stream: bool,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -399,6 +416,8 @@ def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -438,6 +457,7 @@ def create(
model: ModelParam | Omit = omit,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -481,6 +501,7 @@ def create(
"model": model,
"background": background,
"generation_config": generation_config,
"model_armor_config": model_armor_config,
"previous_interaction_id": previous_interaction_id,
"response_format": response_format,
"response_mime_type": response_mime_type,
Expand Down Expand Up @@ -770,6 +791,7 @@ async def create(
model: ModelParam,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -799,6 +821,8 @@ async def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -841,6 +865,7 @@ async def create(
stream: Literal[True],
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -871,6 +896,8 @@ async def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -917,6 +944,7 @@ async def create(
input: interaction_create_params.Input,
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -946,6 +974,8 @@ async def create(

background: Input only. Whether to run the model interaction in the background.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -995,6 +1025,7 @@ async def create(
stream: Literal[True],
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -1025,6 +1056,8 @@ async def create(

background: Input only. Whether to run the model interaction in the background.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -1065,6 +1098,7 @@ async def create(
stream: bool,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -1095,6 +1129,8 @@ async def create(

generation_config: Input only. Configuration parameters for the model interaction.

model_armor_config: Settings for prompt and response sanitization using the Model Armor service.

previous_interaction_id: The ID of the previous interaction, if any.

response_format: Enforces that the generated response is a JSON object that complies with the
Expand Down Expand Up @@ -1134,6 +1170,7 @@ async def create(
model: ModelParam | Omit = omit,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: ModelArmorConfigParam | Omit = omit,
previous_interaction_id: str | Omit = omit,
response_format: interaction_create_params.ResponseFormat | Omit = omit,
response_mime_type: str | Omit = omit,
Expand Down Expand Up @@ -1177,6 +1214,7 @@ async def create(
"model": model,
"background": background,
"generation_config": generation_config,
"model_armor_config": model_armor_config,
"previous_interaction_id": previous_interaction_id,
"response_format": response_format,
"response_mime_type": response_mime_type,
Expand Down
2 changes: 2 additions & 0 deletions google/genai/_interactions/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from .model_output_step import ModelOutputStep as ModelOutputStep
from .function_call_step import FunctionCallStep as FunctionCallStep
from .image_config_param import ImageConfigParam as ImageConfigParam
from .model_armor_config import ModelArmorConfig as ModelArmorConfig
from .text_content_param import TextContentParam as TextContentParam
from .thought_step_param import ThoughtStepParam as ThoughtStepParam
from .tool_choice_config import ToolChoiceConfig as ToolChoiceConfig
Expand Down Expand Up @@ -98,6 +99,7 @@
from .webhook_delete_response import WebhookDeleteResponse as WebhookDeleteResponse
from .code_execution_call_step import CodeExecutionCallStep as CodeExecutionCallStep
from .function_call_step_param import FunctionCallStepParam as FunctionCallStepParam
from .model_armor_config_param import ModelArmorConfigParam as ModelArmorConfigParam
from .tool_choice_config_param import ToolChoiceConfigParam as ToolChoiceConfigParam
from .google_search_result_step import GoogleSearchResultStep as GoogleSearchResultStep
from .interaction_create_params import InteractionCreateParams as InteractionCreateParams
Expand Down
6 changes: 6 additions & 0 deletions google/genai/_interactions/types/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from datetime import datetime
from typing_extensions import Literal, Annotated, TypeAlias

from pydantic import Field as FieldInfo

from .step import Step
from .tool import Tool
from .model import Model
Expand All @@ -32,6 +34,7 @@
from .video_content import VideoContent
from .webhook_config import WebhookConfig
from .document_content import DocumentContent
from .model_armor_config import ModelArmorConfig
from .dynamic_agent_config import DynamicAgentConfig
from .text_response_format import TextResponseFormat
from .audio_response_format import AudioResponseFormat
Expand Down Expand Up @@ -104,6 +107,9 @@ class Interaction(BaseModel):
model: Optional[Model] = None
"""The name of the `Model` used for generating the interaction."""

api_model_armor_config: Optional[ModelArmorConfig] = FieldInfo(alias="model_armor_config", default=None)
"""Settings for prompt and response sanitization using the Model Armor service."""

previous_interaction_id: Optional[str] = None
"""The ID of the previous interaction, if any."""

Expand Down
7 changes: 7 additions & 0 deletions google/genai/_interactions/types/interaction_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .webhook_config_param import WebhookConfigParam
from .document_content_param import DocumentContentParam
from .generation_config_param import GenerationConfigParam
from .model_armor_config_param import ModelArmorConfigParam
from .dynamic_agent_config_param import DynamicAgentConfigParam
from .text_response_format_param import TextResponseFormatParam
from .audio_response_format_param import AudioResponseFormatParam
Expand Down Expand Up @@ -67,6 +68,9 @@ class BaseCreateModelInteractionParams(TypedDict, total=False):
generation_config: GenerationConfigParam
"""Input only. Configuration parameters for the model interaction."""

model_armor_config: ModelArmorConfigParam
"""Settings for prompt and response sanitization using the Model Armor service."""

previous_interaction_id: str
"""The ID of the previous interaction, if any."""

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

model_armor_config: ModelArmorConfigParam
"""Settings for prompt and response sanitization using the Model Armor service."""

previous_interaction_id: str
"""The ID of the previous interaction, if any."""

Expand Down
58 changes: 58 additions & 0 deletions google/genai/_interactions/types/model_armor_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional

from pydantic import Field as FieldInfo

from .._models import BaseModel

__all__ = ["ModelArmorConfig"]


class ModelArmorConfig(BaseModel):
"""Configuration for Model Armor.

Model Armor is a Google Cloud service that provides safety and security
filtering for prompts and responses. It helps protect your AI applications
from risks such as harmful content, sensitive data leakage, and prompt
injection attacks.
"""

prompt_template_name: Optional[str] = FieldInfo(alias="promptTemplateName", default=None)
"""The resource name of the Model Armor template to use for prompt screening.

A Model Armor template is a set of customized filters and thresholds that define
how Model Armor screens content. If specified, Model Armor will use this
template to check the user's prompt for safety and security risks before it is
sent to the model.

The name must be in the format
`projects/{project}/locations/{location}/templates/{template}`.
"""

response_template_name: Optional[str] = FieldInfo(alias="responseTemplateName", default=None)
"""The resource name of the Model Armor template to use for response screening.

A Model Armor template is a set of customized filters and thresholds that define
how Model Armor screens content. If specified, Model Armor will use this
template to check the model's response for safety and security risks before it
is returned to the user.

The name must be in the format
`projects/{project}/locations/{location}/templates/{template}`.
"""
Loading
Loading