google-genai 0.4.0__py3-none-any.whl → 0.6.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
@@ -13,207 +13,301 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ # Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17
+
16
18
  import datetime
17
19
  import inspect
18
20
  import json
19
21
  import logging
20
- from typing import Any, Callable, Literal, Optional, TypedDict, Union
22
+ from typing import Any, Callable, GenericAlias, Literal, Optional, TypedDict, Union
21
23
  import PIL.Image
22
24
  import pydantic
23
25
  from pydantic import Field
24
26
  from . import _common
25
27
 
26
28
 
27
- Outcome = Literal[
28
- "OUTCOME_UNSPECIFIED",
29
- "OUTCOME_OK",
30
- "OUTCOME_FAILED",
31
- "OUTCOME_DEADLINE_EXCEEDED",
32
- ]
29
+ class Outcome(_common.CaseInSensitiveEnum):
30
+ """Required. Outcome of the code execution."""
33
31
 
32
+ OUTCOME_UNSPECIFIED = 'OUTCOME_UNSPECIFIED'
33
+ OUTCOME_OK = 'OUTCOME_OK'
34
+ OUTCOME_FAILED = 'OUTCOME_FAILED'
35
+ OUTCOME_DEADLINE_EXCEEDED = 'OUTCOME_DEADLINE_EXCEEDED'
34
36
 
35
- Language = Literal["LANGUAGE_UNSPECIFIED", "PYTHON"]
36
37
 
38
+ class Language(_common.CaseInSensitiveEnum):
39
+ """Required. Programming language of the `code`."""
37
40
 
38
- Type = Literal[
39
- "TYPE_UNSPECIFIED",
40
- "STRING",
41
- "NUMBER",
42
- "INTEGER",
43
- "BOOLEAN",
44
- "ARRAY",
45
- "OBJECT",
46
- ]
41
+ LANGUAGE_UNSPECIFIED = 'LANGUAGE_UNSPECIFIED'
42
+ PYTHON = 'PYTHON'
47
43
 
48
44
 
49
- HarmCategory = Literal[
50
- "HARM_CATEGORY_UNSPECIFIED",
51
- "HARM_CATEGORY_HATE_SPEECH",
52
- "HARM_CATEGORY_DANGEROUS_CONTENT",
53
- "HARM_CATEGORY_HARASSMENT",
54
- "HARM_CATEGORY_SEXUALLY_EXPLICIT",
55
- "HARM_CATEGORY_CIVIC_INTEGRITY",
56
- ]
45
+ class Type(_common.CaseInSensitiveEnum):
46
+ """A basic data type."""
57
47
 
48
+ TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'
49
+ STRING = 'STRING'
50
+ NUMBER = 'NUMBER'
51
+ INTEGER = 'INTEGER'
52
+ BOOLEAN = 'BOOLEAN'
53
+ ARRAY = 'ARRAY'
54
+ OBJECT = 'OBJECT'
58
55
 
59
- HarmBlockMethod = Literal[
60
- "HARM_BLOCK_METHOD_UNSPECIFIED", "SEVERITY", "PROBABILITY"
61
- ]
62
56
 
57
+ class HarmCategory(_common.CaseInSensitiveEnum):
58
+ """Required. Harm category."""
63
59
 
64
- HarmBlockThreshold = Literal[
65
- "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
66
- "BLOCK_LOW_AND_ABOVE",
67
- "BLOCK_MEDIUM_AND_ABOVE",
68
- "BLOCK_ONLY_HIGH",
69
- "BLOCK_NONE",
70
- "OFF",
71
- ]
60
+ HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED'
61
+ HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH'
62
+ HARM_CATEGORY_DANGEROUS_CONTENT = 'HARM_CATEGORY_DANGEROUS_CONTENT'
63
+ HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT'
64
+ HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT'
65
+ HARM_CATEGORY_CIVIC_INTEGRITY = 'HARM_CATEGORY_CIVIC_INTEGRITY'
72
66
 
73
67
 
74
- Mode = Literal["MODE_UNSPECIFIED", "MODE_DYNAMIC"]
68
+ class HarmBlockMethod(_common.CaseInSensitiveEnum):
69
+ """Optional.
75
70
 
71
+ Specify if the threshold is used for probability or severity score. If not
72
+ specified, the threshold is used for probability score.
73
+ """
76
74
 
77
- FinishReason = Literal[
78
- "FINISH_REASON_UNSPECIFIED",
79
- "STOP",
80
- "MAX_TOKENS",
81
- "SAFETY",
82
- "RECITATION",
83
- "OTHER",
84
- "BLOCKLIST",
85
- "PROHIBITED_CONTENT",
86
- "SPII",
87
- "MALFORMED_FUNCTION_CALL",
88
- ]
75
+ HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED'
76
+ SEVERITY = 'SEVERITY'
77
+ PROBABILITY = 'PROBABILITY'
89
78
 
90
79
 
91
- HarmProbability = Literal[
92
- "HARM_PROBABILITY_UNSPECIFIED", "NEGLIGIBLE", "LOW", "MEDIUM", "HIGH"
93
- ]
80
+ class HarmBlockThreshold(_common.CaseInSensitiveEnum):
81
+ """Required. The harm block threshold."""
94
82
 
83
+ HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED'
84
+ BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'
85
+ BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'
86
+ BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'
87
+ BLOCK_NONE = 'BLOCK_NONE'
88
+ OFF = 'OFF'
95
89
 
96
- HarmSeverity = Literal[
97
- "HARM_SEVERITY_UNSPECIFIED",
98
- "HARM_SEVERITY_NEGLIGIBLE",
99
- "HARM_SEVERITY_LOW",
100
- "HARM_SEVERITY_MEDIUM",
101
- "HARM_SEVERITY_HIGH",
102
- ]
103
90
 
91
+ class Mode(_common.CaseInSensitiveEnum):
92
+ """The mode of the predictor to be used in dynamic retrieval."""
104
93
 
105
- BlockedReason = Literal[
106
- "BLOCKED_REASON_UNSPECIFIED",
107
- "SAFETY",
108
- "OTHER",
109
- "BLOCKLIST",
110
- "PROHIBITED_CONTENT",
111
- ]
94
+ MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
95
+ MODE_DYNAMIC = 'MODE_DYNAMIC'
112
96
 
113
97
 
114
- DeploymentResourcesType = Literal[
115
- "DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED",
116
- "DEDICATED_RESOURCES",
117
- "AUTOMATIC_RESOURCES",
118
- "SHARED_RESOURCES",
119
- ]
98
+ class State(_common.CaseInSensitiveEnum):
99
+ """Output only. RagFile state."""
120
100
 
101
+ STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
102
+ ACTIVE = 'ACTIVE'
103
+ ERROR = 'ERROR'
121
104
 
122
- JobState = Literal[
123
- "JOB_STATE_UNSPECIFIED",
124
- "JOB_STATE_QUEUED",
125
- "JOB_STATE_PENDING",
126
- "JOB_STATE_RUNNING",
127
- "JOB_STATE_SUCCEEDED",
128
- "JOB_STATE_FAILED",
129
- "JOB_STATE_CANCELLING",
130
- "JOB_STATE_CANCELLED",
131
- "JOB_STATE_PAUSED",
132
- "JOB_STATE_EXPIRED",
133
- "JOB_STATE_UPDATING",
134
- "JOB_STATE_PARTIALLY_SUCCEEDED",
135
- ]
136
105
 
106
+ class FinishReason(_common.CaseInSensitiveEnum):
107
+ """Output only.
137
108
 
138
- AdapterSize = Literal[
139
- "ADAPTER_SIZE_UNSPECIFIED",
140
- "ADAPTER_SIZE_ONE",
141
- "ADAPTER_SIZE_FOUR",
142
- "ADAPTER_SIZE_EIGHT",
143
- "ADAPTER_SIZE_SIXTEEN",
144
- "ADAPTER_SIZE_THIRTY_TWO",
145
- ]
109
+ The reason why the model stopped generating tokens. If empty, the model has
110
+ not stopped generating the tokens.
111
+ """
146
112
 
113
+ FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED'
114
+ STOP = 'STOP'
115
+ MAX_TOKENS = 'MAX_TOKENS'
116
+ SAFETY = 'SAFETY'
117
+ RECITATION = 'RECITATION'
118
+ OTHER = 'OTHER'
119
+ BLOCKLIST = 'BLOCKLIST'
120
+ PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
121
+ SPII = 'SPII'
122
+ MALFORMED_FUNCTION_CALL = 'MALFORMED_FUNCTION_CALL'
147
123
 
148
- State = Literal["STATE_UNSPECIFIED", "ACTIVE", "ERROR"]
149
124
 
125
+ class HarmProbability(_common.CaseInSensitiveEnum):
126
+ """Output only. Harm probability levels in the content."""
150
127
 
151
- DynamicRetrievalConfigMode = Literal["MODE_UNSPECIFIED", "MODE_DYNAMIC"]
128
+ HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED'
129
+ NEGLIGIBLE = 'NEGLIGIBLE'
130
+ LOW = 'LOW'
131
+ MEDIUM = 'MEDIUM'
132
+ HIGH = 'HIGH'
152
133
 
153
134
 
154
- FunctionCallingConfigMode = Literal["MODE_UNSPECIFIED", "AUTO", "ANY", "NONE"]
135
+ class HarmSeverity(_common.CaseInSensitiveEnum):
136
+ """Output only. Harm severity levels in the content."""
155
137
 
138
+ HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED'
139
+ HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE'
140
+ HARM_SEVERITY_LOW = 'HARM_SEVERITY_LOW'
141
+ HARM_SEVERITY_MEDIUM = 'HARM_SEVERITY_MEDIUM'
142
+ HARM_SEVERITY_HIGH = 'HARM_SEVERITY_HIGH'
156
143
 
157
- MediaResolution = Literal[
158
- "MEDIA_RESOLUTION_UNSPECIFIED",
159
- "MEDIA_RESOLUTION_LOW",
160
- "MEDIA_RESOLUTION_MEDIUM",
161
- "MEDIA_RESOLUTION_HIGH",
162
- ]
163
144
 
145
+ class BlockedReason(_common.CaseInSensitiveEnum):
146
+ """Output only. Blocked reason."""
164
147
 
165
- SafetyFilterLevel = Literal[
166
- "BLOCK_LOW_AND_ABOVE",
167
- "BLOCK_MEDIUM_AND_ABOVE",
168
- "BLOCK_ONLY_HIGH",
169
- "BLOCK_NONE",
170
- ]
148
+ BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED'
149
+ SAFETY = 'SAFETY'
150
+ OTHER = 'OTHER'
151
+ BLOCKLIST = 'BLOCKLIST'
152
+ PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
171
153
 
172
154
 
173
- PersonGeneration = Literal["DONT_ALLOW", "ALLOW_ADULT", "ALLOW_ALL"]
155
+ class DeploymentResourcesType(_common.CaseInSensitiveEnum):
156
+ """"""
174
157
 
158
+ DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED = (
159
+ 'DEPLOYMENT_RESOURCES_TYPE_UNSPECIFIED'
160
+ )
161
+ DEDICATED_RESOURCES = 'DEDICATED_RESOURCES'
162
+ AUTOMATIC_RESOURCES = 'AUTOMATIC_RESOURCES'
163
+ SHARED_RESOURCES = 'SHARED_RESOURCES'
175
164
 
176
- ImagePromptLanguage = Literal["auto", "en", "ja", "ko", "hi"]
177
165
 
166
+ class JobState(_common.CaseInSensitiveEnum):
167
+ """Config class for the job state."""
178
168
 
179
- MaskReferenceMode = Literal[
180
- "MASK_MODE_DEFAULT",
181
- "MASK_MODE_USER_PROVIDED",
182
- "MASK_MODE_BACKGROUND",
183
- "MASK_MODE_FOREGROUND",
184
- "MASK_MODE_SEMANTIC",
185
- ]
169
+ JOB_STATE_UNSPECIFIED = 'JOB_STATE_UNSPECIFIED'
170
+ JOB_STATE_QUEUED = 'JOB_STATE_QUEUED'
171
+ JOB_STATE_PENDING = 'JOB_STATE_PENDING'
172
+ JOB_STATE_RUNNING = 'JOB_STATE_RUNNING'
173
+ JOB_STATE_SUCCEEDED = 'JOB_STATE_SUCCEEDED'
174
+ JOB_STATE_FAILED = 'JOB_STATE_FAILED'
175
+ JOB_STATE_CANCELLING = 'JOB_STATE_CANCELLING'
176
+ JOB_STATE_CANCELLED = 'JOB_STATE_CANCELLED'
177
+ JOB_STATE_PAUSED = 'JOB_STATE_PAUSED'
178
+ JOB_STATE_EXPIRED = 'JOB_STATE_EXPIRED'
179
+ JOB_STATE_UPDATING = 'JOB_STATE_UPDATING'
180
+ JOB_STATE_PARTIALLY_SUCCEEDED = 'JOB_STATE_PARTIALLY_SUCCEEDED'
186
181
 
187
182
 
188
- ControlReferenceType = Literal[
189
- "CONTROL_TYPE_DEFAULT",
190
- "CONTROL_TYPE_CANNY",
191
- "CONTROL_TYPE_SCRIBBLE",
192
- "CONTROL_TYPE_FACE_MESH",
193
- ]
183
+ class AdapterSize(_common.CaseInSensitiveEnum):
184
+ """Optional. Adapter size for tuning."""
194
185
 
186
+ ADAPTER_SIZE_UNSPECIFIED = 'ADAPTER_SIZE_UNSPECIFIED'
187
+ ADAPTER_SIZE_ONE = 'ADAPTER_SIZE_ONE'
188
+ ADAPTER_SIZE_FOUR = 'ADAPTER_SIZE_FOUR'
189
+ ADAPTER_SIZE_EIGHT = 'ADAPTER_SIZE_EIGHT'
190
+ ADAPTER_SIZE_SIXTEEN = 'ADAPTER_SIZE_SIXTEEN'
191
+ ADAPTER_SIZE_THIRTY_TWO = 'ADAPTER_SIZE_THIRTY_TWO'
195
192
 
196
- SubjectReferenceType = Literal[
197
- "SUBJECT_TYPE_DEFAULT",
198
- "SUBJECT_TYPE_PERSON",
199
- "SUBJECT_TYPE_ANIMAL",
200
- "SUBJECT_TYPE_PRODUCT",
201
- ]
202
193
 
194
+ class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
195
+ """Config class for the dynamic retrieval config mode."""
196
+
197
+ MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
198
+ MODE_DYNAMIC = 'MODE_DYNAMIC'
199
+
200
+
201
+ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
202
+ """Config class for the function calling config mode."""
203
+
204
+ MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
205
+ AUTO = 'AUTO'
206
+ ANY = 'ANY'
207
+ NONE = 'NONE'
208
+
209
+
210
+ class MediaResolution(_common.CaseInSensitiveEnum):
211
+ """The media resolution to use."""
212
+
213
+ MEDIA_RESOLUTION_UNSPECIFIED = 'MEDIA_RESOLUTION_UNSPECIFIED'
214
+ MEDIA_RESOLUTION_LOW = 'MEDIA_RESOLUTION_LOW'
215
+ MEDIA_RESOLUTION_MEDIUM = 'MEDIA_RESOLUTION_MEDIUM'
216
+ MEDIA_RESOLUTION_HIGH = 'MEDIA_RESOLUTION_HIGH'
217
+
218
+
219
+ class SafetyFilterLevel(_common.CaseInSensitiveEnum):
220
+ """Enum that controls the safety filter level for objectionable content."""
221
+
222
+ BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE'
223
+ BLOCK_MEDIUM_AND_ABOVE = 'BLOCK_MEDIUM_AND_ABOVE'
224
+ BLOCK_ONLY_HIGH = 'BLOCK_ONLY_HIGH'
225
+ BLOCK_NONE = 'BLOCK_NONE'
226
+
227
+
228
+ class PersonGeneration(_common.CaseInSensitiveEnum):
229
+ """Enum that controls the generation of people."""
230
+
231
+ DONT_ALLOW = 'DONT_ALLOW'
232
+ ALLOW_ADULT = 'ALLOW_ADULT'
233
+ ALLOW_ALL = 'ALLOW_ALL'
234
+
235
+
236
+ class ImagePromptLanguage(_common.CaseInSensitiveEnum):
237
+ """Enum that specifies the language of the text in the prompt."""
238
+
239
+ auto = 'auto'
240
+ en = 'en'
241
+ ja = 'ja'
242
+ ko = 'ko'
243
+ hi = 'hi'
244
+
245
+
246
+ class MaskReferenceMode(_common.CaseInSensitiveEnum):
247
+ """Enum representing the mask mode of a mask reference image."""
248
+
249
+ MASK_MODE_DEFAULT = 'MASK_MODE_DEFAULT'
250
+ MASK_MODE_USER_PROVIDED = 'MASK_MODE_USER_PROVIDED'
251
+ MASK_MODE_BACKGROUND = 'MASK_MODE_BACKGROUND'
252
+ MASK_MODE_FOREGROUND = 'MASK_MODE_FOREGROUND'
253
+ MASK_MODE_SEMANTIC = 'MASK_MODE_SEMANTIC'
203
254
 
204
- EditMode = Literal[
205
- "EDIT_MODE_DEFAULT",
206
- "EDIT_MODE_INPAINT_REMOVAL",
207
- "EDIT_MODE_INPAINT_INSERTION",
208
- "EDIT_MODE_OUTPAINT",
209
- "EDIT_MODE_CONTROLLED_EDITING",
210
- "EDIT_MODE_STYLE",
211
- "EDIT_MODE_BGSWAP",
212
- "EDIT_MODE_PRODUCT_IMAGE",
213
- ]
214
255
 
256
+ class ControlReferenceType(_common.CaseInSensitiveEnum):
257
+ """Enum representing the control type of a control reference image."""
215
258
 
216
- FileState = Literal["STATE_UNSPECIFIED", "PROCESSING", "ACTIVE", "FAILED"]
259
+ CONTROL_TYPE_DEFAULT = 'CONTROL_TYPE_DEFAULT'
260
+ CONTROL_TYPE_CANNY = 'CONTROL_TYPE_CANNY'
261
+ CONTROL_TYPE_SCRIBBLE = 'CONTROL_TYPE_SCRIBBLE'
262
+ CONTROL_TYPE_FACE_MESH = 'CONTROL_TYPE_FACE_MESH'
263
+
264
+
265
+ class SubjectReferenceType(_common.CaseInSensitiveEnum):
266
+ """Enum representing the subject type of a subject reference image."""
267
+
268
+ SUBJECT_TYPE_DEFAULT = 'SUBJECT_TYPE_DEFAULT'
269
+ SUBJECT_TYPE_PERSON = 'SUBJECT_TYPE_PERSON'
270
+ SUBJECT_TYPE_ANIMAL = 'SUBJECT_TYPE_ANIMAL'
271
+ SUBJECT_TYPE_PRODUCT = 'SUBJECT_TYPE_PRODUCT'
272
+
273
+
274
+ class EditMode(_common.CaseInSensitiveEnum):
275
+ """Enum representing the Imagen 3 Edit mode."""
276
+
277
+ EDIT_MODE_DEFAULT = 'EDIT_MODE_DEFAULT'
278
+ EDIT_MODE_INPAINT_REMOVAL = 'EDIT_MODE_INPAINT_REMOVAL'
279
+ EDIT_MODE_INPAINT_INSERTION = 'EDIT_MODE_INPAINT_INSERTION'
280
+ EDIT_MODE_OUTPAINT = 'EDIT_MODE_OUTPAINT'
281
+ EDIT_MODE_CONTROLLED_EDITING = 'EDIT_MODE_CONTROLLED_EDITING'
282
+ EDIT_MODE_STYLE = 'EDIT_MODE_STYLE'
283
+ EDIT_MODE_BGSWAP = 'EDIT_MODE_BGSWAP'
284
+ EDIT_MODE_PRODUCT_IMAGE = 'EDIT_MODE_PRODUCT_IMAGE'
285
+
286
+
287
+ class FileState(_common.CaseInSensitiveEnum):
288
+ """State for the lifecycle of a File."""
289
+
290
+ STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
291
+ PROCESSING = 'PROCESSING'
292
+ ACTIVE = 'ACTIVE'
293
+ FAILED = 'FAILED'
294
+
295
+
296
+ class FileSource(_common.CaseInSensitiveEnum):
297
+ """Source of the File."""
298
+
299
+ SOURCE_UNSPECIFIED = 'SOURCE_UNSPECIFIED'
300
+ UPLOADED = 'UPLOADED'
301
+ GENERATED = 'GENERATED'
302
+
303
+
304
+ class Modality(_common.CaseInSensitiveEnum):
305
+ """Config class for the server content modalities."""
306
+
307
+ MODALITY_UNSPECIFIED = 'MODALITY_UNSPECIFIED'
308
+ TEXT = 'TEXT'
309
+ IMAGE = 'IMAGE'
310
+ AUDIO = 'AUDIO'
217
311
 
218
312
 
219
313
  class VideoMetadata(_common.BaseModel):
@@ -472,16 +566,16 @@ class Part(_common.BaseModel):
472
566
  )
473
567
 
474
568
  @classmethod
475
- def from_uri(cls, file_uri: str, mime_type: str) -> "Part":
569
+ def from_uri(cls, file_uri: str, mime_type: str) -> 'Part':
476
570
  file_data = FileData(file_uri=file_uri, mime_type=mime_type)
477
571
  return cls(file_data=file_data)
478
572
 
479
573
  @classmethod
480
- def from_text(cls, text: str) -> "Part":
574
+ def from_text(cls, text: str) -> 'Part':
481
575
  return cls(text=text)
482
576
 
483
577
  @classmethod
484
- def from_bytes(cls, data: bytes, mime_type: str) -> "Part":
578
+ def from_bytes(cls, data: bytes, mime_type: str) -> 'Part':
485
579
  inline_data = Blob(
486
580
  data=data,
487
581
  mime_type=mime_type,
@@ -489,31 +583,31 @@ class Part(_common.BaseModel):
489
583
  return cls(inline_data=inline_data)
490
584
 
491
585
  @classmethod
492
- def from_function_call(cls, name: str, args: dict[str, Any]) -> "Part":
586
+ def from_function_call(cls, name: str, args: dict[str, Any]) -> 'Part':
493
587
  function_call = FunctionCall(name=name, args=args)
494
588
  return cls(function_call=function_call)
495
589
 
496
590
  @classmethod
497
591
  def from_function_response(
498
592
  cls, name: str, response: dict[str, Any]
499
- ) -> "Part":
593
+ ) -> 'Part':
500
594
  function_response = FunctionResponse(name=name, response=response)
501
595
  return cls(function_response=function_response)
502
596
 
503
597
  @classmethod
504
- def from_video_metadata(cls, end_offset: str, start_offset: str) -> "Part":
598
+ def from_video_metadata(cls, end_offset: str, start_offset: str) -> 'Part':
505
599
  video_metadata = VideoMetadata(
506
600
  end_offset=end_offset, start_offset=start_offset
507
601
  )
508
602
  return cls(video_metadata=video_metadata)
509
603
 
510
604
  @classmethod
511
- def from_executable_code(cls, code: str, language: Language) -> "Part":
605
+ def from_executable_code(cls, code: str, language: Language) -> 'Part':
512
606
  executable_code = ExecutableCode(code=code, language=language)
513
607
  return cls(executable_code=executable_code)
514
608
 
515
609
  @classmethod
516
- def from_code_execution_result(cls, outcome: Outcome, output: str) -> "Part":
610
+ def from_code_execution_result(cls, outcome: Outcome, output: str) -> 'Part':
517
611
  code_execution_result = CodeExecutionResult(outcome=outcome, output=output)
518
612
  return cls(code_execution_result=code_execution_result)
519
613
 
@@ -555,8 +649,6 @@ class PartDict(TypedDict, total=False):
555
649
 
556
650
 
557
651
  PartOrDict = Union[Part, PartDict]
558
- PartUnion = Union[Part, PIL.Image.Image, str]
559
- PartUnionDict = Union[PartUnion, PartDict]
560
652
 
561
653
 
562
654
  class Content(_common.BaseModel):
@@ -589,11 +681,6 @@ class ContentDict(TypedDict, total=False):
589
681
 
590
682
 
591
683
  ContentOrDict = Union[Content, ContentDict]
592
- ContentUnion = Union[Content, list[PartUnion], PartUnion]
593
- ContentUnionDict = Union[ContentUnion, ContentDict]
594
-
595
- ContentListUnion = Union[list[ContentUnion], ContentUnion]
596
- ContentListUnionDict = Union[list[ContentUnionDict], ContentUnionDict]
597
684
 
598
685
 
599
686
  class Schema(_common.BaseModel):
@@ -625,7 +712,7 @@ class Schema(_common.BaseModel):
625
712
  default: Optional[Any] = Field(
626
713
  default=None, description="""Optional. Default value of the data."""
627
714
  )
628
- any_of: list["Schema"] = Field(
715
+ any_of: list['Schema'] = Field(
629
716
  default=None,
630
717
  description="""Optional. The value should be validated against any (one or more) of the subschemas in the list.""",
631
718
  )
@@ -674,11 +761,11 @@ class Schema(_common.BaseModel):
674
761
  default=None,
675
762
  description="""Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc""",
676
763
  )
677
- items: "Schema" = Field(
764
+ items: 'Schema' = Field(
678
765
  default=None,
679
766
  description="""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY.""",
680
767
  )
681
- properties: dict[str, "Schema"] = Field(
768
+ properties: dict[str, 'Schema'] = Field(
682
769
  default=None,
683
770
  description="""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT.""",
684
771
  )
@@ -712,7 +799,7 @@ class SchemaDict(TypedDict, total=False):
712
799
  default: Optional[Any]
713
800
  """Optional. Default value of the data."""
714
801
 
715
- any_of: list["SchemaDict"]
802
+ any_of: list['SchemaDict']
716
803
  """Optional. The value should be validated against any (one or more) of the subschemas in the list."""
717
804
 
718
805
  max_length: Optional[int]
@@ -751,10 +838,10 @@ class SchemaDict(TypedDict, total=False):
751
838
  format: Optional[str]
752
839
  """Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc"""
753
840
 
754
- items: "SchemaDict"
841
+ items: 'SchemaDict'
755
842
  """Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY."""
756
843
 
757
- properties: dict[str, "SchemaDict"]
844
+ properties: dict[str, 'SchemaDict']
758
845
  """Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT."""
759
846
 
760
847
  required: Optional[list[str]]
@@ -762,8 +849,6 @@ class SchemaDict(TypedDict, total=False):
762
849
 
763
850
 
764
851
  SchemaOrDict = Union[Schema, SchemaDict]
765
- SchemaUnion = Union[dict, type, Schema]
766
- SchemaUnionDict = Union[SchemaUnion, SchemaDict]
767
852
 
768
853
 
769
854
  class SafetySetting(_common.BaseModel):
@@ -828,27 +913,27 @@ class FunctionDeclaration(_common.BaseModel):
828
913
  def _get_variant(cls, client) -> str:
829
914
  """Returns the function variant based on the provided client object."""
830
915
  if client.vertexai:
831
- return "VERTEX_AI"
916
+ return 'VERTEX_AI'
832
917
  else:
833
- return "GOOGLE_AI"
918
+ return 'GOOGLE_AI'
834
919
 
835
920
  @classmethod
836
921
  def from_function_with_options(
837
922
  cls,
838
923
  func: Callable,
839
- variant: Literal["GOOGLE_AI", "VERTEX_AI", "DEFAULT"] = "GOOGLE_AI",
840
- ) -> "FunctionDeclaration":
924
+ variant: Literal['GOOGLE_AI', 'VERTEX_AI', 'DEFAULT'] = 'GOOGLE_AI',
925
+ ) -> 'FunctionDeclaration':
841
926
  """Converts a function to a FunctionDeclaration based on an API endpoint.
842
927
 
843
928
  Supported endpoints are: 'GOOGLE_AI', 'VERTEX_AI', or 'DEFAULT'.
844
929
  """
845
930
  from . import _automatic_function_calling_util
846
931
 
847
- supported_variants = ["GOOGLE_AI", "VERTEX_AI", "DEFAULT"]
932
+ supported_variants = ['GOOGLE_AI', 'VERTEX_AI', 'DEFAULT']
848
933
  if variant not in supported_variants:
849
934
  raise ValueError(
850
- f"Unsupported variant: {variant}. Supported variants are:"
851
- f" {', '.join(supported_variants)}"
935
+ f'Unsupported variant: {variant}. Supported variants are:'
936
+ f' {", ".join(supported_variants)}'
852
937
  )
853
938
 
854
939
  # TODO: b/382524014 - Add support for DEFAULT API endpoint.
@@ -870,16 +955,16 @@ class FunctionDeclaration(_common.BaseModel):
870
955
  )
871
956
  if parameters_properties:
872
957
  declaration.parameters = Schema(
873
- type="OBJECT",
958
+ type='OBJECT',
874
959
  properties=parameters_properties,
875
960
  )
876
- if variant == "VERTEX_AI":
961
+ if variant == 'VERTEX_AI':
877
962
  declaration.parameters.required = (
878
963
  _automatic_function_calling_util._get_required_fields(
879
964
  declaration.parameters
880
965
  )
881
966
  )
882
- if not variant == "VERTEX_AI":
967
+ if not variant == 'VERTEX_AI':
883
968
  return declaration
884
969
 
885
970
  return_annotation = inspect.signature(func).return_annotation
@@ -890,7 +975,7 @@ class FunctionDeclaration(_common.BaseModel):
890
975
  _automatic_function_calling_util._parse_schema_from_parameter(
891
976
  variant,
892
977
  inspect.Parameter(
893
- "return_value",
978
+ 'return_value',
894
979
  inspect.Parameter.POSITIONAL_OR_KEYWORD,
895
980
  annotation=return_annotation,
896
981
  ),
@@ -900,7 +985,7 @@ class FunctionDeclaration(_common.BaseModel):
900
985
  return declaration
901
986
 
902
987
  @classmethod
903
- def from_function(cls, client, func: Callable) -> "FunctionDeclaration":
988
+ def from_callable(cls, client, func: Callable) -> 'FunctionDeclaration':
904
989
  """Converts a function to a FunctionDeclaration."""
905
990
  return cls.from_function_with_options(
906
991
  variant=cls._get_variant(client),
@@ -1308,8 +1393,6 @@ class SpeechConfigDict(TypedDict, total=False):
1308
1393
 
1309
1394
 
1310
1395
  SpeechConfigOrDict = Union[SpeechConfig, SpeechConfigDict]
1311
- SpeechConfigUnion = Union[SpeechConfig, str]
1312
- SpeechConfigUnionDict = Union[SpeechConfigUnion, SpeechConfigDict]
1313
1396
 
1314
1397
 
1315
1398
  class AutomaticFunctionCallingConfig(_common.BaseModel):
@@ -1371,11 +1454,186 @@ AutomaticFunctionCallingConfigOrDict = Union[
1371
1454
  ]
1372
1455
 
1373
1456
 
1457
+ class ThinkingConfig(_common.BaseModel):
1458
+ """The thinking features configuration."""
1459
+
1460
+ include_thoughts: Optional[bool] = Field(
1461
+ default=None,
1462
+ description="""Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
1463
+ """,
1464
+ )
1465
+
1466
+
1467
+ class ThinkingConfigDict(TypedDict, total=False):
1468
+ """The thinking features configuration."""
1469
+
1470
+ include_thoughts: Optional[bool]
1471
+ """Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.
1472
+ """
1473
+
1474
+
1475
+ ThinkingConfigOrDict = Union[ThinkingConfig, ThinkingConfigDict]
1476
+
1477
+
1478
+ class FileStatus(_common.BaseModel):
1479
+ """Status of a File that uses a common error model."""
1480
+
1481
+ details: Optional[list[dict[str, Any]]] = Field(
1482
+ default=None,
1483
+ description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
1484
+ )
1485
+ message: Optional[str] = Field(
1486
+ default=None,
1487
+ description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
1488
+ )
1489
+ code: Optional[int] = Field(
1490
+ default=None, description="""The status code. 0 for OK, 1 for CANCELLED"""
1491
+ )
1492
+
1493
+
1494
+ class FileStatusDict(TypedDict, total=False):
1495
+ """Status of a File that uses a common error model."""
1496
+
1497
+ details: Optional[list[dict[str, Any]]]
1498
+ """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
1499
+
1500
+ message: Optional[str]
1501
+ """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
1502
+
1503
+ code: Optional[int]
1504
+ """The status code. 0 for OK, 1 for CANCELLED"""
1505
+
1506
+
1507
+ FileStatusOrDict = Union[FileStatus, FileStatusDict]
1508
+
1509
+
1510
+ class File(_common.BaseModel):
1511
+ """A file uploaded to the API."""
1512
+
1513
+ name: Optional[str] = Field(
1514
+ default=None,
1515
+ description="""The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`""",
1516
+ )
1517
+ display_name: Optional[str] = Field(
1518
+ default=None,
1519
+ description="""Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'""",
1520
+ )
1521
+ mime_type: Optional[str] = Field(
1522
+ default=None, description="""Output only. MIME type of the file."""
1523
+ )
1524
+ size_bytes: Optional[int] = Field(
1525
+ default=None, description="""Output only. Size of the file in bytes."""
1526
+ )
1527
+ create_time: Optional[datetime.datetime] = Field(
1528
+ default=None,
1529
+ description="""Output only. The timestamp of when the `File` was created.""",
1530
+ )
1531
+ expiration_time: Optional[datetime.datetime] = Field(
1532
+ default=None,
1533
+ description="""Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'""",
1534
+ )
1535
+ update_time: Optional[datetime.datetime] = Field(
1536
+ default=None,
1537
+ description="""Output only. The timestamp of when the `File` was last updated.""",
1538
+ )
1539
+ sha256_hash: Optional[str] = Field(
1540
+ default=None,
1541
+ description="""Output only. SHA-256 hash of the uploaded bytes.""",
1542
+ )
1543
+ uri: Optional[str] = Field(
1544
+ default=None, description="""Output only. The URI of the `File`."""
1545
+ )
1546
+ download_uri: Optional[str] = Field(
1547
+ default=None,
1548
+ description="""Output only. The URI of the `File`, only set for downloadable (generated) files.""",
1549
+ )
1550
+ state: Optional[FileState] = Field(
1551
+ default=None, description="""Output only. Processing state of the File."""
1552
+ )
1553
+ source: Optional[FileSource] = Field(
1554
+ default=None, description="""Output only. The source of the `File`."""
1555
+ )
1556
+ video_metadata: Optional[dict[str, Any]] = Field(
1557
+ default=None, description="""Output only. Metadata for a video."""
1558
+ )
1559
+ error: Optional[FileStatus] = Field(
1560
+ default=None,
1561
+ description="""Output only. Error status if File processing failed.""",
1562
+ )
1563
+
1564
+
1565
+ class FileDict(TypedDict, total=False):
1566
+ """A file uploaded to the API."""
1567
+
1568
+ name: Optional[str]
1569
+ """The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`"""
1570
+
1571
+ display_name: Optional[str]
1572
+ """Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'"""
1573
+
1574
+ mime_type: Optional[str]
1575
+ """Output only. MIME type of the file."""
1576
+
1577
+ size_bytes: Optional[int]
1578
+ """Output only. Size of the file in bytes."""
1579
+
1580
+ create_time: Optional[datetime.datetime]
1581
+ """Output only. The timestamp of when the `File` was created."""
1582
+
1583
+ expiration_time: Optional[datetime.datetime]
1584
+ """Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'"""
1585
+
1586
+ update_time: Optional[datetime.datetime]
1587
+ """Output only. The timestamp of when the `File` was last updated."""
1588
+
1589
+ sha256_hash: Optional[str]
1590
+ """Output only. SHA-256 hash of the uploaded bytes."""
1591
+
1592
+ uri: Optional[str]
1593
+ """Output only. The URI of the `File`."""
1594
+
1595
+ download_uri: Optional[str]
1596
+ """Output only. The URI of the `File`, only set for downloadable (generated) files."""
1597
+
1598
+ state: Optional[FileState]
1599
+ """Output only. Processing state of the File."""
1600
+
1601
+ source: Optional[FileSource]
1602
+ """Output only. The source of the `File`."""
1603
+
1604
+ video_metadata: Optional[dict[str, Any]]
1605
+ """Output only. Metadata for a video."""
1606
+
1607
+ error: Optional[FileStatusDict]
1608
+ """Output only. Error status if File processing failed."""
1609
+
1610
+
1611
+ FileOrDict = Union[File, FileDict]
1612
+
1613
+
1614
+ PartUnion = Union[File, Part, PIL.Image.Image, str]
1615
+
1616
+
1617
+ PartUnionDict = Union[PartUnion, PartDict]
1618
+
1619
+
1620
+ ContentUnion = Union[Content, list[PartUnion], PartUnion]
1621
+
1622
+
1623
+ ContentUnionDict = Union[ContentUnion, ContentDict]
1624
+
1625
+
1626
+ SchemaUnion = Union[dict, type, Schema, GenericAlias]
1627
+
1628
+
1629
+ SchemaUnionDict = Union[SchemaUnion, SchemaDict]
1630
+
1631
+
1374
1632
  class GenerationConfigRoutingConfigAutoRoutingMode(_common.BaseModel):
1375
1633
  """When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference."""
1376
1634
 
1377
1635
  model_routing_preference: Optional[
1378
- Literal["UNKNOWN", "PRIORITIZE_QUALITY", "BALANCED", "PRIORITIZE_COST"]
1636
+ Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']
1379
1637
  ] = Field(default=None, description="""The model routing preference.""")
1380
1638
 
1381
1639
 
@@ -1383,7 +1641,7 @@ class GenerationConfigRoutingConfigAutoRoutingModeDict(TypedDict, total=False):
1383
1641
  """When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference."""
1384
1642
 
1385
1643
  model_routing_preference: Optional[
1386
- Literal["UNKNOWN", "PRIORITIZE_QUALITY", "BALANCED", "PRIORITIZE_COST"]
1644
+ Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']
1387
1645
  ]
1388
1646
  """The model routing preference."""
1389
1647
 
@@ -1444,6 +1702,12 @@ GenerationConfigRoutingConfigOrDict = Union[
1444
1702
  ]
1445
1703
 
1446
1704
 
1705
+ SpeechConfigUnion = Union[SpeechConfig, str]
1706
+
1707
+
1708
+ SpeechConfigUnionDict = Union[SpeechConfigUnion, SpeechConfigDict]
1709
+
1710
+
1447
1711
  class GenerateContentConfig(_common.BaseModel):
1448
1712
  """Class for configuring optional model parameters.
1449
1713
 
@@ -1585,11 +1849,22 @@ class GenerateContentConfig(_common.BaseModel):
1585
1849
  description="""The speech generation configuration.
1586
1850
  """,
1587
1851
  )
1852
+ audio_timestamp: Optional[bool] = Field(
1853
+ default=None,
1854
+ description="""If enabled, audio timestamp will be included in the request to the
1855
+ model.
1856
+ """,
1857
+ )
1588
1858
  automatic_function_calling: Optional[AutomaticFunctionCallingConfig] = Field(
1589
1859
  default=None,
1590
1860
  description="""The configuration for automatic function calling.
1591
1861
  """,
1592
1862
  )
1863
+ thinking_config: Optional[ThinkingConfig] = Field(
1864
+ default=None,
1865
+ description="""The thinking features configuration.
1866
+ """,
1867
+ )
1593
1868
 
1594
1869
 
1595
1870
  class GenerateContentConfigDict(TypedDict, total=False):
@@ -1711,16 +1986,31 @@ class GenerateContentConfigDict(TypedDict, total=False):
1711
1986
  """The speech generation configuration.
1712
1987
  """
1713
1988
 
1989
+ audio_timestamp: Optional[bool]
1990
+ """If enabled, audio timestamp will be included in the request to the
1991
+ model.
1992
+ """
1993
+
1714
1994
  automatic_function_calling: Optional[AutomaticFunctionCallingConfigDict]
1715
1995
  """The configuration for automatic function calling.
1716
1996
  """
1717
1997
 
1998
+ thinking_config: Optional[ThinkingConfigDict]
1999
+ """The thinking features configuration.
2000
+ """
2001
+
1718
2002
 
1719
2003
  GenerateContentConfigOrDict = Union[
1720
2004
  GenerateContentConfig, GenerateContentConfigDict
1721
2005
  ]
1722
2006
 
1723
2007
 
2008
+ ContentListUnion = Union[list[ContentUnion], ContentUnion]
2009
+
2010
+
2011
+ ContentListUnionDict = Union[list[ContentUnionDict], ContentUnionDict]
2012
+
2013
+
1724
2014
  class _GenerateContentParameters(_common.BaseModel):
1725
2015
  """Class for configuring the content of the request to the model."""
1726
2016
 
@@ -2469,20 +2759,20 @@ class GenerateContentResponse(_common.BaseModel):
2469
2759
  return None
2470
2760
  if len(self.candidates) > 1:
2471
2761
  logging.warning(
2472
- f"there are {len(self.candidates)} candidates, returning text from"
2473
- " the first candidate.Access response.candidates directly to get"
2474
- " text from other candidates."
2762
+ f'there are {len(self.candidates)} candidates, returning text from'
2763
+ ' the first candidate.Access response.candidates directly to get'
2764
+ ' text from other candidates.'
2475
2765
  )
2476
- text = ""
2766
+ text = ''
2477
2767
  any_text_part_text = False
2478
2768
  for part in self.candidates[0].content.parts:
2479
2769
  for field_name, field_value in part.dict(
2480
- exclude={"text", "thought"}
2770
+ exclude={'text', 'thought'}
2481
2771
  ).items():
2482
2772
  if field_value is not None:
2483
2773
  raise ValueError(
2484
- "GenerateContentResponse.text only supports text parts, but got"
2485
- f" {field_name} part{part}"
2774
+ 'GenerateContentResponse.text only supports text parts, but got'
2775
+ f' {field_name} part{part}'
2486
2776
  )
2487
2777
  if isinstance(part.text, str):
2488
2778
  if isinstance(part.thought, bool) and part.thought:
@@ -2503,8 +2793,8 @@ class GenerateContentResponse(_common.BaseModel):
2503
2793
  return None
2504
2794
  if len(self.candidates) > 1:
2505
2795
  logging.warning(
2506
- "Warning: there are multiple candidates in the response, returning"
2507
- " function calls from the first one."
2796
+ 'Warning: there are multiple candidates in the response, returning'
2797
+ ' function calls from the first one.'
2508
2798
  )
2509
2799
  function_calls = [
2510
2800
  part.function_call
@@ -2522,7 +2812,7 @@ class GenerateContentResponse(_common.BaseModel):
2522
2812
 
2523
2813
  # Handles response schema.
2524
2814
  response_schema = _common.get_value_by_path(
2525
- kwargs, ["config", "response_schema"]
2815
+ kwargs, ['config', 'response_schema']
2526
2816
  )
2527
2817
  if inspect.isclass(response_schema) and issubclass(
2528
2818
  response_schema, pydantic.BaseModel
@@ -2534,6 +2824,23 @@ class GenerateContentResponse(_common.BaseModel):
2534
2824
  except pydantic.ValidationError:
2535
2825
  pass
2536
2826
 
2827
+ elif isinstance(response_schema, GenericAlias) and issubclass(
2828
+ response_schema.__args__[0], pydantic.BaseModel
2829
+ ):
2830
+ # Handle cases where `list[pydantic.BaseModel]` was provided.
2831
+ result.parsed = []
2832
+ pydantic_model_class = response_schema.__args__[0]
2833
+ response_list_json = json.loads(result.text)
2834
+ for json_instance in response_list_json:
2835
+ try:
2836
+ pydantic_model_instance = pydantic_model_class.model_validate_json(
2837
+ json.dumps(json_instance)
2838
+ )
2839
+ result.parsed.append(pydantic_model_instance)
2840
+ # may not be a valid json per stream response
2841
+ except pydantic.ValidationError:
2842
+ pass
2843
+
2537
2844
  elif isinstance(response_schema, dict) or isinstance(
2538
2845
  response_schema, pydantic.BaseModel
2539
2846
  ):
@@ -3026,7 +3333,7 @@ class Image(_common.BaseModel):
3026
3333
  """Image."""
3027
3334
 
3028
3335
  @staticmethod
3029
- def from_file(location: str) -> "Image":
3336
+ def from_file(location: str) -> 'Image':
3030
3337
  """Lazy-loads an image from a local file or Google Cloud Storage.
3031
3338
 
3032
3339
  Args:
@@ -3041,17 +3348,17 @@ class Image(_common.BaseModel):
3041
3348
 
3042
3349
  parsed_url = urllib.parse.urlparse(location)
3043
3350
  if (
3044
- parsed_url.scheme == "https"
3045
- and parsed_url.netloc == "storage.googleapis.com"
3351
+ parsed_url.scheme == 'https'
3352
+ and parsed_url.netloc == 'storage.googleapis.com'
3046
3353
  ):
3047
3354
  parsed_url = parsed_url._replace(
3048
- scheme="gs",
3049
- netloc="",
3050
- path=f"/{urllib.parse.unquote(parsed_url.path)}",
3355
+ scheme='gs',
3356
+ netloc='',
3357
+ path=f'/{urllib.parse.unquote(parsed_url.path)}',
3051
3358
  )
3052
3359
  location = urllib.parse.urlunparse(parsed_url)
3053
3360
 
3054
- if parsed_url.scheme == "gs":
3361
+ if parsed_url.scheme == 'gs':
3055
3362
  return Image(gcs_uri=location)
3056
3363
 
3057
3364
  # Load image from local path
@@ -3077,7 +3384,7 @@ class Image(_common.BaseModel):
3077
3384
  IPython_display.display(self._pil_image)
3078
3385
 
3079
3386
  @property
3080
- def _pil_image(self) -> "PIL_Image.Image":
3387
+ def _pil_image(self) -> 'PIL_Image.Image':
3081
3388
  try:
3082
3389
  from PIL import Image as PIL_Image
3083
3390
  except ImportError:
@@ -3087,8 +3394,8 @@ class Image(_common.BaseModel):
3087
3394
  if self._loaded_image is None:
3088
3395
  if not PIL_Image:
3089
3396
  raise RuntimeError(
3090
- "The PIL module is not available. Please install the Pillow"
3091
- " package."
3397
+ 'The PIL module is not available. Please install the Pillow'
3398
+ ' package.'
3092
3399
  )
3093
3400
  self._loaded_image = PIL_Image.open(io.BytesIO(self.image_bytes))
3094
3401
  return self._loaded_image
@@ -3104,29 +3411,27 @@ class Image(_common.BaseModel):
3104
3411
  pathlib.Path(location).write_bytes(self.image_bytes)
3105
3412
 
3106
3413
 
3107
- Modality = Literal["MODALITY_UNSPECIFIED", "TEXT", "IMAGE", "AUDIO"]
3108
-
3109
3414
  JOB_STATES_SUCCEEDED_VERTEX = [
3110
- "JOB_STATE_SUCCEEDED",
3415
+ 'JOB_STATE_SUCCEEDED',
3111
3416
  ]
3112
3417
 
3113
3418
  JOB_STATES_SUCCEEDED_MLDEV = [
3114
- "ACTIVE",
3419
+ 'ACTIVE',
3115
3420
  ]
3116
3421
 
3117
3422
  JOB_STATES_SUCCEEDED = JOB_STATES_SUCCEEDED_VERTEX + JOB_STATES_SUCCEEDED_MLDEV
3118
3423
 
3119
3424
 
3120
3425
  JOB_STATES_ENDED_VERTEX = [
3121
- "JOB_STATE_SUCCEEDED",
3122
- "JOB_STATE_FAILED",
3123
- "JOB_STATE_CANCELLED",
3124
- "JOB_STATE_EXPIRED",
3426
+ 'JOB_STATE_SUCCEEDED',
3427
+ 'JOB_STATE_FAILED',
3428
+ 'JOB_STATE_CANCELLED',
3429
+ 'JOB_STATE_EXPIRED',
3125
3430
  ]
3126
3431
 
3127
3432
  JOB_STATES_ENDED_MLDEV = [
3128
- "ACTIVE",
3129
- "FAILED",
3433
+ 'ACTIVE',
3434
+ 'FAILED',
3130
3435
  ]
3131
3436
 
3132
3437
  JOB_STATES_ENDED = JOB_STATES_ENDED_VERTEX + JOB_STATES_ENDED_MLDEV
@@ -3861,13 +4166,23 @@ ModelOrDict = Union[Model, ModelDict]
3861
4166
 
3862
4167
  class ListModelsConfig(_common.BaseModel):
3863
4168
 
4169
+ http_options: Optional[dict[str, Any]] = Field(
4170
+ default=None, description="""Used to override HTTP request options."""
4171
+ )
3864
4172
  page_size: Optional[int] = Field(default=None, description="""""")
3865
4173
  page_token: Optional[str] = Field(default=None, description="""""")
3866
4174
  filter: Optional[str] = Field(default=None, description="""""")
4175
+ query_base: Optional[bool] = Field(
4176
+ default=None,
4177
+ description="""Set true to list base models, false to list tuned models.""",
4178
+ )
3867
4179
 
3868
4180
 
3869
4181
  class ListModelsConfigDict(TypedDict, total=False):
3870
4182
 
4183
+ http_options: Optional[dict[str, Any]]
4184
+ """Used to override HTTP request options."""
4185
+
3871
4186
  page_size: Optional[int]
3872
4187
  """"""
3873
4188
 
@@ -3877,6 +4192,9 @@ class ListModelsConfigDict(TypedDict, total=False):
3877
4192
  filter: Optional[str]
3878
4193
  """"""
3879
4194
 
4195
+ query_base: Optional[bool]
4196
+ """Set true to list base models, false to list tuned models."""
4197
+
3880
4198
 
3881
4199
  ListModelsConfigOrDict = Union[ListModelsConfig, ListModelsConfigDict]
3882
4200
 
@@ -6144,129 +6462,6 @@ _ListFilesParametersOrDict = Union[
6144
6462
  ]
6145
6463
 
6146
6464
 
6147
- class FileStatus(_common.BaseModel):
6148
- """Status of a File that uses a common error model."""
6149
-
6150
- details: Optional[list[dict[str, Any]]] = Field(
6151
- default=None,
6152
- description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
6153
- )
6154
- message: Optional[str] = Field(
6155
- default=None,
6156
- description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
6157
- )
6158
- code: Optional[int] = Field(
6159
- default=None, description="""The status code. 0 for OK, 1 for CANCELLED"""
6160
- )
6161
-
6162
-
6163
- class FileStatusDict(TypedDict, total=False):
6164
- """Status of a File that uses a common error model."""
6165
-
6166
- details: Optional[list[dict[str, Any]]]
6167
- """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
6168
-
6169
- message: Optional[str]
6170
- """A list of messages that carry the error details. There is a common set of message types for APIs to use."""
6171
-
6172
- code: Optional[int]
6173
- """The status code. 0 for OK, 1 for CANCELLED"""
6174
-
6175
-
6176
- FileStatusOrDict = Union[FileStatus, FileStatusDict]
6177
-
6178
-
6179
- class File(_common.BaseModel):
6180
- """A file uploaded to the API."""
6181
-
6182
- name: Optional[str] = Field(
6183
- default=None,
6184
- description="""The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`""",
6185
- )
6186
- display_name: Optional[str] = Field(
6187
- default=None,
6188
- description="""Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'""",
6189
- )
6190
- mime_type: Optional[str] = Field(
6191
- default=None, description="""Output only. MIME type of the file."""
6192
- )
6193
- size_bytes: Optional[int] = Field(
6194
- default=None, description="""Output only. Size of the file in bytes."""
6195
- )
6196
- create_time: Optional[datetime.datetime] = Field(
6197
- default=None,
6198
- description="""Output only. The timestamp of when the `File` was created.""",
6199
- )
6200
- expiration_time: Optional[datetime.datetime] = Field(
6201
- default=None,
6202
- description="""Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'""",
6203
- )
6204
- update_time: Optional[datetime.datetime] = Field(
6205
- default=None,
6206
- description="""Output only. The timestamp of when the `File` was last updated.""",
6207
- )
6208
- sha256_hash: Optional[bytes] = Field(
6209
- default=None,
6210
- description="""Output only. SHA-256 hash of the uploaded bytes.""",
6211
- )
6212
- uri: Optional[str] = Field(
6213
- default=None, description="""Output only. The URI of the `File`."""
6214
- )
6215
- state: Optional[FileState] = Field(
6216
- default=None, description="""Output only. Processing state of the File."""
6217
- )
6218
- video_metadata: Optional[dict[str, Any]] = Field(
6219
- default=None, description="""Output only. Metadata for a video."""
6220
- )
6221
- error: Optional[FileStatus] = Field(
6222
- default=None,
6223
- description="""Output only. Error status if File processing failed.""",
6224
- )
6225
-
6226
-
6227
- class FileDict(TypedDict, total=False):
6228
- """A file uploaded to the API."""
6229
-
6230
- name: Optional[str]
6231
- """The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456`"""
6232
-
6233
- display_name: Optional[str]
6234
- """Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'"""
6235
-
6236
- mime_type: Optional[str]
6237
- """Output only. MIME type of the file."""
6238
-
6239
- size_bytes: Optional[int]
6240
- """Output only. Size of the file in bytes."""
6241
-
6242
- create_time: Optional[datetime.datetime]
6243
- """Output only. The timestamp of when the `File` was created."""
6244
-
6245
- expiration_time: Optional[datetime.datetime]
6246
- """Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: 'Welcome Image'"""
6247
-
6248
- update_time: Optional[datetime.datetime]
6249
- """Output only. The timestamp of when the `File` was last updated."""
6250
-
6251
- sha256_hash: Optional[bytes]
6252
- """Output only. SHA-256 hash of the uploaded bytes."""
6253
-
6254
- uri: Optional[str]
6255
- """Output only. The URI of the `File`."""
6256
-
6257
- state: Optional[FileState]
6258
- """Output only. Processing state of the File."""
6259
-
6260
- video_metadata: Optional[dict[str, Any]]
6261
- """Output only. Metadata for a video."""
6262
-
6263
- error: Optional[FileStatusDict]
6264
- """Output only. Error status if File processing failed."""
6265
-
6266
-
6267
- FileOrDict = Union[File, FileDict]
6268
-
6269
-
6270
6465
  class ListFilesResponse(_common.BaseModel):
6271
6466
  """Response for the list files method."""
6272
6467
 
@@ -7209,6 +7404,24 @@ class UploadFileConfigDict(TypedDict, total=False):
7209
7404
  UploadFileConfigOrDict = Union[UploadFileConfig, UploadFileConfigDict]
7210
7405
 
7211
7406
 
7407
+ class DownloadFileConfig(_common.BaseModel):
7408
+ """Used to override the default configuration."""
7409
+
7410
+ http_options: Optional[dict[str, Any]] = Field(
7411
+ default=None, description="""Used to override HTTP request options."""
7412
+ )
7413
+
7414
+
7415
+ class DownloadFileConfigDict(TypedDict, total=False):
7416
+ """Used to override the default configuration."""
7417
+
7418
+ http_options: Optional[dict[str, Any]]
7419
+ """Used to override HTTP request options."""
7420
+
7421
+
7422
+ DownloadFileConfigOrDict = Union[DownloadFileConfig, DownloadFileConfigDict]
7423
+
7424
+
7212
7425
  class UpscaleImageConfig(_common.BaseModel):
7213
7426
  """Configuration for upscaling an image.
7214
7427
 
@@ -7328,7 +7541,7 @@ class RawReferenceImage(_common.BaseModel):
7328
7541
  super().__init__(
7329
7542
  reference_image=reference_image,
7330
7543
  reference_id=reference_id,
7331
- reference_type="REFERENCE_TYPE_RAW",
7544
+ reference_type='REFERENCE_TYPE_RAW',
7332
7545
  )
7333
7546
 
7334
7547
 
@@ -7380,7 +7593,7 @@ class MaskReferenceImage(_common.BaseModel):
7380
7593
  description="""Configuration for the mask reference image.""",
7381
7594
  )
7382
7595
  """Re-map config to mask_reference_config to send to API."""
7383
- mask_image_config: Optional["MaskReferenceConfig"] = Field(
7596
+ mask_image_config: Optional['MaskReferenceConfig'] = Field(
7384
7597
  default=None, description=""""""
7385
7598
  )
7386
7599
 
@@ -7388,12 +7601,12 @@ class MaskReferenceImage(_common.BaseModel):
7388
7601
  self,
7389
7602
  reference_image: Optional[Image] = None,
7390
7603
  reference_id: Optional[int] = None,
7391
- config: Optional["MaskReferenceConfig"] = None,
7604
+ config: Optional['MaskReferenceConfig'] = None,
7392
7605
  ):
7393
7606
  super().__init__(
7394
7607
  reference_image=reference_image,
7395
7608
  reference_id=reference_id,
7396
- reference_type="REFERENCE_TYPE_MASK",
7609
+ reference_type='REFERENCE_TYPE_MASK',
7397
7610
  )
7398
7611
  self.mask_image_config = config
7399
7612
 
@@ -7453,7 +7666,7 @@ class ControlReferenceImage(_common.BaseModel):
7453
7666
  description="""Configuration for the control reference image.""",
7454
7667
  )
7455
7668
  """Re-map config to control_reference_config to send to API."""
7456
- control_image_config: Optional["ControlReferenceConfig"] = Field(
7669
+ control_image_config: Optional['ControlReferenceConfig'] = Field(
7457
7670
  default=None, description=""""""
7458
7671
  )
7459
7672
 
@@ -7461,12 +7674,12 @@ class ControlReferenceImage(_common.BaseModel):
7461
7674
  self,
7462
7675
  reference_image: Optional[Image] = None,
7463
7676
  reference_id: Optional[int] = None,
7464
- config: Optional["ControlReferenceConfig"] = None,
7677
+ config: Optional['ControlReferenceConfig'] = None,
7465
7678
  ):
7466
7679
  super().__init__(
7467
7680
  reference_image=reference_image,
7468
7681
  reference_id=reference_id,
7469
- reference_type="REFERENCE_TYPE_CONTROL",
7682
+ reference_type='REFERENCE_TYPE_CONTROL',
7470
7683
  )
7471
7684
  self.control_image_config = config
7472
7685
 
@@ -7526,7 +7739,7 @@ class StyleReferenceImage(_common.BaseModel):
7526
7739
  description="""Configuration for the style reference image.""",
7527
7740
  )
7528
7741
  """Re-map config to style_reference_config to send to API."""
7529
- style_image_config: Optional["StyleReferenceConfig"] = Field(
7742
+ style_image_config: Optional['StyleReferenceConfig'] = Field(
7530
7743
  default=None, description=""""""
7531
7744
  )
7532
7745
 
@@ -7534,12 +7747,12 @@ class StyleReferenceImage(_common.BaseModel):
7534
7747
  self,
7535
7748
  reference_image: Optional[Image] = None,
7536
7749
  reference_id: Optional[int] = None,
7537
- config: Optional["StyleReferenceConfig"] = None,
7750
+ config: Optional['StyleReferenceConfig'] = None,
7538
7751
  ):
7539
7752
  super().__init__(
7540
7753
  reference_image=reference_image,
7541
7754
  reference_id=reference_id,
7542
- reference_type="REFERENCE_TYPE_STYLE",
7755
+ reference_type='REFERENCE_TYPE_STYLE',
7543
7756
  )
7544
7757
  self.style_image_config = config
7545
7758
 
@@ -7595,7 +7808,7 @@ class SubjectReferenceImage(_common.BaseModel):
7595
7808
  description="""Configuration for the subject reference image.""",
7596
7809
  )
7597
7810
  """Re-map config to subject_reference_config to send to API."""
7598
- subject_image_config: Optional["SubjectReferenceConfig"] = Field(
7811
+ subject_image_config: Optional['SubjectReferenceConfig'] = Field(
7599
7812
  default=None, description=""""""
7600
7813
  )
7601
7814
 
@@ -7603,12 +7816,12 @@ class SubjectReferenceImage(_common.BaseModel):
7603
7816
  self,
7604
7817
  reference_image: Optional[Image] = None,
7605
7818
  reference_id: Optional[int] = None,
7606
- config: Optional["SubjectReferenceConfig"] = None,
7819
+ config: Optional['SubjectReferenceConfig'] = None,
7607
7820
  ):
7608
7821
  super().__init__(
7609
7822
  reference_image=reference_image,
7610
7823
  reference_id=reference_id,
7611
- reference_type="REFERENCE_TYPE_SUBJECT",
7824
+ reference_type='REFERENCE_TYPE_SUBJECT',
7612
7825
  )
7613
7826
  self.subject_image_config = config
7614
7827
 
@@ -7777,7 +7990,7 @@ class LiveServerMessage(_common.BaseModel):
7777
7990
  or not self.server_content.model_turn.parts
7778
7991
  ):
7779
7992
  return None
7780
- text = ""
7993
+ text = ''
7781
7994
  for part in self.server_content.model_turn.parts:
7782
7995
  if isinstance(part.text, str):
7783
7996
  if isinstance(part.thought, bool) and part.thought:
@@ -7795,7 +8008,7 @@ class LiveServerMessage(_common.BaseModel):
7795
8008
  or not self.server_content.model_turn.parts
7796
8009
  ):
7797
8010
  return None
7798
- concatenated_data = b""
8011
+ concatenated_data = b''
7799
8012
  for part in self.server_content.model_turn.parts:
7800
8013
  if part.inline_data and isinstance(part.inline_data.data, bytes):
7801
8014
  concatenated_data += part.inline_data.data
@@ -8020,7 +8233,7 @@ class LiveClientMessage(_common.BaseModel):
8020
8233
 
8021
8234
  setup: Optional[LiveClientSetup] = Field(
8022
8235
  default=None,
8023
- description="""Message to be sent in the first and only first client message.""",
8236
+ description="""Message to be sent by the system when connecting to the API. SDK users should not send this message.""",
8024
8237
  )
8025
8238
  client_content: Optional[LiveClientContent] = Field(
8026
8239
  default=None,
@@ -8039,7 +8252,7 @@ class LiveClientMessageDict(TypedDict, total=False):
8039
8252
  """Messages sent by the client in the API call."""
8040
8253
 
8041
8254
  setup: Optional[LiveClientSetupDict]
8042
- """Message to be sent in the first and only first client message."""
8255
+ """Message to be sent by the system when connecting to the API. SDK users should not send this message."""
8043
8256
 
8044
8257
  client_content: Optional[LiveClientContentDict]
8045
8258
  """Incremental update of the current conversation delivered from the client."""