From d7ac1356ecdf99bef74cceeff9c97e39e0a2c43b Mon Sep 17 00:00:00 2001 From: adri22235 Date: Thu, 10 Sep 2026 22:15:35 +0200 Subject: [PATCH 1/2] fix(types): set optimal default top_p threshold for nucleus sampling --- google/genai/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/google/genai/types.py b/google/genai/types.py index 24d739ee8..7c93a0525 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -6472,7 +6472,7 @@ class GenerateContentConfig(_common.BaseModel): creative results. """, ) - top_p: Optional[float] = Field( + top_p: Optional[float] = Field(default=0.95, default=None, description="""Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less @@ -10913,7 +10913,7 @@ class Model(_common.BaseModel): description="""The maximum temperature value used for sampling set when the dataset was saved. This value is used to tune the degree of randomness.""", ) - top_p: Optional[float] = Field( + top_p: Optional[float] = Field(default=0.95, default=None, description="""Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is @@ -11503,7 +11503,7 @@ class GenerationConfig(_common.BaseModel): default=None, description="""Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words.""", ) - top_p: Optional[float] = Field( + top_p: Optional[float] = Field(default=0.95, default=None, description="""Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both.""", ) @@ -21581,7 +21581,7 @@ class LiveConnectConfig(_common.BaseModel): creative results. """, ) - top_p: Optional[float] = Field( + top_p: Optional[float] = Field(default=0.95, default=None, description="""Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less From 9d793f16f8ce59107de441b5c5f16bb6621473fc Mon Sep 17 00:00:00 2001 From: adri22235 Date: Fri, 11 Sep 2026 14:28:13 +0200 Subject: [PATCH 2/2] fix(types): resolve syntax error and duplicate default arguments in Field --- google/genai/types.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/google/genai/types.py b/google/genai/types.py index 7c93a0525..d07cc7e16 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -6472,8 +6472,8 @@ class GenerateContentConfig(_common.BaseModel): creative results. """, ) - top_p: Optional[float] = Field(default=0.95, - default=None, + top_p: Optional[float] = Field( + default=0.95, description="""Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses. @@ -10913,8 +10913,8 @@ class Model(_common.BaseModel): description="""The maximum temperature value used for sampling set when the dataset was saved. This value is used to tune the degree of randomness.""", ) - top_p: Optional[float] = Field(default=0.95, - default=None, + top_p: Optional[float] = Field( + default=0.95, description="""Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive @@ -11503,8 +11503,8 @@ class GenerationConfig(_common.BaseModel): default=None, description="""Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words.""", ) - top_p: Optional[float] = Field(default=0.95, - default=None, + top_p: Optional[float] = Field( + default=0.95, description="""Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both.""", ) enable_enhanced_civic_answers: Optional[bool] = Field( @@ -21581,8 +21581,8 @@ class LiveConnectConfig(_common.BaseModel): creative results. """, ) - top_p: Optional[float] = Field(default=0.95, - default=None, + top_p: Optional[float] = Field( + default=0.95, description="""Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.