google-genai 1.30.0__py3-none-any.whl → 1.32.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
@@ -19,6 +19,7 @@ from abc import ABC, abstractmethod
19
19
  import datetime
20
20
  from enum import Enum, EnumMeta
21
21
  import inspect
22
+ import io
22
23
  import json
23
24
  import logging
24
25
  import sys
@@ -29,6 +30,11 @@ import pydantic
29
30
  from pydantic import ConfigDict, Field, PrivateAttr, model_validator
30
31
  from typing_extensions import Self, TypedDict
31
32
  from . import _common
33
+ from ._operations_converters import (
34
+ _GenerateVideosOperation_from_mldev,
35
+ _GenerateVideosOperation_from_vertex,
36
+ )
37
+
32
38
 
33
39
  if sys.version_info >= (3, 10):
34
40
  # Supports both Union[t1, t2] and t1 | t2
@@ -429,6 +435,22 @@ class AdapterSize(_common.CaseInSensitiveEnum):
429
435
  """Adapter size 32."""
430
436
 
431
437
 
438
+ class JSONSchemaType(Enum):
439
+ """The type of the data supported by JSON Schema.
440
+
441
+ The values of the enums are lower case strings, while the values of the enums
442
+ for the Type class are upper case strings.
443
+ """
444
+
445
+ NULL = 'null'
446
+ BOOLEAN = 'boolean'
447
+ OBJECT = 'object'
448
+ ARRAY = 'array'
449
+ NUMBER = 'number'
450
+ INTEGER = 'integer'
451
+ STRING = 'string'
452
+
453
+
432
454
  class FeatureSelectionPreference(_common.CaseInSensitiveEnum):
433
455
  """Options for feature selection preference."""
434
456
 
@@ -480,6 +502,8 @@ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
480
502
  """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""
481
503
  NONE = 'NONE'
482
504
  """Model will not predict any function calls. Model behavior is same as when not passing any function declarations."""
505
+ VALIDATED = 'VALIDATED'
506
+ """Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations"."""
483
507
 
484
508
 
485
509
  class SafetyFilterLevel(_common.CaseInSensitiveEnum):
@@ -564,6 +588,28 @@ class EditMode(_common.CaseInSensitiveEnum):
564
588
  EDIT_MODE_PRODUCT_IMAGE = 'EDIT_MODE_PRODUCT_IMAGE'
565
589
 
566
590
 
591
+ class SegmentMode(_common.CaseInSensitiveEnum):
592
+ """Enum that represents the segmentation mode."""
593
+
594
+ FOREGROUND = 'FOREGROUND'
595
+ BACKGROUND = 'BACKGROUND'
596
+ PROMPT = 'PROMPT'
597
+ SEMANTIC = 'SEMANTIC'
598
+ INTERACTIVE = 'INTERACTIVE'
599
+
600
+
601
+ class VideoGenerationReferenceType(_common.CaseInSensitiveEnum):
602
+ """Enum for the reference type of a video generation reference image."""
603
+
604
+ ASSET = 'ASSET'
605
+ """A reference image that provides assets to the generated video,
606
+ such as the scene, an object, a character, etc."""
607
+ STYLE = 'STYLE'
608
+ """A reference image that provides aesthetics including colors,
609
+ lighting, texture, etc., to be used as the style of the generated video,
610
+ such as 'anime', 'photography', 'origami', etc."""
611
+
612
+
567
613
  class VideoCompressionQuality(_common.CaseInSensitiveEnum):
568
614
  """Enum that controls the compression quality of the generated videos."""
569
615
 
@@ -609,6 +655,19 @@ class MediaModality(_common.CaseInSensitiveEnum):
609
655
  """Document, e.g. PDF."""
610
656
 
611
657
 
658
+ class FunctionResponseScheduling(_common.CaseInSensitiveEnum):
659
+ """Specifies how the response should be scheduled in the conversation."""
660
+
661
+ SCHEDULING_UNSPECIFIED = 'SCHEDULING_UNSPECIFIED'
662
+ """This value is unused."""
663
+ SILENT = 'SILENT'
664
+ """Only add the result to the conversation context, do not interrupt or trigger generation."""
665
+ WHEN_IDLE = 'WHEN_IDLE'
666
+ """Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation."""
667
+ INTERRUPT = 'INTERRUPT'
668
+ """Add the result to the conversation context, interrupt ongoing generation and prompt to generate output."""
669
+
670
+
612
671
  class StartSensitivity(_common.CaseInSensitiveEnum):
613
672
  """Start of speech sensitivity."""
614
673
 
@@ -653,19 +712,6 @@ class TurnCoverage(_common.CaseInSensitiveEnum):
653
712
  """The users turn includes all realtime input since the last turn, including inactivity (e.g. silence on the audio stream)."""
654
713
 
655
714
 
656
- class FunctionResponseScheduling(_common.CaseInSensitiveEnum):
657
- """Specifies how the response should be scheduled in the conversation."""
658
-
659
- SCHEDULING_UNSPECIFIED = 'SCHEDULING_UNSPECIFIED'
660
- """This value is unused."""
661
- SILENT = 'SILENT'
662
- """Only add the result to the conversation context, do not interrupt or trigger generation."""
663
- WHEN_IDLE = 'WHEN_IDLE'
664
- """Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation."""
665
- INTERRUPT = 'INTERRUPT'
666
- """Add the result to the conversation context, interrupt ongoing generation and prompt to generate output."""
667
-
668
-
669
715
  class Scale(_common.CaseInSensitiveEnum):
670
716
  """Scale of the generated music."""
671
717
 
@@ -778,6 +824,21 @@ class Blob(_common.BaseModel):
778
824
  description="""Required. The IANA standard MIME type of the source data.""",
779
825
  )
780
826
 
827
+ def as_image(self) -> Optional['PIL_Image']:
828
+ """Returns the Blob as a PIL Image, or None if the Blob is not an image."""
829
+ if (
830
+ not self.data
831
+ or not self.mime_type
832
+ or not self.mime_type.startswith('image/')
833
+ ):
834
+ return None
835
+ if not _is_pillow_image_imported:
836
+ raise ImportError(
837
+ 'The PIL module is not available. Please install the Pillow'
838
+ ' package. `pip install pillow`'
839
+ )
840
+ return PIL.Image.open(io.BytesIO(self.data))
841
+
781
842
 
782
843
  class BlobDict(TypedDict, total=False):
783
844
  """Content blob."""
@@ -1037,6 +1098,12 @@ class Part(_common.BaseModel):
1037
1098
  default=None, description="""Optional. Text part (can be code)."""
1038
1099
  )
1039
1100
 
1101
+ def as_image(self) -> Optional['PIL_Image']:
1102
+ """Returns the part as a PIL Image, or None if the part is not an image."""
1103
+ if not self.inline_data:
1104
+ return None
1105
+ return self.inline_data.as_image()
1106
+
1040
1107
  @classmethod
1041
1108
  def from_uri(
1042
1109
  cls, *, file_uri: str, mime_type: Optional[str] = None
@@ -1152,67 +1219,6 @@ class Content(_common.BaseModel):
1152
1219
  )
1153
1220
 
1154
1221
 
1155
- class UserContent(Content):
1156
- """UserContent facilitates the creation of a Content object with a user role.
1157
-
1158
- Example usages:
1159
-
1160
-
1161
- - Create a user Content object with a string:
1162
- user_content = UserContent("Why is the sky blue?")
1163
- - Create a user Content object with a file data Part object:
1164
- user_content = UserContent(Part.from_uri(file_uril="gs://bucket/file.txt",
1165
- mime_type="text/plain"))
1166
- - Create a user Content object with byte data Part object:
1167
- user_content = UserContent(Part.from_bytes(data=b"Hello, World!",
1168
- mime_type="text/plain"))
1169
-
1170
- You can create a user Content object using other classmethods in the Part
1171
- class as well.
1172
- You can also create a user Content using a list of Part objects or strings.
1173
- """
1174
-
1175
- role: Literal['user'] = Field(default='user', init=False, frozen=True)
1176
- parts: list[Part] = Field()
1177
-
1178
- def __init__(
1179
- self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]
1180
- ):
1181
- from . import _transformers as t
1182
-
1183
- super().__init__(parts=t.t_parts(parts=parts))
1184
-
1185
-
1186
- class ModelContent(Content):
1187
- """ModelContent facilitates the creation of a Content object with a model role.
1188
-
1189
- Example usages:
1190
-
1191
- - Create a model Content object with a string:
1192
- model_content = ModelContent("Why is the sky blue?")
1193
- - Create a model Content object with a file data Part object:
1194
- model_content = ModelContent(Part.from_uri(file_uril="gs://bucket/file.txt",
1195
- mime_type="text/plain"))
1196
- - Create a model Content object with byte data Part object:
1197
- model_content = ModelContent(Part.from_bytes(data=b"Hello, World!",
1198
- mime_type="text/plain"))
1199
-
1200
- You can create a model Content object using other classmethods in the Part
1201
- class as well.
1202
- You can also create a model Content using a list of Part objects or strings.
1203
- """
1204
-
1205
- role: Literal['model'] = Field(default='model', init=False, frozen=True)
1206
- parts: list[Part] = Field()
1207
-
1208
- def __init__(
1209
- self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]
1210
- ):
1211
- from . import _transformers as t
1212
-
1213
- super().__init__(parts=t.t_parts(parts=parts))
1214
-
1215
-
1216
1222
  class ContentDict(TypedDict, total=False):
1217
1223
  """Contains the multi-part content of a message."""
1218
1224
 
@@ -1355,23 +1361,7 @@ class HttpOptionsDict(TypedDict, total=False):
1355
1361
  HttpOptionsOrDict = Union[HttpOptions, HttpOptionsDict]
1356
1362
 
1357
1363
 
1358
- class JSONSchemaType(Enum):
1359
- """The type of the data supported by JSON Schema.
1360
-
1361
- The values of the enums are lower case strings, while the values of the enums
1362
- for the Type class are upper case strings.
1363
- """
1364
-
1365
- NULL = 'null'
1366
- BOOLEAN = 'boolean'
1367
- OBJECT = 'object'
1368
- ARRAY = 'array'
1369
- NUMBER = 'number'
1370
- INTEGER = 'integer'
1371
- STRING = 'string'
1372
-
1373
-
1374
- class JSONSchema(pydantic.BaseModel):
1364
+ class JSONSchema(_common.BaseModel):
1375
1365
  """A subset of JSON Schema according to 2020-12 JSON Schema draft.
1376
1366
 
1377
1367
  Represents a subset of a JSON Schema object that is used by the Gemini model.
@@ -5497,6 +5487,23 @@ class GenerateContentResponse(_common.BaseModel):
5497
5487
  # part.text == '' is different from part.text is None
5498
5488
  return text if any_text_part_text else None
5499
5489
 
5490
+ @property
5491
+ def parts(self) -> Optional[list[Part]]:
5492
+ """Returns the content-parts in the response."""
5493
+ if (
5494
+ not self.candidates
5495
+ or self.candidates[0].content is None
5496
+ or self.candidates[0].content.parts is None
5497
+ ):
5498
+ return None
5499
+ if len(self.candidates) > 1:
5500
+ logger.warning(
5501
+ 'Warning: there are multiple candidates in the response, returning'
5502
+ ' parts from the first one.'
5503
+ )
5504
+
5505
+ return self.candidates[0].content.parts
5506
+
5500
5507
  @property
5501
5508
  def text(self) -> Optional[str]:
5502
5509
  """Returns the concatenation of all text parts in the response."""
@@ -6905,6 +6912,10 @@ class _UpscaleImageAPIConfig(_common.BaseModel):
6905
6912
  http_options: Optional[HttpOptions] = Field(
6906
6913
  default=None, description="""Used to override HTTP request options."""
6907
6914
  )
6915
+ output_gcs_uri: Optional[str] = Field(
6916
+ default=None,
6917
+ description="""Cloud Storage URI used to store the generated images.""",
6918
+ )
6908
6919
  include_rai_reason: Optional[bool] = Field(
6909
6920
  default=None,
6910
6921
  description="""Whether to include a reason for filtered-out images in the
@@ -6946,6 +6957,9 @@ class _UpscaleImageAPIConfigDict(TypedDict, total=False):
6946
6957
  http_options: Optional[HttpOptionsDict]
6947
6958
  """Used to override HTTP request options."""
6948
6959
 
6960
+ output_gcs_uri: Optional[str]
6961
+ """Cloud Storage URI used to store the generated images."""
6962
+
6949
6963
  include_rai_reason: Optional[bool]
6950
6964
  """Whether to include a reason for filtered-out images in the
6951
6965
  response."""
@@ -7129,6 +7143,10 @@ class RecontextImageConfig(_common.BaseModel):
7129
7143
  description="""Whether allow to generate person images, and restrict to specific
7130
7144
  ages.""",
7131
7145
  )
7146
+ add_watermark: Optional[bool] = Field(
7147
+ default=None,
7148
+ description="""Whether to add a SynthID watermark to the generated images.""",
7149
+ )
7132
7150
  output_mime_type: Optional[str] = Field(
7133
7151
  default=None, description="""MIME type of the generated image."""
7134
7152
  )
@@ -7168,6 +7186,9 @@ class RecontextImageConfigDict(TypedDict, total=False):
7168
7186
  """Whether allow to generate person images, and restrict to specific
7169
7187
  ages."""
7170
7188
 
7189
+ add_watermark: Optional[bool]
7190
+ """Whether to add a SynthID watermark to the generated images."""
7191
+
7171
7192
  output_mime_type: Optional[str]
7172
7193
  """MIME type of the generated image."""
7173
7194
 
@@ -7241,118 +7262,348 @@ RecontextImageResponseOrDict = Union[
7241
7262
  ]
7242
7263
 
7243
7264
 
7244
- class GetModelConfig(_common.BaseModel):
7245
- """Optional parameters for models.get method."""
7265
+ class ScribbleImage(_common.BaseModel):
7266
+ """An image mask representing a brush scribble."""
7246
7267
 
7247
- http_options: Optional[HttpOptions] = Field(
7248
- default=None, description="""Used to override HTTP request options."""
7268
+ image: Optional[Image] = Field(
7269
+ default=None,
7270
+ description="""The brush scribble to guide segmentation. Valid for the interactive mode.""",
7249
7271
  )
7250
7272
 
7251
7273
 
7252
- class GetModelConfigDict(TypedDict, total=False):
7253
- """Optional parameters for models.get method."""
7274
+ class ScribbleImageDict(TypedDict, total=False):
7275
+ """An image mask representing a brush scribble."""
7254
7276
 
7255
- http_options: Optional[HttpOptionsDict]
7256
- """Used to override HTTP request options."""
7277
+ image: Optional[ImageDict]
7278
+ """The brush scribble to guide segmentation. Valid for the interactive mode."""
7257
7279
 
7258
7280
 
7259
- GetModelConfigOrDict = Union[GetModelConfig, GetModelConfigDict]
7281
+ ScribbleImageOrDict = Union[ScribbleImage, ScribbleImageDict]
7260
7282
 
7261
7283
 
7262
- class _GetModelParameters(_common.BaseModel):
7284
+ class SegmentImageSource(_common.BaseModel):
7285
+ """A set of source input(s) for image segmentation."""
7263
7286
 
7264
- model: Optional[str] = Field(default=None, description="""""")
7265
- config: Optional[GetModelConfig] = Field(
7266
- default=None, description="""Optional parameters for the request."""
7287
+ prompt: Optional[str] = Field(
7288
+ default=None,
7289
+ description="""A text prompt for guiding the model during image segmentation.
7290
+ Required for prompt mode and semantic mode, disallowed for other modes.""",
7291
+ )
7292
+ image: Optional[Image] = Field(
7293
+ default=None, description="""The image to be segmented."""
7294
+ )
7295
+ scribble_image: Optional[ScribbleImage] = Field(
7296
+ default=None,
7297
+ description="""The brush scribble to guide segmentation.
7298
+ Required for the interactive mode, disallowed for other modes.""",
7267
7299
  )
7268
7300
 
7269
7301
 
7270
- class _GetModelParametersDict(TypedDict, total=False):
7302
+ class SegmentImageSourceDict(TypedDict, total=False):
7303
+ """A set of source input(s) for image segmentation."""
7271
7304
 
7272
- model: Optional[str]
7273
- """"""
7305
+ prompt: Optional[str]
7306
+ """A text prompt for guiding the model during image segmentation.
7307
+ Required for prompt mode and semantic mode, disallowed for other modes."""
7274
7308
 
7275
- config: Optional[GetModelConfigDict]
7276
- """Optional parameters for the request."""
7309
+ image: Optional[ImageDict]
7310
+ """The image to be segmented."""
7277
7311
 
7312
+ scribble_image: Optional[ScribbleImageDict]
7313
+ """The brush scribble to guide segmentation.
7314
+ Required for the interactive mode, disallowed for other modes."""
7278
7315
 
7279
- _GetModelParametersOrDict = Union[_GetModelParameters, _GetModelParametersDict]
7280
7316
 
7317
+ SegmentImageSourceOrDict = Union[SegmentImageSource, SegmentImageSourceDict]
7281
7318
 
7282
- class Endpoint(_common.BaseModel):
7283
- """An endpoint where you deploy models."""
7284
7319
 
7285
- name: Optional[str] = Field(
7286
- default=None, description="""Resource name of the endpoint."""
7320
+ class SegmentImageConfig(_common.BaseModel):
7321
+ """Configuration for segmenting an image."""
7322
+
7323
+ http_options: Optional[HttpOptions] = Field(
7324
+ default=None, description="""Used to override HTTP request options."""
7287
7325
  )
7288
- deployed_model_id: Optional[str] = Field(
7326
+ mode: Optional[SegmentMode] = Field(
7327
+ default=None, description="""The segmentation mode to use."""
7328
+ )
7329
+ max_predictions: Optional[int] = Field(
7289
7330
  default=None,
7290
- description="""ID of the model that's deployed to the endpoint.""",
7331
+ description="""The maximum number of predictions to return up to, by top
7332
+ confidence score.""",
7333
+ )
7334
+ confidence_threshold: Optional[float] = Field(
7335
+ default=None,
7336
+ description="""The confidence score threshold for the detections as a decimal
7337
+ value. Only predictions with a confidence score higher than this
7338
+ threshold will be returned.""",
7339
+ )
7340
+ mask_dilation: Optional[float] = Field(
7341
+ default=None,
7342
+ description="""A decimal value representing how much dilation to apply to the
7343
+ masks. 0 for no dilation. 1.0 means the masked area covers the whole
7344
+ image.""",
7345
+ )
7346
+ binary_color_threshold: Optional[float] = Field(
7347
+ default=None,
7348
+ description="""The binary color threshold to apply to the masks. The threshold
7349
+ can be set to a decimal value between 0 and 255 non-inclusive.
7350
+ Set to -1 for no binary color thresholding.""",
7291
7351
  )
7292
7352
 
7293
7353
 
7294
- class EndpointDict(TypedDict, total=False):
7295
- """An endpoint where you deploy models."""
7354
+ class SegmentImageConfigDict(TypedDict, total=False):
7355
+ """Configuration for segmenting an image."""
7296
7356
 
7297
- name: Optional[str]
7298
- """Resource name of the endpoint."""
7357
+ http_options: Optional[HttpOptionsDict]
7358
+ """Used to override HTTP request options."""
7299
7359
 
7300
- deployed_model_id: Optional[str]
7301
- """ID of the model that's deployed to the endpoint."""
7360
+ mode: Optional[SegmentMode]
7361
+ """The segmentation mode to use."""
7302
7362
 
7363
+ max_predictions: Optional[int]
7364
+ """The maximum number of predictions to return up to, by top
7365
+ confidence score."""
7303
7366
 
7304
- EndpointOrDict = Union[Endpoint, EndpointDict]
7367
+ confidence_threshold: Optional[float]
7368
+ """The confidence score threshold for the detections as a decimal
7369
+ value. Only predictions with a confidence score higher than this
7370
+ threshold will be returned."""
7305
7371
 
7372
+ mask_dilation: Optional[float]
7373
+ """A decimal value representing how much dilation to apply to the
7374
+ masks. 0 for no dilation. 1.0 means the masked area covers the whole
7375
+ image."""
7306
7376
 
7307
- class TunedModelInfo(_common.BaseModel):
7308
- """A tuned machine learning model."""
7377
+ binary_color_threshold: Optional[float]
7378
+ """The binary color threshold to apply to the masks. The threshold
7379
+ can be set to a decimal value between 0 and 255 non-inclusive.
7380
+ Set to -1 for no binary color thresholding."""
7309
7381
 
7310
- base_model: Optional[str] = Field(
7382
+
7383
+ SegmentImageConfigOrDict = Union[SegmentImageConfig, SegmentImageConfigDict]
7384
+
7385
+
7386
+ class _SegmentImageParameters(_common.BaseModel):
7387
+ """The parameters for segmenting an image."""
7388
+
7389
+ model: Optional[str] = Field(
7311
7390
  default=None,
7312
- description="""ID of the base model that you want to tune.""",
7391
+ description="""ID of the model to use. For a list of models, see `Google models
7392
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_.""",
7313
7393
  )
7314
- create_time: Optional[datetime.datetime] = Field(
7394
+ source: Optional[SegmentImageSource] = Field(
7315
7395
  default=None,
7316
- description="""Date and time when the base model was created.""",
7396
+ description="""A set of source input(s) for image segmentation.""",
7317
7397
  )
7318
- update_time: Optional[datetime.datetime] = Field(
7319
- default=None,
7320
- description="""Date and time when the base model was last updated.""",
7398
+ config: Optional[SegmentImageConfig] = Field(
7399
+ default=None, description="""Configuration for image segmentation."""
7321
7400
  )
7322
7401
 
7323
7402
 
7324
- class TunedModelInfoDict(TypedDict, total=False):
7325
- """A tuned machine learning model."""
7403
+ class _SegmentImageParametersDict(TypedDict, total=False):
7404
+ """The parameters for segmenting an image."""
7326
7405
 
7327
- base_model: Optional[str]
7328
- """ID of the base model that you want to tune."""
7406
+ model: Optional[str]
7407
+ """ID of the model to use. For a list of models, see `Google models
7408
+ <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>`_."""
7329
7409
 
7330
- create_time: Optional[datetime.datetime]
7331
- """Date and time when the base model was created."""
7410
+ source: Optional[SegmentImageSourceDict]
7411
+ """A set of source input(s) for image segmentation."""
7332
7412
 
7333
- update_time: Optional[datetime.datetime]
7334
- """Date and time when the base model was last updated."""
7413
+ config: Optional[SegmentImageConfigDict]
7414
+ """Configuration for image segmentation."""
7335
7415
 
7336
7416
 
7337
- TunedModelInfoOrDict = Union[TunedModelInfo, TunedModelInfoDict]
7417
+ _SegmentImageParametersOrDict = Union[
7418
+ _SegmentImageParameters, _SegmentImageParametersDict
7419
+ ]
7338
7420
 
7339
7421
 
7340
- class Checkpoint(_common.BaseModel):
7341
- """Describes the machine learning model version checkpoint."""
7422
+ class EntityLabel(_common.BaseModel):
7423
+ """An entity representing the segmented area."""
7342
7424
 
7343
- checkpoint_id: Optional[str] = Field(
7344
- default=None,
7345
- description="""The ID of the checkpoint.
7346
- """,
7425
+ label: Optional[str] = Field(
7426
+ default=None, description="""The label of the segmented entity."""
7347
7427
  )
7348
- epoch: Optional[int] = Field(
7428
+ score: Optional[float] = Field(
7349
7429
  default=None,
7350
- description="""The epoch of the checkpoint.
7351
- """,
7430
+ description="""The confidence score of the detected label.""",
7352
7431
  )
7353
- step: Optional[int] = Field(
7354
- default=None,
7355
- description="""The step of the checkpoint.
7432
+
7433
+
7434
+ class EntityLabelDict(TypedDict, total=False):
7435
+ """An entity representing the segmented area."""
7436
+
7437
+ label: Optional[str]
7438
+ """The label of the segmented entity."""
7439
+
7440
+ score: Optional[float]
7441
+ """The confidence score of the detected label."""
7442
+
7443
+
7444
+ EntityLabelOrDict = Union[EntityLabel, EntityLabelDict]
7445
+
7446
+
7447
+ class GeneratedImageMask(_common.BaseModel):
7448
+ """A generated image mask."""
7449
+
7450
+ mask: Optional[Image] = Field(
7451
+ default=None, description="""The generated image mask."""
7452
+ )
7453
+ labels: Optional[list[EntityLabel]] = Field(
7454
+ default=None,
7455
+ description="""The detected entities on the segmented area.""",
7456
+ )
7457
+
7458
+
7459
+ class GeneratedImageMaskDict(TypedDict, total=False):
7460
+ """A generated image mask."""
7461
+
7462
+ mask: Optional[ImageDict]
7463
+ """The generated image mask."""
7464
+
7465
+ labels: Optional[list[EntityLabelDict]]
7466
+ """The detected entities on the segmented area."""
7467
+
7468
+
7469
+ GeneratedImageMaskOrDict = Union[GeneratedImageMask, GeneratedImageMaskDict]
7470
+
7471
+
7472
+ class SegmentImageResponse(_common.BaseModel):
7473
+ """The output images response."""
7474
+
7475
+ generated_masks: Optional[list[GeneratedImageMask]] = Field(
7476
+ default=None,
7477
+ description="""List of generated image masks.
7478
+ """,
7479
+ )
7480
+
7481
+
7482
+ class SegmentImageResponseDict(TypedDict, total=False):
7483
+ """The output images response."""
7484
+
7485
+ generated_masks: Optional[list[GeneratedImageMaskDict]]
7486
+ """List of generated image masks.
7487
+ """
7488
+
7489
+
7490
+ SegmentImageResponseOrDict = Union[
7491
+ SegmentImageResponse, SegmentImageResponseDict
7492
+ ]
7493
+
7494
+
7495
+ class GetModelConfig(_common.BaseModel):
7496
+ """Optional parameters for models.get method."""
7497
+
7498
+ http_options: Optional[HttpOptions] = Field(
7499
+ default=None, description="""Used to override HTTP request options."""
7500
+ )
7501
+
7502
+
7503
+ class GetModelConfigDict(TypedDict, total=False):
7504
+ """Optional parameters for models.get method."""
7505
+
7506
+ http_options: Optional[HttpOptionsDict]
7507
+ """Used to override HTTP request options."""
7508
+
7509
+
7510
+ GetModelConfigOrDict = Union[GetModelConfig, GetModelConfigDict]
7511
+
7512
+
7513
+ class _GetModelParameters(_common.BaseModel):
7514
+
7515
+ model: Optional[str] = Field(default=None, description="""""")
7516
+ config: Optional[GetModelConfig] = Field(
7517
+ default=None, description="""Optional parameters for the request."""
7518
+ )
7519
+
7520
+
7521
+ class _GetModelParametersDict(TypedDict, total=False):
7522
+
7523
+ model: Optional[str]
7524
+ """"""
7525
+
7526
+ config: Optional[GetModelConfigDict]
7527
+ """Optional parameters for the request."""
7528
+
7529
+
7530
+ _GetModelParametersOrDict = Union[_GetModelParameters, _GetModelParametersDict]
7531
+
7532
+
7533
+ class Endpoint(_common.BaseModel):
7534
+ """An endpoint where you deploy models."""
7535
+
7536
+ name: Optional[str] = Field(
7537
+ default=None, description="""Resource name of the endpoint."""
7538
+ )
7539
+ deployed_model_id: Optional[str] = Field(
7540
+ default=None,
7541
+ description="""ID of the model that's deployed to the endpoint.""",
7542
+ )
7543
+
7544
+
7545
+ class EndpointDict(TypedDict, total=False):
7546
+ """An endpoint where you deploy models."""
7547
+
7548
+ name: Optional[str]
7549
+ """Resource name of the endpoint."""
7550
+
7551
+ deployed_model_id: Optional[str]
7552
+ """ID of the model that's deployed to the endpoint."""
7553
+
7554
+
7555
+ EndpointOrDict = Union[Endpoint, EndpointDict]
7556
+
7557
+
7558
+ class TunedModelInfo(_common.BaseModel):
7559
+ """A tuned machine learning model."""
7560
+
7561
+ base_model: Optional[str] = Field(
7562
+ default=None,
7563
+ description="""ID of the base model that you want to tune.""",
7564
+ )
7565
+ create_time: Optional[datetime.datetime] = Field(
7566
+ default=None,
7567
+ description="""Date and time when the base model was created.""",
7568
+ )
7569
+ update_time: Optional[datetime.datetime] = Field(
7570
+ default=None,
7571
+ description="""Date and time when the base model was last updated.""",
7572
+ )
7573
+
7574
+
7575
+ class TunedModelInfoDict(TypedDict, total=False):
7576
+ """A tuned machine learning model."""
7577
+
7578
+ base_model: Optional[str]
7579
+ """ID of the base model that you want to tune."""
7580
+
7581
+ create_time: Optional[datetime.datetime]
7582
+ """Date and time when the base model was created."""
7583
+
7584
+ update_time: Optional[datetime.datetime]
7585
+ """Date and time when the base model was last updated."""
7586
+
7587
+
7588
+ TunedModelInfoOrDict = Union[TunedModelInfo, TunedModelInfoDict]
7589
+
7590
+
7591
+ class Checkpoint(_common.BaseModel):
7592
+ """Describes the machine learning model version checkpoint."""
7593
+
7594
+ checkpoint_id: Optional[str] = Field(
7595
+ default=None,
7596
+ description="""The ID of the checkpoint.
7597
+ """,
7598
+ )
7599
+ epoch: Optional[int] = Field(
7600
+ default=None,
7601
+ description="""The epoch of the checkpoint.
7602
+ """,
7603
+ )
7604
+ step: Optional[int] = Field(
7605
+ default=None,
7606
+ description="""The step of the checkpoint.
7356
7607
  """,
7357
7608
  )
7358
7609
 
@@ -7649,12 +7900,15 @@ _DeleteModelParametersOrDict = Union[
7649
7900
 
7650
7901
  class DeleteModelResponse(_common.BaseModel):
7651
7902
 
7652
- pass
7903
+ sdk_http_response: Optional[HttpResponse] = Field(
7904
+ default=None, description="""Used to retain the full HTTP response."""
7905
+ )
7653
7906
 
7654
7907
 
7655
7908
  class DeleteModelResponseDict(TypedDict, total=False):
7656
7909
 
7657
- pass
7910
+ sdk_http_response: Optional[HttpResponseDict]
7911
+ """Used to retain the full HTTP response."""
7658
7912
 
7659
7913
 
7660
7914
  DeleteModelResponseOrDict = Union[DeleteModelResponse, DeleteModelResponseDict]
@@ -8019,7 +8273,7 @@ class TokensInfo(_common.BaseModel):
8019
8273
 
8020
8274
  role: Optional[str] = Field(
8021
8275
  default=None,
8022
- description="""Optional. Optional fields for the role from the corresponding Content.""",
8276
+ description="""Optional fields for the role from the corresponding Content.""",
8023
8277
  )
8024
8278
  token_ids: Optional[list[int]] = Field(
8025
8279
  default=None, description="""A list of token ids from the input."""
@@ -8033,7 +8287,7 @@ class TokensInfoDict(TypedDict, total=False):
8033
8287
  """Tokens info with a list of tokens and the corresponding list of token ids."""
8034
8288
 
8035
8289
  role: Optional[str]
8036
- """Optional. Optional fields for the role from the corresponding Content."""
8290
+ """Optional fields for the role from the corresponding Content."""
8037
8291
 
8038
8292
  token_ids: Optional[list[int]]
8039
8293
  """A list of token ids from the input."""
@@ -8175,6 +8429,79 @@ class VideoDict(TypedDict, total=False):
8175
8429
  VideoOrDict = Union[Video, VideoDict]
8176
8430
 
8177
8431
 
8432
+ class GenerateVideosSource(_common.BaseModel):
8433
+ """A set of source input(s) for video generation."""
8434
+
8435
+ prompt: Optional[str] = Field(
8436
+ default=None,
8437
+ description="""The text prompt for generating the videos.
8438
+ Optional if image or video is provided.""",
8439
+ )
8440
+ image: Optional[Image] = Field(
8441
+ default=None,
8442
+ description="""The input image for generating the videos.
8443
+ Optional if prompt or video is provided.""",
8444
+ )
8445
+ video: Optional[Video] = Field(
8446
+ default=None,
8447
+ description="""The input video for video extension use cases.
8448
+ Optional if prompt or image is provided.""",
8449
+ )
8450
+
8451
+
8452
+ class GenerateVideosSourceDict(TypedDict, total=False):
8453
+ """A set of source input(s) for video generation."""
8454
+
8455
+ prompt: Optional[str]
8456
+ """The text prompt for generating the videos.
8457
+ Optional if image or video is provided."""
8458
+
8459
+ image: Optional[ImageDict]
8460
+ """The input image for generating the videos.
8461
+ Optional if prompt or video is provided."""
8462
+
8463
+ video: Optional[VideoDict]
8464
+ """The input video for video extension use cases.
8465
+ Optional if prompt or image is provided."""
8466
+
8467
+
8468
+ GenerateVideosSourceOrDict = Union[
8469
+ GenerateVideosSource, GenerateVideosSourceDict
8470
+ ]
8471
+
8472
+
8473
+ class VideoGenerationReferenceImage(_common.BaseModel):
8474
+ """A reference image for video generation."""
8475
+
8476
+ image: Optional[Image] = Field(
8477
+ default=None,
8478
+ description="""The reference image.
8479
+ """,
8480
+ )
8481
+ reference_type: Optional[VideoGenerationReferenceType] = Field(
8482
+ default=None,
8483
+ description="""The type of the reference image, which defines how the reference
8484
+ image will be used to generate the video.""",
8485
+ )
8486
+
8487
+
8488
+ class VideoGenerationReferenceImageDict(TypedDict, total=False):
8489
+ """A reference image for video generation."""
8490
+
8491
+ image: Optional[ImageDict]
8492
+ """The reference image.
8493
+ """
8494
+
8495
+ reference_type: Optional[VideoGenerationReferenceType]
8496
+ """The type of the reference image, which defines how the reference
8497
+ image will be used to generate the video."""
8498
+
8499
+
8500
+ VideoGenerationReferenceImageOrDict = Union[
8501
+ VideoGenerationReferenceImage, VideoGenerationReferenceImageDict
8502
+ ]
8503
+
8504
+
8178
8505
  class GenerateVideosConfig(_common.BaseModel):
8179
8506
  """Configuration for generating videos."""
8180
8507
 
@@ -8230,6 +8557,14 @@ class GenerateVideosConfig(_common.BaseModel):
8230
8557
  default=None,
8231
8558
  description="""Image to use as the last frame of generated videos. Only supported for image to video use cases.""",
8232
8559
  )
8560
+ reference_images: Optional[list[VideoGenerationReferenceImage]] = Field(
8561
+ default=None,
8562
+ description="""The images to use as the references to generate the videos.
8563
+ If this field is provided, the text prompt field must also be provided.
8564
+ The image, video, or last_frame field are not supported. Each image must
8565
+ be associated with a type. Veo 2 supports up to 3 asset images *or* 1
8566
+ style image.""",
8567
+ )
8233
8568
  compression_quality: Optional[VideoCompressionQuality] = Field(
8234
8569
  default=None,
8235
8570
  description="""Compression quality of the generated videos.""",
@@ -8281,6 +8616,13 @@ class GenerateVideosConfigDict(TypedDict, total=False):
8281
8616
  last_frame: Optional[ImageDict]
8282
8617
  """Image to use as the last frame of generated videos. Only supported for image to video use cases."""
8283
8618
 
8619
+ reference_images: Optional[list[VideoGenerationReferenceImageDict]]
8620
+ """The images to use as the references to generate the videos.
8621
+ If this field is provided, the text prompt field must also be provided.
8622
+ The image, video, or last_frame field are not supported. Each image must
8623
+ be associated with a type. Veo 2 supports up to 3 asset images *or* 1
8624
+ style image."""
8625
+
8284
8626
  compression_quality: Optional[VideoCompressionQuality]
8285
8627
  """Compression quality of the generated videos."""
8286
8628
 
@@ -8312,6 +8654,10 @@ class _GenerateVideosParameters(_common.BaseModel):
8312
8654
  description="""The input video for video extension use cases.
8313
8655
  Optional if prompt or image is provided.""",
8314
8656
  )
8657
+ source: Optional[GenerateVideosSource] = Field(
8658
+ default=None,
8659
+ description="""A set of source input(s) for video generation.""",
8660
+ )
8315
8661
  config: Optional[GenerateVideosConfig] = Field(
8316
8662
  default=None, description="""Configuration for generating videos."""
8317
8663
  )
@@ -8335,6 +8681,9 @@ class _GenerateVideosParametersDict(TypedDict, total=False):
8335
8681
  """The input video for video extension use cases.
8336
8682
  Optional if prompt or image is provided."""
8337
8683
 
8684
+ source: Optional[GenerateVideosSourceDict]
8685
+ """A set of source input(s) for video generation."""
8686
+
8338
8687
  config: Optional[GenerateVideosConfigDict]
8339
8688
  """Configuration for generating videos."""
8340
8689
 
@@ -8377,6 +8726,24 @@ class GenerateVideosResponse(_common.BaseModel):
8377
8726
  )
8378
8727
 
8379
8728
 
8729
+ class GenerateVideosResponseDict(TypedDict, total=False):
8730
+ """Response with generated videos."""
8731
+
8732
+ generated_videos: Optional[list[GeneratedVideoDict]]
8733
+ """List of the generated videos"""
8734
+
8735
+ rai_media_filtered_count: Optional[int]
8736
+ """Returns if any videos were filtered due to RAI policies."""
8737
+
8738
+ rai_media_filtered_reasons: Optional[list[str]]
8739
+ """Returns rai failure reasons if any."""
8740
+
8741
+
8742
+ GenerateVideosResponseOrDict = Union[
8743
+ GenerateVideosResponse, GenerateVideosResponseDict
8744
+ ]
8745
+
8746
+
8380
8747
  class Operation(ABC):
8381
8748
  """A long-running operation."""
8382
8749
 
@@ -8412,7 +8779,6 @@ class GenerateVideosOperation(_common.BaseModel, Operation):
8412
8779
  response: Optional[GenerateVideosResponse] = Field(
8413
8780
  default=None, description="""The generated videos."""
8414
8781
  )
8415
-
8416
8782
  result: Optional[GenerateVideosResponse] = Field(
8417
8783
  default=None, description="""The generated videos."""
8418
8784
  )
@@ -8422,76 +8788,12 @@ class GenerateVideosOperation(_common.BaseModel, Operation):
8422
8788
  cls, api_response: Any, is_vertex_ai: bool = False
8423
8789
  ) -> Self:
8424
8790
  """Instantiates a GenerateVideosOperation from an API response."""
8425
- new_operation = cls()
8426
- new_operation.name = api_response.get('name', None)
8427
- new_operation.metadata = api_response.get('metadata', None)
8428
- new_operation.done = api_response.get('done', None)
8429
- new_operation.error = api_response.get('error', None)
8430
-
8431
8791
  if is_vertex_ai:
8432
- if api_response.get('response', None) is not None:
8433
- new_operation.response = GenerateVideosResponse(
8434
- generated_videos=[
8435
- GeneratedVideo(
8436
- video=Video(
8437
- uri=video.get('gcsUri', None),
8438
- video_bytes=video.get('bytesBase64Encoded', None),
8439
- mime_type=video.get('mimeType', None),
8440
- )
8441
- )
8442
- for video in api_response.get('response', {}).get('videos', [])
8443
- ],
8444
- rai_media_filtered_count=api_response.get('response', {}).get(
8445
- 'raiMediaFilteredCount', None
8446
- ),
8447
- rai_media_filtered_reasons=api_response.get('response', {}).get(
8448
- 'raiMediaFilteredReasons', None
8449
- ),
8450
- )
8792
+ response_dict = _GenerateVideosOperation_from_vertex(api_response)
8451
8793
  else:
8452
- if api_response.get('response', None) is not None:
8453
- new_operation.response = GenerateVideosResponse(
8454
- generated_videos=[
8455
- GeneratedVideo(
8456
- video=Video(
8457
- uri=video.get('video', {}).get('uri', None),
8458
- video_bytes=video.get('video', {}).get(
8459
- 'encodedVideo', None
8460
- ),
8461
- mime_type=video.get('encoding', None),
8462
- )
8463
- )
8464
- for video in api_response.get('response', {})
8465
- .get('generateVideoResponse', {})
8466
- .get('generatedSamples', [])
8467
- ],
8468
- rai_media_filtered_count=api_response.get('response', {})
8469
- .get('generateVideoResponse', {})
8470
- .get('raiMediaFilteredCount', None),
8471
- rai_media_filtered_reasons=api_response.get('response', {})
8472
- .get('generateVideoResponse', {})
8473
- .get('raiMediaFilteredReasons', None),
8474
- )
8475
- new_operation.result = new_operation.response
8476
- return new_operation
8477
-
8478
-
8479
- class GenerateVideosResponseDict(TypedDict, total=False):
8480
- """Response with generated videos."""
8481
-
8482
- generated_videos: Optional[list[GeneratedVideoDict]]
8483
- """List of the generated videos"""
8484
-
8485
- rai_media_filtered_count: Optional[int]
8486
- """Returns if any videos were filtered due to RAI policies."""
8487
-
8488
- rai_media_filtered_reasons: Optional[list[str]]
8489
- """Returns rai failure reasons if any."""
8490
-
8794
+ response_dict = _GenerateVideosOperation_from_mldev(api_response)
8491
8795
 
8492
- GenerateVideosResponseOrDict = Union[
8493
- GenerateVideosResponse, GenerateVideosResponseDict
8494
- ]
8796
+ return cls._from_response(response=response_dict, kwargs={})
8495
8797
 
8496
8798
 
8497
8799
  class GetTuningJobConfig(_common.BaseModel):
@@ -9965,13 +10267,59 @@ ListTuningJobsResponseOrDict = Union[
9965
10267
  ]
9966
10268
 
9967
10269
 
9968
- class TuningExample(_common.BaseModel):
10270
+ class CancelTuningJobConfig(_common.BaseModel):
10271
+ """Optional parameters for tunings.cancel method."""
9969
10272
 
9970
- text_input: Optional[str] = Field(
9971
- default=None, description="""Text model input."""
10273
+ http_options: Optional[HttpOptions] = Field(
10274
+ default=None, description="""Used to override HTTP request options."""
9972
10275
  )
9973
- output: Optional[str] = Field(
9974
- default=None, description="""The expected model output."""
10276
+
10277
+
10278
+ class CancelTuningJobConfigDict(TypedDict, total=False):
10279
+ """Optional parameters for tunings.cancel method."""
10280
+
10281
+ http_options: Optional[HttpOptionsDict]
10282
+ """Used to override HTTP request options."""
10283
+
10284
+
10285
+ CancelTuningJobConfigOrDict = Union[
10286
+ CancelTuningJobConfig, CancelTuningJobConfigDict
10287
+ ]
10288
+
10289
+
10290
+ class _CancelTuningJobParameters(_common.BaseModel):
10291
+ """Parameters for the cancel method."""
10292
+
10293
+ name: Optional[str] = Field(
10294
+ default=None, description="""The resource name of the tuning job."""
10295
+ )
10296
+ config: Optional[CancelTuningJobConfig] = Field(
10297
+ default=None, description="""Optional parameters for the request."""
10298
+ )
10299
+
10300
+
10301
+ class _CancelTuningJobParametersDict(TypedDict, total=False):
10302
+ """Parameters for the cancel method."""
10303
+
10304
+ name: Optional[str]
10305
+ """The resource name of the tuning job."""
10306
+
10307
+ config: Optional[CancelTuningJobConfigDict]
10308
+ """Optional parameters for the request."""
10309
+
10310
+
10311
+ _CancelTuningJobParametersOrDict = Union[
10312
+ _CancelTuningJobParameters, _CancelTuningJobParametersDict
10313
+ ]
10314
+
10315
+
10316
+ class TuningExample(_common.BaseModel):
10317
+
10318
+ text_input: Optional[str] = Field(
10319
+ default=None, description="""Text model input."""
10320
+ )
10321
+ output: Optional[str] = Field(
10322
+ default=None, description="""The expected model output."""
9975
10323
  )
9976
10324
 
9977
10325
 
@@ -10569,13 +10917,16 @@ _DeleteCachedContentParametersOrDict = Union[
10569
10917
  class DeleteCachedContentResponse(_common.BaseModel):
10570
10918
  """Empty response for caches.delete method."""
10571
10919
 
10572
- pass
10920
+ sdk_http_response: Optional[HttpResponse] = Field(
10921
+ default=None, description="""Used to retain the full HTTP response."""
10922
+ )
10573
10923
 
10574
10924
 
10575
10925
  class DeleteCachedContentResponseDict(TypedDict, total=False):
10576
10926
  """Empty response for caches.delete method."""
10577
10927
 
10578
- pass
10928
+ sdk_http_response: Optional[HttpResponseDict]
10929
+ """Used to retain the full HTTP response."""
10579
10930
 
10580
10931
 
10581
10932
  DeleteCachedContentResponseOrDict = Union[
@@ -10980,13 +11331,16 @@ _DeleteFileParametersOrDict = Union[
10980
11331
  class DeleteFileResponse(_common.BaseModel):
10981
11332
  """Response for the delete file method."""
10982
11333
 
10983
- pass
11334
+ sdk_http_response: Optional[HttpResponse] = Field(
11335
+ default=None, description="""Used to retain the full HTTP response."""
11336
+ )
10984
11337
 
10985
11338
 
10986
11339
  class DeleteFileResponseDict(TypedDict, total=False):
10987
11340
  """Response for the delete file method."""
10988
11341
 
10989
- pass
11342
+ sdk_http_response: Optional[HttpResponseDict]
11343
+ """Used to retain the full HTTP response."""
10990
11344
 
10991
11345
 
10992
11346
  DeleteFileResponseOrDict = Union[DeleteFileResponse, DeleteFileResponseDict]
@@ -12053,6 +12407,10 @@ class UpscaleImageConfig(_common.BaseModel):
12053
12407
  http_options: Optional[HttpOptions] = Field(
12054
12408
  default=None, description="""Used to override HTTP request options."""
12055
12409
  )
12410
+ output_gcs_uri: Optional[str] = Field(
12411
+ default=None,
12412
+ description="""Cloud Storage URI used to store the generated images.""",
12413
+ )
12056
12414
  include_rai_reason: Optional[bool] = Field(
12057
12415
  default=None,
12058
12416
  description="""Whether to include a reason for filtered-out images in the
@@ -12093,6 +12451,9 @@ class UpscaleImageConfigDict(TypedDict, total=False):
12093
12451
  http_options: Optional[HttpOptionsDict]
12094
12452
  """Used to override HTTP request options."""
12095
12453
 
12454
+ output_gcs_uri: Optional[str]
12455
+ """Cloud Storage URI used to store the generated images."""
12456
+
12096
12457
  include_rai_reason: Optional[bool]
12097
12458
  """Whether to include a reason for filtered-out images in the
12098
12459
  response."""
@@ -12964,95 +13325,6 @@ class LiveServerMessageDict(TypedDict, total=False):
12964
13325
  LiveServerMessageOrDict = Union[LiveServerMessage, LiveServerMessageDict]
12965
13326
 
12966
13327
 
12967
- class AutomaticActivityDetection(_common.BaseModel):
12968
- """Configures automatic detection of activity."""
12969
-
12970
- disabled: Optional[bool] = Field(
12971
- default=None,
12972
- description="""If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals.""",
12973
- )
12974
- start_of_speech_sensitivity: Optional[StartSensitivity] = Field(
12975
- default=None,
12976
- description="""Determines how likely speech is to be detected.""",
12977
- )
12978
- end_of_speech_sensitivity: Optional[EndSensitivity] = Field(
12979
- default=None,
12980
- description="""Determines how likely detected speech is ended.""",
12981
- )
12982
- prefix_padding_ms: Optional[int] = Field(
12983
- default=None,
12984
- 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.""",
12985
- )
12986
- silence_duration_ms: Optional[int] = Field(
12987
- default=None,
12988
- 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.""",
12989
- )
12990
-
12991
-
12992
- class AutomaticActivityDetectionDict(TypedDict, total=False):
12993
- """Configures automatic detection of activity."""
12994
-
12995
- disabled: Optional[bool]
12996
- """If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals."""
12997
-
12998
- start_of_speech_sensitivity: Optional[StartSensitivity]
12999
- """Determines how likely speech is to be detected."""
13000
-
13001
- end_of_speech_sensitivity: Optional[EndSensitivity]
13002
- """Determines how likely detected speech is ended."""
13003
-
13004
- prefix_padding_ms: Optional[int]
13005
- """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."""
13006
-
13007
- silence_duration_ms: Optional[int]
13008
- """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."""
13009
-
13010
-
13011
- AutomaticActivityDetectionOrDict = Union[
13012
- AutomaticActivityDetection, AutomaticActivityDetectionDict
13013
- ]
13014
-
13015
-
13016
- class RealtimeInputConfig(_common.BaseModel):
13017
- """Marks the end of user activity.
13018
-
13019
- This can only be sent if automatic (i.e. server-side) activity detection is
13020
- disabled.
13021
- """
13022
-
13023
- automatic_activity_detection: Optional[AutomaticActivityDetection] = Field(
13024
- default=None,
13025
- description="""If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.""",
13026
- )
13027
- activity_handling: Optional[ActivityHandling] = Field(
13028
- default=None, description="""Defines what effect activity has."""
13029
- )
13030
- turn_coverage: Optional[TurnCoverage] = Field(
13031
- default=None,
13032
- description="""Defines which input is included in the user's turn.""",
13033
- )
13034
-
13035
-
13036
- class RealtimeInputConfigDict(TypedDict, total=False):
13037
- """Marks the end of user activity.
13038
-
13039
- This can only be sent if automatic (i.e. server-side) activity detection is
13040
- disabled.
13041
- """
13042
-
13043
- automatic_activity_detection: Optional[AutomaticActivityDetectionDict]
13044
- """If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals."""
13045
-
13046
- activity_handling: Optional[ActivityHandling]
13047
- """Defines what effect activity has."""
13048
-
13049
- turn_coverage: Optional[TurnCoverage]
13050
- """Defines which input is included in the user's turn."""
13051
-
13052
-
13053
- RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict]
13054
-
13055
-
13056
13328
  class SessionResumptionConfig(_common.BaseModel):
13057
13329
  """Configuration of session resumption mechanism.
13058
13330
 
@@ -13191,6 +13463,95 @@ class ProactivityConfigDict(TypedDict, total=False):
13191
13463
  ProactivityConfigOrDict = Union[ProactivityConfig, ProactivityConfigDict]
13192
13464
 
13193
13465
 
13466
+ class AutomaticActivityDetection(_common.BaseModel):
13467
+ """Configures automatic detection of activity."""
13468
+
13469
+ disabled: Optional[bool] = Field(
13470
+ default=None,
13471
+ description="""If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals.""",
13472
+ )
13473
+ start_of_speech_sensitivity: Optional[StartSensitivity] = Field(
13474
+ default=None,
13475
+ description="""Determines how likely speech is to be detected.""",
13476
+ )
13477
+ end_of_speech_sensitivity: Optional[EndSensitivity] = Field(
13478
+ default=None,
13479
+ description="""Determines how likely detected speech is ended.""",
13480
+ )
13481
+ prefix_padding_ms: Optional[int] = Field(
13482
+ default=None,
13483
+ 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.""",
13484
+ )
13485
+ silence_duration_ms: Optional[int] = Field(
13486
+ default=None,
13487
+ 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.""",
13488
+ )
13489
+
13490
+
13491
+ class AutomaticActivityDetectionDict(TypedDict, total=False):
13492
+ """Configures automatic detection of activity."""
13493
+
13494
+ disabled: Optional[bool]
13495
+ """If enabled, detected voice and text input count as activity. If disabled, the client must send activity signals."""
13496
+
13497
+ start_of_speech_sensitivity: Optional[StartSensitivity]
13498
+ """Determines how likely speech is to be detected."""
13499
+
13500
+ end_of_speech_sensitivity: Optional[EndSensitivity]
13501
+ """Determines how likely detected speech is ended."""
13502
+
13503
+ prefix_padding_ms: Optional[int]
13504
+ """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."""
13505
+
13506
+ silence_duration_ms: Optional[int]
13507
+ """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."""
13508
+
13509
+
13510
+ AutomaticActivityDetectionOrDict = Union[
13511
+ AutomaticActivityDetection, AutomaticActivityDetectionDict
13512
+ ]
13513
+
13514
+
13515
+ class RealtimeInputConfig(_common.BaseModel):
13516
+ """Marks the end of user activity.
13517
+
13518
+ This can only be sent if automatic (i.e. server-side) activity detection is
13519
+ disabled.
13520
+ """
13521
+
13522
+ automatic_activity_detection: Optional[AutomaticActivityDetection] = Field(
13523
+ default=None,
13524
+ description="""If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals.""",
13525
+ )
13526
+ activity_handling: Optional[ActivityHandling] = Field(
13527
+ default=None, description="""Defines what effect activity has."""
13528
+ )
13529
+ turn_coverage: Optional[TurnCoverage] = Field(
13530
+ default=None,
13531
+ description="""Defines which input is included in the user's turn.""",
13532
+ )
13533
+
13534
+
13535
+ class RealtimeInputConfigDict(TypedDict, total=False):
13536
+ """Marks the end of user activity.
13537
+
13538
+ This can only be sent if automatic (i.e. server-side) activity detection is
13539
+ disabled.
13540
+ """
13541
+
13542
+ automatic_activity_detection: Optional[AutomaticActivityDetectionDict]
13543
+ """If not set, automatic activity detection is enabled by default. If automatic voice detection is disabled, the client must send activity signals."""
13544
+
13545
+ activity_handling: Optional[ActivityHandling]
13546
+ """Defines what effect activity has."""
13547
+
13548
+ turn_coverage: Optional[TurnCoverage]
13549
+ """Defines which input is included in the user's turn."""
13550
+
13551
+
13552
+ RealtimeInputConfigOrDict = Union[RealtimeInputConfig, RealtimeInputConfigDict]
13553
+
13554
+
13194
13555
  class LiveClientSetup(_common.BaseModel):
13195
13556
  """Message contains configuration that will apply for the duration of the streaming session."""
13196
13557
 
@@ -14509,6 +14870,42 @@ CreateAuthTokenParametersOrDict = Union[
14509
14870
  ]
14510
14871
 
14511
14872
 
14873
+ class CountTokensResult(_common.BaseModel):
14874
+ """Local tokenizer count tokens result."""
14875
+
14876
+ total_tokens: Optional[int] = Field(
14877
+ default=None, description="""The total number of tokens."""
14878
+ )
14879
+
14880
+
14881
+ class CountTokensResultDict(TypedDict, total=False):
14882
+ """Local tokenizer count tokens result."""
14883
+
14884
+ total_tokens: Optional[int]
14885
+ """The total number of tokens."""
14886
+
14887
+
14888
+ CountTokensResultOrDict = Union[CountTokensResult, CountTokensResultDict]
14889
+
14890
+
14891
+ class ComputeTokensResult(_common.BaseModel):
14892
+ """Local tokenizer compute tokens result."""
14893
+
14894
+ tokens_info: Optional[list[TokensInfo]] = Field(
14895
+ default=None, description="""Lists of tokens info from the input."""
14896
+ )
14897
+
14898
+
14899
+ class ComputeTokensResultDict(TypedDict, total=False):
14900
+ """Local tokenizer compute tokens result."""
14901
+
14902
+ tokens_info: Optional[list[TokensInfoDict]]
14903
+ """Lists of tokens info from the input."""
14904
+
14905
+
14906
+ ComputeTokensResultOrDict = Union[ComputeTokensResult, ComputeTokensResultDict]
14907
+
14908
+
14512
14909
  class CreateTuningJobParameters(_common.BaseModel):
14513
14910
  """Supervised fine-tuning job creation parameters - optional fields."""
14514
14911
 
@@ -14543,6 +14940,67 @@ CreateTuningJobParametersOrDict = Union[
14543
14940
  ]
14544
14941
 
14545
14942
 
14943
+ class UserContent(Content):
14944
+ """UserContent facilitates the creation of a Content object with a user role.
14945
+
14946
+ Example usages:
14947
+
14948
+
14949
+ - Create a user Content object with a string:
14950
+ user_content = UserContent("Why is the sky blue?")
14951
+ - Create a user Content object with a file data Part object:
14952
+ user_content = UserContent(Part.from_uri(file_uril="gs://bucket/file.txt",
14953
+ mime_type="text/plain"))
14954
+ - Create a user Content object with byte data Part object:
14955
+ user_content = UserContent(Part.from_bytes(data=b"Hello, World!",
14956
+ mime_type="text/plain"))
14957
+
14958
+ You can create a user Content object using other classmethods in the Part
14959
+ class as well.
14960
+ You can also create a user Content using a list of Part objects or strings.
14961
+ """
14962
+
14963
+ role: Literal['user'] = Field(default='user', init=False, frozen=True)
14964
+ parts: list[Part] = Field()
14965
+
14966
+ def __init__(
14967
+ self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]
14968
+ ):
14969
+ from . import _transformers as t
14970
+
14971
+ super().__init__(parts=t.t_parts(parts=parts))
14972
+
14973
+
14974
+ class ModelContent(Content):
14975
+ """ModelContent facilitates the creation of a Content object with a model role.
14976
+
14977
+ Example usages:
14978
+
14979
+ - Create a model Content object with a string:
14980
+ model_content = ModelContent("Why is the sky blue?")
14981
+ - Create a model Content object with a file data Part object:
14982
+ model_content = ModelContent(Part.from_uri(file_uril="gs://bucket/file.txt",
14983
+ mime_type="text/plain"))
14984
+ - Create a model Content object with byte data Part object:
14985
+ model_content = ModelContent(Part.from_bytes(data=b"Hello, World!",
14986
+ mime_type="text/plain"))
14987
+
14988
+ You can create a model Content object using other classmethods in the Part
14989
+ class as well.
14990
+ You can also create a model Content using a list of Part objects or strings.
14991
+ """
14992
+
14993
+ role: Literal['model'] = Field(default='model', init=False, frozen=True)
14994
+ parts: list[Part] = Field()
14995
+
14996
+ def __init__(
14997
+ self, parts: Union['PartUnionDict', list['PartUnionDict'], list['Part']]
14998
+ ):
14999
+ from . import _transformers as t
15000
+
15001
+ super().__init__(parts=t.t_parts(parts=parts))
15002
+
15003
+
14546
15004
  class CustomOutputFormatConfig(_common.BaseModel):
14547
15005
  """Config for custom output format."""
14548
15006