diff --git a/google/genai/_interactions/resources/interactions.py b/google/genai/_interactions/resources/interactions.py index 274c546c9..17cf54150 100644 --- a/google/genai/_interactions/resources/interactions.py +++ b/google/genai/_interactions/resources/interactions.py @@ -80,6 +80,7 @@ def create( input: interaction_create_params.Input, model: ModelParam, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -109,6 +110,12 @@ def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -155,6 +162,7 @@ def create( model: ModelParam, stream: Literal[True], background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -185,6 +193,12 @@ def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -391,6 +405,7 @@ def create( model: ModelParam, stream: bool, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -421,6 +436,12 @@ def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -464,6 +485,7 @@ def create( input: interaction_create_params.Input, model: ModelParam | Omit = omit, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -519,6 +541,7 @@ def create( "input": input, "model": model, "background": background, + "cached_content": cached_content, "environment": environment, "generation_config": generation_config, "previous_interaction_id": previous_interaction_id, @@ -820,6 +843,7 @@ async def create( input: interaction_create_params.Input, model: ModelParam, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -849,6 +873,12 @@ async def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -895,6 +925,7 @@ async def create( model: ModelParam, stream: Literal[True], background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -925,6 +956,12 @@ async def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -1131,6 +1168,7 @@ async def create( model: ModelParam, stream: bool, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -1161,6 +1199,12 @@ async def create( background: Input only. Whether to run the model interaction in the background. + cached_content: + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID. @@ -1204,6 +1248,7 @@ async def create( input: interaction_create_params.Input, model: ModelParam | Omit = omit, background: bool | Omit = omit, + cached_content: str | Omit = omit, environment: interaction_create_params.Environment | Omit = omit, generation_config: GenerationConfigParam | Omit = omit, previous_interaction_id: str | Omit = omit, @@ -1255,6 +1300,7 @@ async def create( "input": input, "model": model, "background": background, + "cached_content": cached_content, "environment": environment, "generation_config": generation_config, "previous_interaction_id": previous_interaction_id, diff --git a/google/genai/_interactions/types/generation_config.py b/google/genai/_interactions/types/generation_config.py index cf2b99c9a..27c4fd011 100644 --- a/google/genai/_interactions/types/generation_config.py +++ b/google/genai/_interactions/types/generation_config.py @@ -33,12 +33,26 @@ class GenerationConfig(BaseModel): """Configuration parameters for model interactions.""" + frequency_penalty: Optional[float] = None + """ + Penalizes tokens based on their frequency in the generated text. A positive + value helps to reduce the repetition of words and phrases. Valid values can + range from [-2.0, 2.0]. + """ + image_config: Optional[ImageConfig] = None """Configuration for image interaction.""" max_output_tokens: Optional[int] = None """The maximum number of tokens to include in the response.""" + presence_penalty: Optional[float] = None + """Penalizes tokens that have already appeared in the generated text. + + A positive value encourages the model to generate more diverse and less + repetitive text. Valid values can range from [-2.0, 2.0]. + """ + seed: Optional[int] = None """Seed used in decoding for reproducibility.""" diff --git a/google/genai/_interactions/types/generation_config_param.py b/google/genai/_interactions/types/generation_config_param.py index 286df7766..754b188d8 100644 --- a/google/genai/_interactions/types/generation_config_param.py +++ b/google/genai/_interactions/types/generation_config_param.py @@ -35,12 +35,26 @@ class GenerationConfigParam(TypedDict, total=False): """Configuration parameters for model interactions.""" + frequency_penalty: float + """ + Penalizes tokens based on their frequency in the generated text. A positive + value helps to reduce the repetition of words and phrases. Valid values can + range from [-2.0, 2.0]. + """ + image_config: ImageConfigParam """Configuration for image interaction.""" max_output_tokens: int """The maximum number of tokens to include in the response.""" + presence_penalty: float + """Penalizes tokens that have already appeared in the generated text. + + A positive value encourages the model to generate more diverse and less + repetitive text. Valid values can range from [-2.0, 2.0]. + """ + seed: int """Seed used in decoding for reproducibility.""" diff --git a/google/genai/_interactions/types/interaction.py b/google/genai/_interactions/types/interaction.py index 505d1f63a..a93f9cea3 100644 --- a/google/genai/_interactions/types/interaction.py +++ b/google/genai/_interactions/types/interaction.py @@ -104,6 +104,14 @@ class Interaction(BaseModel): agent_config: Optional[AgentConfig] = None """Configuration parameters for the agent interaction.""" + cached_content: Optional[str] = None + """ + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + """ + environment: Optional[Environment] = None """The environment configuration for the interaction. diff --git a/google/genai/_interactions/types/interaction_create_params.py b/google/genai/_interactions/types/interaction_create_params.py index 61a7761a5..61c2a74e7 100644 --- a/google/genai/_interactions/types/interaction_create_params.py +++ b/google/genai/_interactions/types/interaction_create_params.py @@ -65,6 +65,14 @@ class BaseCreateModelInteractionParams(TypedDict, total=False): background: bool """Input only. Whether to run the model interaction in the background.""" + cached_content: str + """ + The name of the cached content used as context to serve the prediction. Note: + only used in explicit caching, where users can have control over caching (e.g. + what content to cache) and enjoy guaranteed cost savings. Format: + `projects/{project}/locations/{location}/cachedContents/{cachedContent}` + """ + environment: Environment """The environment configuration for the interaction.