diff --git a/google/genai/_interactions/resources/interactions.py b/google/genai/_interactions/resources/interactions.py index da7c5da85..12846a423 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. @@ -393,6 +407,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, @@ -423,6 +438,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. @@ -466,6 +487,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, @@ -526,6 +548,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, @@ -827,6 +850,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, @@ -856,6 +880,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. @@ -902,6 +932,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, @@ -932,6 +963,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. @@ -1140,6 +1177,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, @@ -1170,6 +1208,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. @@ -1213,6 +1257,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, @@ -1269,6 +1314,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 7ddcc175b..0bf86b21c 100644 --- a/google/genai/_interactions/types/interaction.py +++ b/google/genai/_interactions/types/interaction.py @@ -107,6 +107,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 d083773ff..8743b5bb4 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.