google-genai 1.9.0__py3-none-any.whl → 1.11.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
google/genai/types.py CHANGED
@@ -128,14 +128,6 @@ class Mode(_common.CaseInSensitiveEnum):
128
128
  MODE_DYNAMIC = 'MODE_DYNAMIC'
129
129
 
130
130
 
131
- class State(_common.CaseInSensitiveEnum):
132
- """Output only. RagFile state."""
133
-
134
- STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
135
- ACTIVE = 'ACTIVE'
136
- ERROR = 'ERROR'
137
-
138
-
139
131
  class FinishReason(_common.CaseInSensitiveEnum):
140
132
  """Output only. The reason why the model stopped generating tokens.
141
133
 
@@ -185,6 +177,18 @@ class BlockedReason(_common.CaseInSensitiveEnum):
185
177
  PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
186
178
 
187
179
 
180
+ class TrafficType(_common.CaseInSensitiveEnum):
181
+ """Output only.
182
+
183
+ Traffic type. This shows whether a request consumes Pay-As-You-Go or
184
+ Provisioned Throughput quota.
185
+ """
186
+
187
+ TRAFFIC_TYPE_UNSPECIFIED = 'TRAFFIC_TYPE_UNSPECIFIED'
188
+ ON_DEMAND = 'ON_DEMAND'
189
+ PROVISIONED_THROUGHPUT = 'PROVISIONED_THROUGHPUT'
190
+
191
+
188
192
  class Modality(_common.CaseInSensitiveEnum):
189
193
  """Server content modalities."""
190
194
 
@@ -194,15 +198,13 @@ class Modality(_common.CaseInSensitiveEnum):
194
198
  AUDIO = 'AUDIO'
195
199
 
196
200
 
197
- class DeploymentResourcesType(_common.CaseInSensitiveEnum):
198
- """"""
201
+ class MediaResolution(_common.CaseInSensitiveEnum):
202
+ """The media resolution to use."""
199
203
 
200
- DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED = (
201
- 'DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED'
202
- )
203
- DEDICATED_RESOURCES = 'DEDICATED_RESOURCES'
204
- AUTOMATIC_RESOURCES = 'AUTOMATIC_RESOURCES'
205
- SHARED_RESOURCES = 'SHARED_RESOURCES'
204
+ MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'
205
+ MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'
206
+ MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'
207
+ MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'
206
208
 
207
209
 
208
210
  class JobState(_common.CaseInSensitiveEnum):
@@ -227,12 +229,24 @@ class AdapterSize(_common.CaseInSensitiveEnum):
227
229
 
228
230
  ADAPTER_SIZE_UNSPECIFIED = 'ADAPTER_SIZE_UNSPECIFIED'
229
231
  ADAPTER_SIZE_ONE = 'ADAPTER_SIZE_ONE'
232
+ ADAPTER_SIZE_TWO = 'ADAPTER_SIZE_TWO'
230
233
  ADAPTER_SIZE_FOUR = 'ADAPTER_SIZE_FOUR'
231
234
  ADAPTER_SIZE_EIGHT = 'ADAPTER_SIZE_EIGHT'
232
235
  ADAPTER_SIZE_SIXTEEN = 'ADAPTER_SIZE_SIXTEEN'
233
236
  ADAPTER_SIZE_THIRTY_TWO = 'ADAPTER_SIZE_THIRTY_TWO'
234
237
 
235
238
 
239
+ class FeatureSelectionPreference(_common.CaseInSensitiveEnum):
240
+ """Options for feature selection preference."""
241
+
242
+ FEATURE_SELECTION_PREFERENCE_UNSPECIFIED = (
243
+ 'FEATURE_SELECTION_PREFERENCE_UNSPECIFIED'
244
+ )
245
+ PRIORITIZE_QUALITY = 'PRIORITIZE_QUALITY'
246
+ BALANCED = 'BALANCED'
247
+ PRIORITIZE_COST = 'PRIORITIZE_COST'
248
+
249
+
236
250
  class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
237
251
  """Config for the dynamic retrieval config mode."""
238
252
 
@@ -249,15 +263,6 @@ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
249
263
  NONE = 'NONE'
250
264
 
251
265
 
252
- class MediaResolution(_common.CaseInSensitiveEnum):
253
- """The media resolution to use."""
254
-
255
- MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'
256
- MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'
257
- MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'
258
- MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'
259
-
260
-
261
266
  class SafetyFilterLevel(_common.CaseInSensitiveEnum):
262
267
  """Enum that controls the safety filter level for objectionable content."""
263
268
 
@@ -354,6 +359,38 @@ class MediaModality(_common.CaseInSensitiveEnum):
354
359
  DOCUMENT = 'DOCUMENT'
355
360
 
356
361
 
362
+ class StartSensitivity(_common.CaseInSensitiveEnum):
363
+ """Start of speech sensitivity."""
364
+
365
+ START_SENSITIVITY_UNSPECIFIED = 'START_SENSITIVITY_UNSPECIFIED'
366
+ START_SENSITIVITY_HIGH = 'START_SENSITIVITY_HIGH'
367
+ START_SENSITIVITY_LOW = 'START_SENSITIVITY_LOW'
368
+
369
+
370
+ class EndSensitivity(_common.CaseInSensitiveEnum):
371
+ """End of speech sensitivity."""
372
+
373
+ END_SENSITIVITY_UNSPECIFIED = 'END_SENSITIVITY_UNSPECIFIED'
374
+ END_SENSITIVITY_HIGH = 'END_SENSITIVITY_HIGH'
375
+ END_SENSITIVITY_LOW = 'END_SENSITIVITY_LOW'
376
+
377
+
378
+ class ActivityHandling(_common.CaseInSensitiveEnum):
379
+ """The different ways of handling user activity."""
380
+
381
+ ACTIVITY_HANDLING_UNSPECIFIED = 'ACTIVITY_HANDLING_UNSPECIFIED'
382
+ START_OF_ACTIVITY_INTERRUPTS = 'START_OF_ACTIVITY_INTERRUPTS'
383
+ NO_INTERRUPTION = 'NO_INTERRUPTION'
384
+
385
+
386
+ class TurnCoverage(_common.CaseInSensitiveEnum):
387
+ """Options about which input is included in the user's turn."""
388
+
389
+ TURN_COVERAGE_UNSPECIFIED = 'TURN_COVERAGE_UNSPECIFIED'
390
+ TURN_INCLUDES_ONLY_ACTIVITY = 'TURN_INCLUDES_ONLY_ACTIVITY'
391
+ TURN_INCLUDES_ALL_INPUT = 'TURN_INCLUDES_ALL_INPUT'
392
+
393
+
357
394
  class VideoMetadata(_common.BaseModel):
358
395
  """Metadata describes the input video content."""
359
396
 
@@ -632,18 +669,6 @@ class Part(_common.BaseModel):
632
669
  function_response = FunctionResponse(name=name, response=response)
633
670
  return cls(function_response=function_response)
634
671
 
635
- @classmethod
636
- def from_video_metadata(cls, *, start_offset: str, end_offset: str) -> 'Part':
637
- logger.warning("""Part.from_video_metadata will be deprecated soon.
638
- Because a Part instance needs to include at least one of the fields:
639
- text, file_data, inline_data, function_call, function_response, executable_code or code_execution_result.
640
- A Part instance contains only video_metadata is not a valid Part.
641
- """)
642
- video_metadata = VideoMetadata(
643
- end_offset=end_offset, start_offset=start_offset
644
- )
645
- return cls(video_metadata=video_metadata)
646
-
647
672
  @classmethod
648
673
  def from_executable_code(cls, *, code: str, language: Language) -> 'Part':
649
674
  executable_code = ExecutableCode(code=code, language=language)
@@ -806,6 +831,12 @@ class HttpOptions(_common.BaseModel):
806
831
  timeout: Optional[int] = Field(
807
832
  default=None, description="""Timeout for the request in milliseconds."""
808
833
  )
834
+ client_args: Optional[dict[str, Any]] = Field(
835
+ default=None, description="""Args passed to the HTTP client."""
836
+ )
837
+ async_client_args: Optional[dict[str, Any]] = Field(
838
+ default=None, description="""Args passed to the async HTTP client."""
839
+ )
809
840
 
810
841
 
811
842
  class HttpOptionsDict(TypedDict, total=False):
@@ -823,10 +854,173 @@ class HttpOptionsDict(TypedDict, total=False):
823
854
  timeout: Optional[int]
824
855
  """Timeout for the request in milliseconds."""
825
856
 
857
+ client_args: Optional[dict[str, Any]]
858
+ """Args passed to the HTTP client."""
859
+
860
+ async_client_args: Optional[dict[str, Any]]
861
+ """Args passed to the async HTTP client."""
862
+
826
863
 
827
864
  HttpOptionsOrDict = Union[HttpOptions, HttpOptionsDict]
828
865
 
829
866
 
867
+ class JSONSchemaType(Enum):
868
+ """The type of the data supported by JSON Schema.
869
+
870
+ The values of the enums are lower case strings, while the values of the enums
871
+ for the Type class are upper case strings.
872
+ """
873
+
874
+ NULL = 'null'
875
+ BOOLEAN = 'boolean'
876
+ OBJECT = 'object'
877
+ ARRAY = 'array'
878
+ NUMBER = 'number'
879
+ INTEGER = 'integer'
880
+ STRING = 'string'
881
+
882
+
883
+ class JSONSchema(pydantic.BaseModel):
884
+ """A subset of JSON Schema according to 2020-12 JSON Schema draft.
885
+
886
+ Represents a subset of a JSON Schema object that is used by the Gemini model.
887
+ The difference between this class and the Schema class is that this class is
888
+ compatible with OpenAPI 3.1 schema objects. And the Schema class is used to
889
+ make API call to Gemini model.
890
+ """
891
+
892
+ type: Optional[Union[JSONSchemaType, list[JSONSchemaType]]] = Field(
893
+ default=None,
894
+ description="""Validation succeeds if the type of the instance matches the type represented by the given type, or matches at least one of the given types.""",
895
+ )
896
+ format: Optional[str] = Field(
897
+ default=None,
898
+ description='Define semantic information about a string instance.',
899
+ )
900
+ title: Optional[str] = Field(
901
+ default=None,
902
+ description=(
903
+ 'A preferably short description about the purpose of the instance'
904
+ ' described by the schema.'
905
+ ),
906
+ )
907
+ description: Optional[str] = Field(
908
+ default=None,
909
+ description=(
910
+ 'An explanation about the purpose of the instance described by the'
911
+ ' schema.'
912
+ ),
913
+ )
914
+ default: Optional[Any] = Field(
915
+ default=None,
916
+ description=(
917
+ 'This keyword can be used to supply a default JSON value associated'
918
+ ' with a particular schema.'
919
+ ),
920
+ )
921
+ items: Optional['JSONSchema'] = Field(
922
+ default=None,
923
+ description=(
924
+ 'Validation succeeds if each element of the instance not covered by'
925
+ ' prefixItems validates against this schema.'
926
+ ),
927
+ )
928
+ min_items: Optional[int] = Field(
929
+ default=None,
930
+ description=(
931
+ 'An array instance is valid if its size is greater than, or equal to,'
932
+ ' the value of this keyword.'
933
+ ),
934
+ )
935
+ max_items: Optional[int] = Field(
936
+ default=None,
937
+ description=(
938
+ 'An array instance is valid if its size is less than, or equal to,'
939
+ ' the value of this keyword.'
940
+ ),
941
+ )
942
+ enum: Optional[list[Any]] = Field(
943
+ default=None,
944
+ description=(
945
+ 'Validation succeeds if the instance is equal to one of the elements'
946
+ ' in this keyword’s array value.'
947
+ ),
948
+ )
949
+ properties: Optional[dict[str, 'JSONSchema']] = Field(
950
+ default=None,
951
+ description=(
952
+ 'Validation succeeds if, for each name that appears in both the'
953
+ ' instance and as a name within this keyword’s value, the child'
954
+ ' instance for that name successfully validates against the'
955
+ ' corresponding schema.'
956
+ ),
957
+ )
958
+ required: Optional[list[str]] = Field(
959
+ default=None,
960
+ description=(
961
+ 'An object instance is valid against this keyword if every item in'
962
+ ' the array is the name of a property in the instance.'
963
+ ),
964
+ )
965
+ min_properties: Optional[int] = Field(
966
+ default=None,
967
+ description=(
968
+ 'An object instance is valid if its number of properties is greater'
969
+ ' than, or equal to, the value of this keyword.'
970
+ ),
971
+ )
972
+ max_properties: Optional[int] = Field(
973
+ default=None,
974
+ description=(
975
+ 'An object instance is valid if its number of properties is less'
976
+ ' than, or equal to, the value of this keyword.'
977
+ ),
978
+ )
979
+ minimum: Optional[float] = Field(
980
+ default=None,
981
+ description=(
982
+ 'Validation succeeds if the numeric instance is greater than or equal'
983
+ ' to the given number.'
984
+ ),
985
+ )
986
+ maximum: Optional[float] = Field(
987
+ default=None,
988
+ description=(
989
+ 'Validation succeeds if the numeric instance is less than or equal to'
990
+ ' the given number.'
991
+ ),
992
+ )
993
+ min_length: Optional[int] = Field(
994
+ default=None,
995
+ description=(
996
+ 'A string instance is valid against this keyword if its length is'
997
+ ' greater than, or equal to, the value of this keyword.'
998
+ ),
999
+ )
1000
+ max_length: Optional[int] = Field(
1001
+ default=None,
1002
+ description=(
1003
+ 'A string instance is valid against this keyword if its length is'
1004
+ ' less than, or equal to, the value of this keyword.'
1005
+ ),
1006
+ )
1007
+ pattern: Optional[str] = Field(
1008
+ default=None,
1009
+ description=(
1010
+ 'A string instance is considered valid if the regular expression'
1011
+ ' matches the instance successfully.'
1012
+ ),
1013
+ )
1014
+ any_of: Optional[list['JSONSchema']] = Field(
1015
+ default=None,
1016
+ description=(
1017
+ 'An instance validates successfully against this keyword if it'
1018
+ ' validates successfully against at least one schema defined by this'
1019
+ ' keyword’s value.'
1020
+ ),
1021
+ )
1022
+
1023
+
830
1024
  class Schema(_common.BaseModel):
831
1025
  """Schema that defines the format of input and output data.
832
1026
 
@@ -918,6 +1112,66 @@ class Schema(_common.BaseModel):
918
1112
  default=None, description="""Optional. The type of the data."""
919
1113
  )
920
1114
 
1115
+ @property
1116
+ def json_schema(self) -> JSONSchema:
1117
+ """Converts the Schema object to a JSONSchema object, that is compatible with 2020-12 JSON Schema draft.
1118
+
1119
+ If a Schema field is not supported by JSONSchema, it will be ignored.
1120
+ """
1121
+ json_schema_field_names: set[str] = set(JSONSchema.model_fields.keys())
1122
+ schema_field_names: tuple[str] = (
1123
+ 'items',
1124
+ ) # 'additional_properties' to come
1125
+ list_schema_field_names: tuple[str] = (
1126
+ 'any_of', # 'one_of', 'all_of', 'not' to come
1127
+ )
1128
+ dict_schema_field_names: tuple[str] = ('properties',) # 'defs' to come
1129
+
1130
+ def convert_schema(schema: Union['Schema', dict[str, Any]]) -> JSONSchema:
1131
+ if isinstance(schema, pydantic.BaseModel):
1132
+ schema_dict = schema.model_dump()
1133
+ else:
1134
+ schema_dict = schema
1135
+ json_schema = JSONSchema()
1136
+ for field_name, field_value in schema_dict.items():
1137
+ if field_value is None:
1138
+ continue
1139
+ elif field_name == 'nullable':
1140
+ json_schema.type = JSONSchemaType.NULL
1141
+ elif field_name not in json_schema_field_names:
1142
+ continue
1143
+ elif field_name == 'type':
1144
+ if field_value == Type.TYPE_UNSPECIFIED:
1145
+ continue
1146
+ json_schema_type = JSONSchemaType(field_value.lower())
1147
+ if json_schema.type is None:
1148
+ json_schema.type = json_schema_type
1149
+ elif isinstance(json_schema.type, JSONSchemaType):
1150
+ existing_type: JSONSchemaType = json_schema.type
1151
+ json_schema.type = [existing_type, json_schema_type]
1152
+ elif isinstance(json_schema.type, list):
1153
+ json_schema.type.append(json_schema_type)
1154
+ elif field_name in schema_field_names:
1155
+ schema_field_value: 'JSONSchema' = convert_schema(field_value)
1156
+ setattr(json_schema, field_name, schema_field_value)
1157
+ elif field_name in list_schema_field_names:
1158
+ list_schema_field_value: list['JSONSchema'] = [
1159
+ convert_schema(this_field_value)
1160
+ for this_field_value in field_value
1161
+ ]
1162
+ setattr(json_schema, field_name, list_schema_field_value)
1163
+ elif field_name in dict_schema_field_names:
1164
+ dict_schema_field_value: dict[str, 'JSONSchema'] = {
1165
+ key: convert_schema(value) for key, value in field_value.items()
1166
+ }
1167
+ setattr(json_schema, field_name, dict_schema_field_value)
1168
+ else:
1169
+ setattr(json_schema, field_name, field_value)
1170
+
1171
+ return json_schema
1172
+
1173
+ return convert_schema(self)
1174
+
921
1175
 
922
1176
  class SchemaDict(TypedDict, total=False):
923
1177
  """Schema that defines the format of input and output data.
@@ -995,6 +1249,26 @@ class SchemaDict(TypedDict, total=False):
995
1249
  SchemaOrDict = Union[Schema, SchemaDict]
996
1250
 
997
1251
 
1252
+ class ModelSelectionConfig(_common.BaseModel):
1253
+ """Config for model selection."""
1254
+
1255
+ feature_selection_preference: Optional[FeatureSelectionPreference] = Field(
1256
+ default=None, description="""Options for feature selection preference."""
1257
+ )
1258
+
1259
+
1260
+ class ModelSelectionConfigDict(TypedDict, total=False):
1261
+ """Config for model selection."""
1262
+
1263
+ feature_selection_preference: Optional[FeatureSelectionPreference]
1264
+ """Options for feature selection preference."""
1265
+
1266
+
1267
+ ModelSelectionConfigOrDict = Union[
1268
+ ModelSelectionConfig, ModelSelectionConfigDict
1269
+ ]
1270
+
1271
+
998
1272
  class SafetySetting(_common.BaseModel):
999
1273
  """Safety settings."""
1000
1274
 
@@ -1287,6 +1561,168 @@ VertexRagStoreRagResourceOrDict = Union[
1287
1561
  ]
1288
1562
 
1289
1563
 
1564
+ class RagRetrievalConfigFilter(_common.BaseModel):
1565
+ """Config for filters."""
1566
+
1567
+ metadata_filter: Optional[str] = Field(
1568
+ default=None, description="""Optional. String for metadata filtering."""
1569
+ )
1570
+ vector_distance_threshold: Optional[float] = Field(
1571
+ default=None,
1572
+ description="""Optional. Only returns contexts with vector distance smaller than the threshold.""",
1573
+ )
1574
+ vector_similarity_threshold: Optional[float] = Field(
1575
+ default=None,
1576
+ description="""Optional. Only returns contexts with vector similarity larger than the threshold.""",
1577
+ )
1578
+
1579
+
1580
+ class RagRetrievalConfigFilterDict(TypedDict, total=False):
1581
+ """Config for filters."""
1582
+
1583
+ metadata_filter: Optional[str]
1584
+ """Optional. String for metadata filtering."""
1585
+
1586
+ vector_distance_threshold: Optional[float]
1587
+ """Optional. Only returns contexts with vector distance smaller than the threshold."""
1588
+
1589
+ vector_similarity_threshold: Optional[float]
1590
+ """Optional. Only returns contexts with vector similarity larger than the threshold."""
1591
+
1592
+
1593
+ RagRetrievalConfigFilterOrDict = Union[
1594
+ RagRetrievalConfigFilter, RagRetrievalConfigFilterDict
1595
+ ]
1596
+
1597
+
1598
+ class RagRetrievalConfigHybridSearch(_common.BaseModel):
1599
+ """Config for Hybrid Search."""
1600
+
1601
+ alpha: Optional[float] = Field(
1602
+ default=None,
1603
+ description="""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally.""",
1604
+ )
1605
+
1606
+
1607
+ class RagRetrievalConfigHybridSearchDict(TypedDict, total=False):
1608
+ """Config for Hybrid Search."""
1609
+
1610
+ alpha: Optional[float]
1611
+ """Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally."""
1612
+
1613
+
1614
+ RagRetrievalConfigHybridSearchOrDict = Union[
1615
+ RagRetrievalConfigHybridSearch, RagRetrievalConfigHybridSearchDict
1616
+ ]
1617
+
1618
+
1619
+ class RagRetrievalConfigRankingLlmRanker(_common.BaseModel):
1620
+ """Config for LlmRanker."""
1621
+
1622
+ model_name: Optional[str] = Field(
1623
+ default=None,
1624
+ description="""Optional. The model name used for ranking. Format: `gemini-1.5-pro`""",
1625
+ )
1626
+
1627
+
1628
+ class RagRetrievalConfigRankingLlmRankerDict(TypedDict, total=False):
1629
+ """Config for LlmRanker."""
1630
+
1631
+ model_name: Optional[str]
1632
+ """Optional. The model name used for ranking. Format: `gemini-1.5-pro`"""
1633
+
1634
+
1635
+ RagRetrievalConfigRankingLlmRankerOrDict = Union[
1636
+ RagRetrievalConfigRankingLlmRanker, RagRetrievalConfigRankingLlmRankerDict
1637
+ ]
1638
+
1639
+
1640
+ class RagRetrievalConfigRankingRankService(_common.BaseModel):
1641
+ """Config for Rank Service."""
1642
+
1643
+ model_name: Optional[str] = Field(
1644
+ default=None,
1645
+ description="""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`""",
1646
+ )
1647
+
1648
+
1649
+ class RagRetrievalConfigRankingRankServiceDict(TypedDict, total=False):
1650
+ """Config for Rank Service."""
1651
+
1652
+ model_name: Optional[str]
1653
+ """Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`"""
1654
+
1655
+
1656
+ RagRetrievalConfigRankingRankServiceOrDict = Union[
1657
+ RagRetrievalConfigRankingRankService,
1658
+ RagRetrievalConfigRankingRankServiceDict,
1659
+ ]
1660
+
1661
+
1662
+ class RagRetrievalConfigRanking(_common.BaseModel):
1663
+ """Config for ranking and reranking."""
1664
+
1665
+ llm_ranker: Optional[RagRetrievalConfigRankingLlmRanker] = Field(
1666
+ default=None, description="""Optional. Config for LlmRanker."""
1667
+ )
1668
+ rank_service: Optional[RagRetrievalConfigRankingRankService] = Field(
1669
+ default=None, description="""Optional. Config for Rank Service."""
1670
+ )
1671
+
1672
+
1673
+ class RagRetrievalConfigRankingDict(TypedDict, total=False):
1674
+ """Config for ranking and reranking."""
1675
+
1676
+ llm_ranker: Optional[RagRetrievalConfigRankingLlmRankerDict]
1677
+ """Optional. Config for LlmRanker."""
1678
+
1679
+ rank_service: Optional[RagRetrievalConfigRankingRankServiceDict]
1680
+ """Optional. Config for Rank Service."""
1681
+
1682
+
1683
+ RagRetrievalConfigRankingOrDict = Union[
1684
+ RagRetrievalConfigRanking, RagRetrievalConfigRankingDict
1685
+ ]
1686
+
1687
+
1688
+ class RagRetrievalConfig(_common.BaseModel):
1689
+ """Specifies the context retrieval config."""
1690
+
1691
+ filter: Optional[RagRetrievalConfigFilter] = Field(
1692
+ default=None, description="""Optional. Config for filters."""
1693
+ )
1694
+ hybrid_search: Optional[RagRetrievalConfigHybridSearch] = Field(
1695
+ default=None, description="""Optional. Config for Hybrid Search."""
1696
+ )
1697
+ ranking: Optional[RagRetrievalConfigRanking] = Field(
1698
+ default=None,
1699
+ description="""Optional. Config for ranking and reranking.""",
1700
+ )
1701
+ top_k: Optional[int] = Field(
1702
+ default=None,
1703
+ description="""Optional. The number of contexts to retrieve.""",
1704
+ )
1705
+
1706
+
1707
+ class RagRetrievalConfigDict(TypedDict, total=False):
1708
+ """Specifies the context retrieval config."""
1709
+
1710
+ filter: Optional[RagRetrievalConfigFilterDict]
1711
+ """Optional. Config for filters."""
1712
+
1713
+ hybrid_search: Optional[RagRetrievalConfigHybridSearchDict]
1714
+ """Optional. Config for Hybrid Search."""
1715
+
1716
+ ranking: Optional[RagRetrievalConfigRankingDict]
1717
+ """Optional. Config for ranking and reranking."""
1718
+
1719
+ top_k: Optional[int]
1720
+ """Optional. The number of contexts to retrieve."""
1721
+
1722
+
1723
+ RagRetrievalConfigOrDict = Union[RagRetrievalConfig, RagRetrievalConfigDict]
1724
+
1725
+
1290
1726
  class VertexRagStore(_common.BaseModel):
1291
1727
  """Retrieve from Vertex RAG Store for grounding."""
1292
1728
 
@@ -1298,6 +1734,10 @@ class VertexRagStore(_common.BaseModel):
1298
1734
  default=None,
1299
1735
  description="""Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.""",
1300
1736
  )
1737
+ rag_retrieval_config: Optional[RagRetrievalConfig] = Field(
1738
+ default=None,
1739
+ description="""Optional. The retrieval config for the Rag query.""",
1740
+ )
1301
1741
  similarity_top_k: Optional[int] = Field(
1302
1742
  default=None,
1303
1743
  description="""Optional. Number of top k results to return from the selected corpora.""",
@@ -1317,6 +1757,9 @@ class VertexRagStoreDict(TypedDict, total=False):
1317
1757
  rag_resources: Optional[list[VertexRagStoreRagResourceDict]]
1318
1758
  """Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support."""
1319
1759
 
1760
+ rag_retrieval_config: Optional[RagRetrievalConfigDict]
1761
+ """Optional. The retrieval config for the Rag query."""
1762
+
1320
1763
  similarity_top_k: Optional[int]
1321
1764
  """Optional. Number of top k results to return from the selected corpora."""
1322
1765
 
@@ -1433,6 +1876,11 @@ ToolOrDict = Union[Tool, ToolDict]
1433
1876
  ToolListUnion = list[Union[Tool, Callable]]
1434
1877
  ToolListUnionDict = list[Union[ToolDict, Callable]]
1435
1878
 
1879
+ SchemaUnion = Union[
1880
+ dict, type, Schema, builtin_types.GenericAlias, VersionedUnionType # type: ignore[valid-type]
1881
+ ]
1882
+ SchemaUnionDict = Union[SchemaUnion, SchemaDict]
1883
+
1436
1884
 
1437
1885
  class FunctionCallingConfig(_common.BaseModel):
1438
1886
  """Function calling config."""
@@ -1535,6 +1983,12 @@ class SpeechConfig(_common.BaseModel):
1535
1983
  description="""The configuration for the speaker to use.
1536
1984
  """,
1537
1985
  )
1986
+ language_code: Optional[str] = Field(
1987
+ default=None,
1988
+ description="""Language code (ISO 639. e.g. en-US) for the speech synthesization.
1989
+ Only available for Live API.
1990
+ """,
1991
+ )
1538
1992
 
1539
1993
 
1540
1994
  class SpeechConfigDict(TypedDict, total=False):
@@ -1544,6 +1998,11 @@ class SpeechConfigDict(TypedDict, total=False):
1544
1998
  """The configuration for the speaker to use.
1545
1999
  """
1546
2000
 
2001
+ language_code: Optional[str]
2002
+ """Language code (ISO 639. e.g. en-US) for the speech synthesization.
2003
+ Only available for Live API.
2004
+ """
2005
+
1547
2006
 
1548
2007
  SpeechConfigOrDict = Union[SpeechConfig, SpeechConfigDict]
1549
2008
 
@@ -1615,6 +2074,11 @@ class ThinkingConfig(_common.BaseModel):
1615
2074
  description="""Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
1616
2075
  """,
1617
2076
  )
2077
+ thinking_budget: Optional[int] = Field(
2078
+ default=None,
2079
+ description="""Indicates the thinking budget in tokens.
2080
+ """,
2081
+ )
1618
2082
 
1619
2083
 
1620
2084
  class ThinkingConfigDict(TypedDict, total=False):
@@ -1624,6 +2088,10 @@ class ThinkingConfigDict(TypedDict, total=False):
1624
2088
  """Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
1625
2089
  """
1626
2090
 
2091
+ thinking_budget: Optional[int]
2092
+ """Indicates the thinking budget in tokens.
2093
+ """
2094
+
1627
2095
 
1628
2096
  ThinkingConfigOrDict = Union[ThinkingConfig, ThinkingConfigDict]
1629
2097
 
@@ -1778,14 +2246,6 @@ ContentUnion = Union[Content, list[PartUnion], PartUnion]
1778
2246
  ContentUnionDict = Union[ContentUnion, ContentDict]
1779
2247
 
1780
2248
 
1781
- SchemaUnion = Union[
1782
- dict, type, Schema, builtin_types.GenericAlias, VersionedUnionType
1783
- ]
1784
-
1785
-
1786
- SchemaUnionDict = Union[SchemaUnion, SchemaDict]
1787
-
1788
-
1789
2249
  class GenerationConfigRoutingConfigAutoRoutingMode(_common.BaseModel):
1790
2250
  """When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference."""
1791
2251
 
@@ -1970,6 +2430,11 @@ class GenerateContentConfig(_common.BaseModel):
1970
2430
  description="""Configuration for model router requests.
1971
2431
  """,
1972
2432
  )
2433
+ model_selection_config: Optional[ModelSelectionConfig] = Field(
2434
+ default=None,
2435
+ description="""Configuration for model selection.
2436
+ """,
2437
+ )
1973
2438
  safety_settings: Optional[list[SafetySetting]] = Field(
1974
2439
  default=None,
1975
2440
  description="""Safety settings in the request to block unsafe content in the
@@ -2135,6 +2600,10 @@ class GenerateContentConfigDict(TypedDict, total=False):
2135
2600
  """Configuration for model router requests.
2136
2601
  """
2137
2602
 
2603
+ model_selection_config: Optional[ModelSelectionConfigDict]
2604
+ """Configuration for model selection.
2605
+ """
2606
+
2138
2607
  safety_settings: Optional[list[SafetySettingDict]]
2139
2608
  """Safety settings in the request to block unsafe content in the
2140
2609
  response.
@@ -2397,6 +2866,9 @@ GroundingChunkRetrievedContextOrDict = Union[
2397
2866
  class GroundingChunkWeb(_common.BaseModel):
2398
2867
  """Chunk from the web."""
2399
2868
 
2869
+ domain: Optional[str] = Field(
2870
+ default=None, description="""Domain of the (original) URI."""
2871
+ )
2400
2872
  title: Optional[str] = Field(
2401
2873
  default=None, description="""Title of the chunk."""
2402
2874
  )
@@ -2408,6 +2880,9 @@ class GroundingChunkWeb(_common.BaseModel):
2408
2880
  class GroundingChunkWebDict(TypedDict, total=False):
2409
2881
  """Chunk from the web."""
2410
2882
 
2883
+ domain: Optional[str]
2884
+ """Domain of the (original) URI."""
2885
+
2411
2886
  title: Optional[str]
2412
2887
  """Title of the chunk."""
2413
2888
 
@@ -2936,6 +3411,10 @@ class GenerateContentResponseUsageMetadata(_common.BaseModel):
2936
3411
  default=None,
2937
3412
  description="""Total token count for prompt, response candidates, and tool-use prompts (if present).""",
2938
3413
  )
3414
+ traffic_type: Optional[TrafficType] = Field(
3415
+ default=None,
3416
+ description="""Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota.""",
3417
+ )
2939
3418
 
2940
3419
 
2941
3420
  class GenerateContentResponseUsageMetadataDict(TypedDict, total=False):
@@ -2971,6 +3450,9 @@ class GenerateContentResponseUsageMetadataDict(TypedDict, total=False):
2971
3450
  total_token_count: Optional[int]
2972
3451
  """Total token count for prompt, response candidates, and tool-use prompts (if present)."""
2973
3452
 
3453
+ traffic_type: Optional[TrafficType]
3454
+ """Output only. Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput quota."""
3455
+
2974
3456
 
2975
3457
  GenerateContentResponseUsageMetadataOrDict = Union[
2976
3458
  GenerateContentResponseUsageMetadata,
@@ -4878,6 +5360,10 @@ class GenerationConfig(_common.BaseModel):
4878
5360
  default=None,
4879
5361
  description="""Optional. The maximum number of output tokens to generate per message.""",
4880
5362
  )
5363
+ media_resolution: Optional[MediaResolution] = Field(
5364
+ default=None,
5365
+ description="""Optional. If specified, the media resolution specified will be used.""",
5366
+ )
4881
5367
  presence_penalty: Optional[float] = Field(
4882
5368
  default=None, description="""Optional. Positive penalties."""
4883
5369
  )
@@ -4932,6 +5418,9 @@ class GenerationConfigDict(TypedDict, total=False):
4932
5418
  max_output_tokens: Optional[int]
4933
5419
  """Optional. The maximum number of output tokens to generate per message."""
4934
5420
 
5421
+ media_resolution: Optional[MediaResolution]
5422
+ """Optional. If specified, the media resolution specified will be used."""
5423
+
4935
5424
  presence_penalty: Optional[float]
4936
5425
  """Optional. Positive penalties."""
4937
5426
 
@@ -5471,9 +5960,8 @@ class GenerateVideosOperation(_common.BaseModel):
5471
5960
  default=None,
5472
5961
  description="""The error result of the operation in case of failure or cancellation.""",
5473
5962
  )
5474
- response: Optional[dict[str, Any]] = Field(
5475
- default=None,
5476
- description="""The normal response of the operation in case of success.""",
5963
+ response: Optional[GenerateVideosResponse] = Field(
5964
+ default=None, description="""The generated videos."""
5477
5965
  )
5478
5966
  result: Optional[GenerateVideosResponse] = Field(
5479
5967
  default=None, description="""The generated videos."""
@@ -5495,8 +5983,8 @@ class GenerateVideosOperationDict(TypedDict, total=False):
5495
5983
  error: Optional[dict[str, Any]]
5496
5984
  """The error result of the operation in case of failure or cancellation."""
5497
5985
 
5498
- response: Optional[dict[str, Any]]
5499
- """The normal response of the operation in case of success."""
5986
+ response: Optional[GenerateVideosResponseDict]
5987
+ """The generated videos."""
5500
5988
 
5501
5989
  result: Optional[GenerateVideosResponseDict]
5502
5990
  """The generated videos."""
@@ -6693,10 +7181,6 @@ class Operation(_common.BaseModel):
6693
7181
  default=None,
6694
7182
  description="""The error result of the operation in case of failure or cancellation.""",
6695
7183
  )
6696
- response: Optional[dict[str, Any]] = Field(
6697
- default=None,
6698
- description="""The normal response of the operation in case of success.""",
6699
- )
6700
7184
 
6701
7185
 
6702
7186
  class OperationDict(TypedDict, total=False):
@@ -6714,9 +7198,6 @@ class OperationDict(TypedDict, total=False):
6714
7198
  error: Optional[dict[str, Any]]
6715
7199
  """The error result of the operation in case of failure or cancellation."""
6716
7200
 
6717
- response: Optional[dict[str, Any]]
6718
- """The normal response of the operation in case of success."""
6719
-
6720
7201
 
6721
7202
  OperationOrDict = Union[Operation, OperationDict]
6722
7203
 
@@ -8938,6 +9419,165 @@ LiveServerToolCallCancellationOrDict = Union[
8938
9419
  ]
8939
9420
 
8940
9421
 
9422
+ class UsageMetadata(_common.BaseModel):
9423
+ """Usage metadata about response(s)."""
9424
+
9425
+ prompt_token_count: Optional[int] = Field(
9426
+ default=None,
9427
+ description="""Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.""",
9428
+ )
9429
+ cached_content_token_count: Optional[int] = Field(
9430
+ default=None,
9431
+ description="""Number of tokens in the cached part of the prompt (the cached content).""",
9432
+ )
9433
+ response_token_count: Optional[int] = Field(
9434
+ default=None,
9435
+ description="""Total number of tokens across all the generated response candidates.""",
9436
+ )
9437
+ tool_use_prompt_token_count: Optional[int] = Field(
9438
+ default=None,
9439
+ description="""Number of tokens present in tool-use prompt(s).""",
9440
+ )
9441
+ thoughts_token_count: Optional[int] = Field(
9442
+ default=None,
9443
+ description="""Number of tokens of thoughts for thinking models.""",
9444
+ )
9445
+ total_token_count: Optional[int] = Field(
9446
+ default=None,
9447
+ description="""Total token count for prompt, response candidates, and tool-use prompts(if present).""",
9448
+ )
9449
+ prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(
9450
+ default=None,
9451
+ description="""List of modalities that were processed in the request input.""",
9452
+ )
9453
+ cache_tokens_details: Optional[list[ModalityTokenCount]] = Field(
9454
+ default=None,
9455
+ description="""List of modalities that were processed in the cache input.""",
9456
+ )
9457
+ response_tokens_details: Optional[list[ModalityTokenCount]] = Field(
9458
+ default=None,
9459
+ description="""List of modalities that were returned in the response.""",
9460
+ )
9461
+ tool_use_prompt_tokens_details: Optional[list[ModalityTokenCount]] = Field(
9462
+ default=None,
9463
+ description="""List of modalities that were processed in the tool-use prompt.""",
9464
+ )
9465
+ traffic_type: Optional[TrafficType] = Field(
9466
+ default=None,
9467
+ description="""Traffic type. This shows whether a request consumes Pay-As-You-Go
9468
+ or Provisioned Throughput quota.""",
9469
+ )
9470
+
9471
+
9472
+ class UsageMetadataDict(TypedDict, total=False):
9473
+ """Usage metadata about response(s)."""
9474
+
9475
+ prompt_token_count: Optional[int]
9476
+ """Number of tokens in the prompt. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content."""
9477
+
9478
+ cached_content_token_count: Optional[int]
9479
+ """Number of tokens in the cached part of the prompt (the cached content)."""
9480
+
9481
+ response_token_count: Optional[int]
9482
+ """Total number of tokens across all the generated response candidates."""
9483
+
9484
+ tool_use_prompt_token_count: Optional[int]
9485
+ """Number of tokens present in tool-use prompt(s)."""
9486
+
9487
+ thoughts_token_count: Optional[int]
9488
+ """Number of tokens of thoughts for thinking models."""
9489
+
9490
+ total_token_count: Optional[int]
9491
+ """Total token count for prompt, response candidates, and tool-use prompts(if present)."""
9492
+
9493
+ prompt_tokens_details: Optional[list[ModalityTokenCountDict]]
9494
+ """List of modalities that were processed in the request input."""
9495
+
9496
+ cache_tokens_details: Optional[list[ModalityTokenCountDict]]
9497
+ """List of modalities that were processed in the cache input."""
9498
+
9499
+ response_tokens_details: Optional[list[ModalityTokenCountDict]]
9500
+ """List of modalities that were returned in the response."""
9501
+
9502
+ tool_use_prompt_tokens_details: Optional[list[ModalityTokenCountDict]]
9503
+ """List of modalities that were processed in the tool-use prompt."""
9504
+
9505
+ traffic_type: Optional[TrafficType]
9506
+ """Traffic type. This shows whether a request consumes Pay-As-You-Go
9507
+ or Provisioned Throughput quota."""
9508
+
9509
+
9510
+ UsageMetadataOrDict = Union[UsageMetadata, UsageMetadataDict]
9511
+
9512
+
9513
+ class LiveServerGoAway(_common.BaseModel):
9514
+ """Server will not be able to service client soon."""
9515
+
9516
+ time_left: Optional[str] = Field(
9517
+ default=None,
9518
+ description="""The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model.""",
9519
+ )
9520
+
9521
+
9522
+ class LiveServerGoAwayDict(TypedDict, total=False):
9523
+ """Server will not be able to service client soon."""
9524
+
9525
+ time_left: Optional[str]
9526
+ """The remaining time before the connection will be terminated as ABORTED. The minimal time returned here is specified differently together with the rate limits for a given model."""
9527
+
9528
+
9529
+ LiveServerGoAwayOrDict = Union[LiveServerGoAway, LiveServerGoAwayDict]
9530
+
9531
+
9532
+ class LiveServerSessionResumptionUpdate(_common.BaseModel):
9533
+ """Update of the session resumption state.
9534
+
9535
+ Only sent if `session_resumption` was set in the connection config.
9536
+ """
9537
+
9538
+ new_handle: Optional[str] = Field(
9539
+ default=None,
9540
+ description="""New handle that represents state that can be resumed. Empty if `resumable`=false.""",
9541
+ )
9542
+ resumable: Optional[bool] = Field(
9543
+ default=None,
9544
+ description="""True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss.""",
9545
+ )
9546
+ last_consumed_client_message_index: Optional[int] = Field(
9547
+ default=None,
9548
+ description="""Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.
9549
+
9550
+ Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last `SessionResmumptionTokenUpdate`. This field will enable them to limit buffering (avoid keeping all requests in RAM).
9551
+
9552
+ Note: This should not be used for when resuming a session at some time later -- in those cases partial audio and video frames arelikely not needed.""",
9553
+ )
9554
+
9555
+
9556
+ class LiveServerSessionResumptionUpdateDict(TypedDict, total=False):
9557
+ """Update of the session resumption state.
9558
+
9559
+ Only sent if `session_resumption` was set in the connection config.
9560
+ """
9561
+
9562
+ new_handle: Optional[str]
9563
+ """New handle that represents state that can be resumed. Empty if `resumable`=false."""
9564
+
9565
+ resumable: Optional[bool]
9566
+ """True if session can be resumed at this point. It might be not possible to resume session at some points. In that case we send update empty new_handle and resumable=false. Example of such case could be model executing function calls or just generating. Resuming session (using previous session token) in such state will result in some data loss."""
9567
+
9568
+ last_consumed_client_message_index: Optional[int]
9569
+ """Index of last message sent by client that is included in state represented by this SessionResumptionToken. Only sent when `SessionResumptionConfig.transparent` is set.
9570
+
9571
+ Presence of this index allows users to transparently reconnect and avoid issue of losing some part of realtime audio input/video. If client wishes to temporarily disconnect (for example as result of receiving GoAway) they can do it without losing state by buffering messages sent since last `SessionResmumptionTokenUpdate`. This field will enable them to limit buffering (avoid keeping all requests in RAM).
9572
+
9573
+ Note: This should not be used for when resuming a session at some time later -- in those cases partial audio and video frames arelikely not needed."""
9574
+
9575
+
9576
+ LiveServerSessionResumptionUpdateOrDict = Union[
9577
+ LiveServerSessionResumptionUpdate, LiveServerSessionResumptionUpdateDict
9578
+ ]
9579
+
9580
+
8941
9581
  class LiveServerMessage(_common.BaseModel):
8942
9582
  """Response message for API call."""
8943
9583
 
@@ -8957,6 +9597,18 @@ class LiveServerMessage(_common.BaseModel):
8957
9597
  default=None,
8958
9598
  description="""Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled.""",
8959
9599
  )
9600
+ usage_metadata: Optional[UsageMetadata] = Field(
9601
+ default=None, description="""Usage metadata about model response(s)."""
9602
+ )
9603
+ go_away: Optional[LiveServerGoAway] = Field(
9604
+ default=None, description="""Server will disconnect soon."""
9605
+ )
9606
+ session_resumption_update: Optional[LiveServerSessionResumptionUpdate] = (
9607
+ Field(
9608
+ default=None,
9609
+ description="""Update of the session resumption state.""",
9610
+ )
9611
+ )
8960
9612
 
8961
9613
  @property
8962
9614
  def text(self) -> Optional[str]:
@@ -9008,10 +9660,223 @@ class LiveServerMessageDict(TypedDict, total=False):
9008
9660
  tool_call_cancellation: Optional[LiveServerToolCallCancellationDict]
9009
9661
  """Notification for the client that a previously issued `ToolCallMessage` with the specified `id`s should have been not executed and should be cancelled."""
9010
9662
 
9663
+ usage_metadata: Optional[UsageMetadataDict]
9664
+ """Usage metadata about model response(s)."""
9665
+
9666
+ go_away: Optional[LiveServerGoAwayDict]
9667
+ """Server will disconnect soon."""
9668
+
9669
+ session_resumption_update: Optional[LiveServerSessionResumptionUpdateDict]
9670
+ """Update of the session resumption state."""
9671
+
9011
9672
 
9012
9673
  LiveServerMessageOrDict = Union[LiveServerMessage, LiveServerMessageDict]
9013
9674
 
9014
9675
 
9676
+ class AutomaticActivityDetection(_common.BaseModel):
9677
+ """Configures automatic detection of activity."""
9678
+
9679
+ disabled: Optional[bool] = Field(
9680
+ default=None,
9681
+ description="""If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals.""",
9682
+ )
9683
+ start_of_speech_sensitivity: Optional[StartSensitivity] = Field(
9684
+ default=None,
9685
+ description="""Determines how likely speech is to be detected.""",
9686
+ )
9687
+ end_of_speech_sensitivity: Optional[EndSensitivity] = Field(
9688
+ default=None,
9689
+ description="""Determines how likely detected speech is ended.""",
9690
+ )
9691
+ prefix_padding_ms: Optional[int] = Field(
9692
+ default=None,
9693
+ description="""The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives.""",
9694
+ )
9695
+ silence_duration_ms: Optional[int] = Field(
9696
+ default=None,
9697
+ description="""The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user's activity but this will increase the model's latency.""",
9698
+ )
9699
+
9700
+
9701
+ class AutomaticActivityDetectionDict(TypedDict, total=False):
9702
+ """Configures automatic detection of activity."""
9703
+
9704
+ disabled: Optional[bool]
9705
+ """If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals."""
9706
+
9707
+ start_of_speech_sensitivity: Optional[StartSensitivity]
9708
+ """Determines how likely speech is to be detected."""
9709
+
9710
+ end_of_speech_sensitivity: Optional[EndSensitivity]
9711
+ """Determines how likely detected speech is ended."""
9712
+
9713
+ prefix_padding_ms: Optional[int]
9714
+ """The required duration of detected speech before start-of-speech is committed. The lower this value the more sensitive the start-of-speech detection is and the shorter speech can be recognized. However, this also increases the probability of false positives."""
9715
+
9716
+ silence_duration_ms: Optional[int]
9717
+ """The required duration of detected non-speech (e.g. silence) before end-of-speech is committed. The larger this value, the longer speech gaps can be without interrupting the user's activity but this will increase the model's latency."""
9718
+
9719
+
9720
+ AutomaticActivityDetectionOrDict = Union[
9721
+ AutomaticActivityDetection, AutomaticActivityDetectionDict
9722
+ ]
9723
+
9724
+
9725
+ class RealtimeInputConfig(_common.BaseModel):
9726
+ """Marks the end of user activity.
9727
+
9728
+ This can only be sent if automatic (i.e. server-side) activity detection is
9729
+ disabled.
9730
+ """
9731
+
9732
+ automatic_activity_detection: Optional[AutomaticActivityDetection] = Field(
9733
+ default=None,
9734
+ description="""If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.""",
9735
+ )
9736
+ activity_handling: Optional[ActivityHandling] = Field(
9737
+ default=None, description="""Defines what effect activity has."""
9738
+ )
9739
+ turn_coverage: Optional[TurnCoverage] = Field(
9740
+ default=None,
9741
+ description="""Defines which input is included in the user's turn.""",
9742
+ )
9743
+
9744
+
9745
+ class RealtimeInputConfigDict(TypedDict, total=False):
9746
+ """Marks the end of user activity.
9747
+
9748
+ This can only be sent if automatic (i.e. server-side) activity detection is
9749
+ disabled.
9750
+ """
9751
+
9752
+ automatic_activity_detection: Optional[AutomaticActivityDetectionDict]
9753
+ """If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals."""
9754
+
9755
+ activity_handling: Optional[ActivityHandling]
9756
+ """Defines what effect activity has."""
9757
+
9758
+ turn_coverage: Optional[TurnCoverage]
9759
+ """Defines which input is included in the user's turn."""
9760
+
9761
+
9762
+ RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict]
9763
+
9764
+
9765
+ class SessionResumptionConfig(_common.BaseModel):
9766
+ """Configuration of session resumption mechanism.
9767
+
9768
+ Included in `LiveConnectConfig.session_resumption`. If included server
9769
+ will send `LiveServerSessionResumptionUpdate` messages.
9770
+ """
9771
+
9772
+ handle: Optional[str] = Field(
9773
+ default=None,
9774
+ description="""Session resumption handle of previous session (session to restore).
9775
+
9776
+ If not present new session will be started.""",
9777
+ )
9778
+ transparent: Optional[bool] = Field(
9779
+ default=None,
9780
+ description="""If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections.""",
9781
+ )
9782
+
9783
+
9784
+ class SessionResumptionConfigDict(TypedDict, total=False):
9785
+ """Configuration of session resumption mechanism.
9786
+
9787
+ Included in `LiveConnectConfig.session_resumption`. If included server
9788
+ will send `LiveServerSessionResumptionUpdate` messages.
9789
+ """
9790
+
9791
+ handle: Optional[str]
9792
+ """Session resumption handle of previous session (session to restore).
9793
+
9794
+ If not present new session will be started."""
9795
+
9796
+ transparent: Optional[bool]
9797
+ """If set the server will send `last_consumed_client_message_index` in the `session_resumption_update` messages to allow for transparent reconnections."""
9798
+
9799
+
9800
+ SessionResumptionConfigOrDict = Union[
9801
+ SessionResumptionConfig, SessionResumptionConfigDict
9802
+ ]
9803
+
9804
+
9805
+ class SlidingWindow(_common.BaseModel):
9806
+ """Context window will be truncated by keeping only suffix of it.
9807
+
9808
+ Context window will always be cut at start of USER role turn. System
9809
+ instructions and `BidiGenerateContentSetup.prefix_turns` will not be
9810
+ subject to the sliding window mechanism, they will always stay at the
9811
+ beginning of context window.
9812
+ """
9813
+
9814
+ target_tokens: Optional[int] = Field(
9815
+ default=None,
9816
+ description="""Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed.""",
9817
+ )
9818
+
9819
+
9820
+ class SlidingWindowDict(TypedDict, total=False):
9821
+ """Context window will be truncated by keeping only suffix of it.
9822
+
9823
+ Context window will always be cut at start of USER role turn. System
9824
+ instructions and `BidiGenerateContentSetup.prefix_turns` will not be
9825
+ subject to the sliding window mechanism, they will always stay at the
9826
+ beginning of context window.
9827
+ """
9828
+
9829
+ target_tokens: Optional[int]
9830
+ """Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed."""
9831
+
9832
+
9833
+ SlidingWindowOrDict = Union[SlidingWindow, SlidingWindowDict]
9834
+
9835
+
9836
+ class ContextWindowCompressionConfig(_common.BaseModel):
9837
+ """Enables context window compression -- mechanism managing model context window so it does not exceed given length."""
9838
+
9839
+ trigger_tokens: Optional[int] = Field(
9840
+ default=None,
9841
+ description="""Number of tokens (before running turn) that triggers context window compression mechanism.""",
9842
+ )
9843
+ sliding_window: Optional[SlidingWindow] = Field(
9844
+ default=None, description="""Sliding window compression mechanism."""
9845
+ )
9846
+
9847
+
9848
+ class ContextWindowCompressionConfigDict(TypedDict, total=False):
9849
+ """Enables context window compression -- mechanism managing model context window so it does not exceed given length."""
9850
+
9851
+ trigger_tokens: Optional[int]
9852
+ """Number of tokens (before running turn) that triggers context window compression mechanism."""
9853
+
9854
+ sliding_window: Optional[SlidingWindowDict]
9855
+ """Sliding window compression mechanism."""
9856
+
9857
+
9858
+ ContextWindowCompressionConfigOrDict = Union[
9859
+ ContextWindowCompressionConfig, ContextWindowCompressionConfigDict
9860
+ ]
9861
+
9862
+
9863
+ class AudioTranscriptionConfig(_common.BaseModel):
9864
+ """The audio transcription configuration in Setup."""
9865
+
9866
+ pass
9867
+
9868
+
9869
+ class AudioTranscriptionConfigDict(TypedDict, total=False):
9870
+ """The audio transcription configuration in Setup."""
9871
+
9872
+ pass
9873
+
9874
+
9875
+ AudioTranscriptionConfigOrDict = Union[
9876
+ AudioTranscriptionConfig, AudioTranscriptionConfigDict
9877
+ ]
9878
+
9879
+
9015
9880
  class LiveClientSetup(_common.BaseModel):
9016
9881
  """Message contains configuration that will apply for the duration of the streaming session."""
9017
9882
 
@@ -9028,7 +9893,7 @@ class LiveClientSetup(_common.BaseModel):
9028
9893
  Note: only a subset of fields are supported.
9029
9894
  """,
9030
9895
  )
9031
- system_instruction: Optional[Content] = Field(
9896
+ system_instruction: Optional[ContentUnion] = Field(
9032
9897
  default=None,
9033
9898
  description="""The user provided system instructions for the model.
9034
9899
  Note: only text should be used in parts and content in each part will be
@@ -9042,6 +9907,18 @@ class LiveClientSetup(_common.BaseModel):
9042
9907
  external systems to perform an action, or set of actions, outside of
9043
9908
  knowledge and scope of the model.""",
9044
9909
  )
9910
+ session_resumption: Optional[SessionResumptionConfig] = Field(
9911
+ default=None,
9912
+ description="""Configures session resumption mechanism.
9913
+
9914
+ If included server will send SessionResumptionUpdate messages.""",
9915
+ )
9916
+ context_window_compression: Optional[ContextWindowCompressionConfig] = Field(
9917
+ default=None,
9918
+ description="""Configures context window compression mechanism.
9919
+
9920
+ If included, server will compress context window to fit into given length.""",
9921
+ )
9045
9922
 
9046
9923
 
9047
9924
  class LiveClientSetupDict(TypedDict, total=False):
@@ -9058,7 +9935,7 @@ class LiveClientSetupDict(TypedDict, total=False):
9058
9935
  Note: only a subset of fields are supported.
9059
9936
  """
9060
9937
 
9061
- system_instruction: Optional[ContentDict]
9938
+ system_instruction: Optional[ContentUnionDict]
9062
9939
  """The user provided system instructions for the model.
9063
9940
  Note: only text should be used in parts and content in each part will be
9064
9941
  in a separate paragraph."""
@@ -9070,6 +9947,16 @@ class LiveClientSetupDict(TypedDict, total=False):
9070
9947
  external systems to perform an action, or set of actions, outside of
9071
9948
  knowledge and scope of the model."""
9072
9949
 
9950
+ session_resumption: Optional[SessionResumptionConfigDict]
9951
+ """Configures session resumption mechanism.
9952
+
9953
+ If included server will send SessionResumptionUpdate messages."""
9954
+
9955
+ context_window_compression: Optional[ContextWindowCompressionConfigDict]
9956
+ """Configures context window compression mechanism.
9957
+
9958
+ If included, server will compress context window to fit into given length."""
9959
+
9073
9960
 
9074
9961
  LiveClientSetupOrDict = Union[LiveClientSetup, LiveClientSetupDict]
9075
9962
 
@@ -9126,6 +10013,52 @@ class LiveClientContentDict(TypedDict, total=False):
9126
10013
  LiveClientContentOrDict = Union[LiveClientContent, LiveClientContentDict]
9127
10014
 
9128
10015
 
10016
+ class ActivityStart(_common.BaseModel):
10017
+ """Marks the start of user activity.
10018
+
10019
+ This can only be sent if automatic (i.e. server-side) activity detection is
10020
+ disabled.
10021
+ """
10022
+
10023
+ pass
10024
+
10025
+
10026
+ class ActivityStartDict(TypedDict, total=False):
10027
+ """Marks the start of user activity.
10028
+
10029
+ This can only be sent if automatic (i.e. server-side) activity detection is
10030
+ disabled.
10031
+ """
10032
+
10033
+ pass
10034
+
10035
+
10036
+ ActivityStartOrDict = Union[ActivityStart, ActivityStartDict]
10037
+
10038
+
10039
+ class ActivityEnd(_common.BaseModel):
10040
+ """Marks the end of user activity.
10041
+
10042
+ This can only be sent if automatic (i.e. server-side) activity detection is
10043
+ disabled.
10044
+ """
10045
+
10046
+ pass
10047
+
10048
+
10049
+ class ActivityEndDict(TypedDict, total=False):
10050
+ """Marks the end of user activity.
10051
+
10052
+ This can only be sent if automatic (i.e. server-side) activity detection is
10053
+ disabled.
10054
+ """
10055
+
10056
+ pass
10057
+
10058
+
10059
+ ActivityEndOrDict = Union[ActivityEnd, ActivityEndDict]
10060
+
10061
+
9129
10062
  class LiveClientRealtimeInput(_common.BaseModel):
9130
10063
  """User input that is sent in real time.
9131
10064
 
@@ -9251,23 +10184,6 @@ class LiveClientMessageDict(TypedDict, total=False):
9251
10184
  LiveClientMessageOrDict = Union[LiveClientMessage, LiveClientMessageDict]
9252
10185
 
9253
10186
 
9254
- class AudioTranscriptionConfig(_common.BaseModel):
9255
- """The audio transcription configuration in Setup."""
9256
-
9257
- pass
9258
-
9259
-
9260
- class AudioTranscriptionConfigDict(TypedDict, total=False):
9261
- """The audio transcription configuration in Setup."""
9262
-
9263
- pass
9264
-
9265
-
9266
- AudioTranscriptionConfigOrDict = Union[
9267
- AudioTranscriptionConfig, AudioTranscriptionConfigDict
9268
- ]
9269
-
9270
-
9271
10187
  class LiveConnectConfig(_common.BaseModel):
9272
10188
  """Session config for the API connection."""
9273
10189
 
@@ -9310,6 +10226,11 @@ class LiveConnectConfig(_common.BaseModel):
9310
10226
  description="""Maximum number of tokens that can be generated in the response.
9311
10227
  """,
9312
10228
  )
10229
+ media_resolution: Optional[MediaResolution] = Field(
10230
+ default=None,
10231
+ description="""If specified, the media resolution specified will be used.
10232
+ """,
10233
+ )
9313
10234
  seed: Optional[int] = Field(
9314
10235
  default=None,
9315
10236
  description="""When ``seed`` is fixed to a specific number, the model makes a best
@@ -9322,7 +10243,7 @@ class LiveConnectConfig(_common.BaseModel):
9322
10243
  description="""The speech generation configuration.
9323
10244
  """,
9324
10245
  )
9325
- system_instruction: Optional[Content] = Field(
10246
+ system_instruction: Optional[ContentUnion] = Field(
9326
10247
  default=None,
9327
10248
  description="""The user provided system instructions for the model.
9328
10249
  Note: only text should be used in parts and content in each part will be
@@ -9336,6 +10257,12 @@ class LiveConnectConfig(_common.BaseModel):
9336
10257
  external systems to perform an action, or set of actions, outside of
9337
10258
  knowledge and scope of the model.""",
9338
10259
  )
10260
+ session_resumption: Optional[SessionResumptionConfig] = Field(
10261
+ default=None,
10262
+ description="""Configures session resumption mechanism.
10263
+
10264
+ If included the server will send SessionResumptionUpdate messages.""",
10265
+ )
9339
10266
  input_audio_transcription: Optional[AudioTranscriptionConfig] = Field(
9340
10267
  default=None,
9341
10268
  description="""The transcription of the input aligns with the input audio language.
@@ -9347,6 +10274,16 @@ class LiveConnectConfig(_common.BaseModel):
9347
10274
  specified for the output audio.
9348
10275
  """,
9349
10276
  )
10277
+ realtime_input_config: Optional[RealtimeInputConfig] = Field(
10278
+ default=None,
10279
+ description="""Configures the realtime input behavior in BidiGenerateContent.""",
10280
+ )
10281
+ context_window_compression: Optional[ContextWindowCompressionConfig] = Field(
10282
+ default=None,
10283
+ description="""Configures context window compression mechanism.
10284
+
10285
+ If included, server will compress context window to fit into given length.""",
10286
+ )
9350
10287
 
9351
10288
 
9352
10289
  class LiveConnectConfigDict(TypedDict, total=False):
@@ -9385,6 +10322,10 @@ class LiveConnectConfigDict(TypedDict, total=False):
9385
10322
  """Maximum number of tokens that can be generated in the response.
9386
10323
  """
9387
10324
 
10325
+ media_resolution: Optional[MediaResolution]
10326
+ """If specified, the media resolution specified will be used.
10327
+ """
10328
+
9388
10329
  seed: Optional[int]
9389
10330
  """When ``seed`` is fixed to a specific number, the model makes a best
9390
10331
  effort to provide the same response for repeated requests. By default, a
@@ -9395,7 +10336,7 @@ class LiveConnectConfigDict(TypedDict, total=False):
9395
10336
  """The speech generation configuration.
9396
10337
  """
9397
10338
 
9398
- system_instruction: Optional[ContentDict]
10339
+ system_instruction: Optional[ContentUnionDict]
9399
10340
  """The user provided system instructions for the model.
9400
10341
  Note: only text should be used in parts and content in each part will be
9401
10342
  in a separate paragraph."""
@@ -9407,6 +10348,11 @@ class LiveConnectConfigDict(TypedDict, total=False):
9407
10348
  external systems to perform an action, or set of actions, outside of
9408
10349
  knowledge and scope of the model."""
9409
10350
 
10351
+ session_resumption: Optional[SessionResumptionConfigDict]
10352
+ """Configures session resumption mechanism.
10353
+
10354
+ If included the server will send SessionResumptionUpdate messages."""
10355
+
9410
10356
  input_audio_transcription: Optional[AudioTranscriptionConfigDict]
9411
10357
  """The transcription of the input aligns with the input audio language.
9412
10358
  """
@@ -9416,5 +10362,45 @@ class LiveConnectConfigDict(TypedDict, total=False):
9416
10362
  specified for the output audio.
9417
10363
  """
9418
10364
 
10365
+ realtime_input_config: Optional[RealtimeInputConfigDict]
10366
+ """Configures the realtime input behavior in BidiGenerateContent."""
10367
+
10368
+ context_window_compression: Optional[ContextWindowCompressionConfigDict]
10369
+ """Configures context window compression mechanism.
10370
+
10371
+ If included, server will compress context window to fit into given length."""
10372
+
9419
10373
 
9420
10374
  LiveConnectConfigOrDict = Union[LiveConnectConfig, LiveConnectConfigDict]
10375
+
10376
+
10377
+ class LiveConnectParameters(_common.BaseModel):
10378
+ """Parameters for connecting to the live API."""
10379
+
10380
+ model: Optional[str] = Field(
10381
+ default=None,
10382
+ description="""ID of the model to use. For a list of models, see `Google models
10383
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",
10384
+ )
10385
+ config: Optional[LiveConnectConfig] = Field(
10386
+ default=None,
10387
+ description="""Optional configuration parameters for the request.
10388
+ """,
10389
+ )
10390
+
10391
+
10392
+ class LiveConnectParametersDict(TypedDict, total=False):
10393
+ """Parameters for connecting to the live API."""
10394
+
10395
+ model: Optional[str]
10396
+ """ID of the model to use. For a list of models, see `Google models
10397
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""
10398
+
10399
+ config: Optional[LiveConnectConfigDict]
10400
+ """Optional configuration parameters for the request.
10401
+ """
10402
+
10403
+
10404
+ LiveConnectParametersOrDict = Union[
10405
+ LiveConnectParameters, LiveConnectParametersDict
10406
+ ]