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
34 changes: 34 additions & 0 deletions google/genai/_interactions/resources/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def create(
model: ModelParam,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +104,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 +148,7 @@ def create(
stream: Literal[True],
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +179,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 +227,7 @@ def create(
input: interaction_create_params.Input,
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +257,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 +308,7 @@ def create(
stream: Literal[True],
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +339,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 +381,7 @@ def create(
stream: bool,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +412,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 +453,7 @@ def create(
model: ModelParam | Omit = omit,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +497,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 +787,7 @@ async def create(
model: ModelParam,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +817,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 +861,7 @@ async def create(
stream: Literal[True],
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +892,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 +940,7 @@ async def create(
input: interaction_create_params.Input,
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +970,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 +1021,7 @@ async def create(
stream: Literal[True],
agent_config: interaction_create_params.AgentConfig | Omit = omit,
background: bool | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +1052,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 +1094,7 @@ async def create(
stream: bool,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +1125,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 +1166,7 @@ async def create(
model: ModelParam | Omit = omit,
background: bool | Omit = omit,
generation_config: GenerationConfigParam | Omit = omit,
model_armor_config: interaction_create_params.ModelArmorConfig | 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 +1210,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
46 changes: 45 additions & 1 deletion 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 @@ -39,7 +41,14 @@
from .video_response_format import VideoResponseFormat
from .deep_research_agent_config import DeepResearchAgentConfig

__all__ = ["Interaction", "AgentConfig", "Input", "ResponseFormat", "ResponseFormatResponseFormatList"]
__all__ = [
"Interaction",
"AgentConfig",
"Input",
"ModelArmorConfig",
"ResponseFormat",
"ResponseFormatResponseFormatList",
]

AgentConfig: TypeAlias = Annotated[
Union[DynamicAgentConfig, DeepResearchAgentConfig], PropertyInfo(discriminator="type")
Expand All @@ -49,6 +58,38 @@
str, List[Step], List[Content], TextContent, ImageContent, AudioContent, DocumentContent, VideoContent
]


class ModelArmorConfig(BaseModel):
"""
Settings for prompt and response sanitization using the Model Armor
service.
"""

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}`.
"""


ResponseFormatResponseFormatList: TypeAlias = Union[
AudioResponseFormat, TextResponseFormat, ImageResponseFormat, VideoResponseFormat, object
]
Expand Down Expand Up @@ -104,6 +145,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
42 changes: 41 additions & 1 deletion google/genai/_interactions/types/interaction_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from __future__ import annotations

from typing import List, Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict

from .._utils import PropertyInfo
from .step_param import StepParam
from .tool_param import ToolParam
from .model_param import ModelParam
Expand All @@ -41,6 +42,7 @@
__all__ = [
"BaseCreateModelInteractionParams",
"Input",
"ModelArmorConfig",
"ResponseFormat",
"ResponseFormatResponseFormatList",
"BaseCreateAgentInteractionParams",
Expand All @@ -67,6 +69,9 @@ class BaseCreateModelInteractionParams(TypedDict, total=False):
generation_config: GenerationConfigParam
"""Input only. Configuration parameters for the model interaction."""

model_armor_config: ModelArmorConfig
"""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 @@ -113,6 +118,38 @@ class BaseCreateModelInteractionParams(TypedDict, total=False):
VideoContentParam,
]


class ModelArmorConfig(TypedDict, total=False):
"""
Settings for prompt and response sanitization using the Model Armor
service.
"""

prompt_template_name: Annotated[str, PropertyInfo(alias="promptTemplateName")]
"""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: Annotated[str, PropertyInfo(alias="responseTemplateName")]
"""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}`.
"""


ResponseFormatResponseFormatList: TypeAlias = Union[
AudioResponseFormatParam, TextResponseFormatParam, ImageResponseFormatParam, VideoResponseFormatParam, object
]
Expand Down Expand Up @@ -151,6 +188,9 @@ class BaseCreateAgentInteractionParams(TypedDict, total=False):
background: bool
"""Input only. Whether to run the model interaction in the background."""

model_armor_config: ModelArmorConfig
"""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
Loading