google-genai 0.5.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/_api_client.py +164 -55
- google/genai/_common.py +37 -6
- google/genai/_extra_utils.py +3 -3
- google/genai/_replay_api_client.py +44 -32
- google/genai/_transformers.py +167 -38
- google/genai/batches.py +10 -10
- google/genai/caches.py +10 -10
- google/genai/client.py +2 -1
- google/genai/errors.py +1 -1
- google/genai/files.py +239 -40
- google/genai/live.py +5 -1
- google/genai/models.py +102 -30
- google/genai/tunings.py +8 -8
- google/genai/types.py +546 -348
- google/genai/version.py +1 -1
- google_genai-0.6.0.dist-info/METADATA +973 -0
- google_genai-0.6.0.dist-info/RECORD +25 -0
- google_genai-0.5.0.dist-info/METADATA +0 -888
- google_genai-0.5.0.dist-info/RECORD +0 -25
- {google_genai-0.5.0.dist-info → google_genai-0.6.0.dist-info}/LICENSE +0 -0
- {google_genai-0.5.0.dist-info → google_genai-0.6.0.dist-info}/WHEEL +0 -0
- {google_genai-0.5.0.dist-info → google_genai-0.6.0.dist-info}/top_level.txt +0 -0
google/genai/types.py
CHANGED
@@ -19,203 +19,295 @@ import datetime
|
|
19
19
|
import inspect
|
20
20
|
import json
|
21
21
|
import logging
|
22
|
-
from typing import Any, Callable, Literal, Optional, TypedDict, Union
|
22
|
+
from typing import Any, Callable, GenericAlias, Literal, Optional, TypedDict, Union
|
23
23
|
import PIL.Image
|
24
24
|
import pydantic
|
25
25
|
from pydantic import Field
|
26
26
|
from . import _common
|
27
27
|
|
28
28
|
|
29
|
-
Outcome
|
30
|
-
|
31
|
-
"OUTCOME_OK",
|
32
|
-
"OUTCOME_FAILED",
|
33
|
-
"OUTCOME_DEADLINE_EXCEEDED",
|
34
|
-
]
|
29
|
+
class Outcome(_common.CaseInSensitiveEnum):
|
30
|
+
"""Required. Outcome of the code execution."""
|
35
31
|
|
32
|
+
OUTCOME_UNSPECIFIED = 'OUTCOME_UNSPECIFIED'
|
33
|
+
OUTCOME_OK = 'OUTCOME_OK'
|
34
|
+
OUTCOME_FAILED = 'OUTCOME_FAILED'
|
35
|
+
OUTCOME_DEADLINE_EXCEEDED = 'OUTCOME_DEADLINE_EXCEEDED'
|
36
36
|
|
37
|
-
Language = Literal["LANGUAGE_UNSPECIFIED", "PYTHON"]
|
38
37
|
|
38
|
+
class Language(_common.CaseInSensitiveEnum):
|
39
|
+
"""Required. Programming language of the `code`."""
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
"STRING",
|
43
|
-
"NUMBER",
|
44
|
-
"INTEGER",
|
45
|
-
"BOOLEAN",
|
46
|
-
"ARRAY",
|
47
|
-
"OBJECT",
|
48
|
-
]
|
41
|
+
LANGUAGE_UNSPECIFIED = 'LANGUAGE_UNSPECIFIED'
|
42
|
+
PYTHON = 'PYTHON'
|
49
43
|
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
"HARM_CATEGORY_HATE_SPEECH",
|
54
|
-
"HARM_CATEGORY_DANGEROUS_CONTENT",
|
55
|
-
"HARM_CATEGORY_HARASSMENT",
|
56
|
-
"HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
57
|
-
"HARM_CATEGORY_CIVIC_INTEGRITY",
|
58
|
-
]
|
45
|
+
class Type(_common.CaseInSensitiveEnum):
|
46
|
+
"""A basic data type."""
|
59
47
|
|
48
|
+
TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'
|
49
|
+
STRING = 'STRING'
|
50
|
+
NUMBER = 'NUMBER'
|
51
|
+
INTEGER = 'INTEGER'
|
52
|
+
BOOLEAN = 'BOOLEAN'
|
53
|
+
ARRAY = 'ARRAY'
|
54
|
+
OBJECT = 'OBJECT'
|
60
55
|
|
61
|
-
HarmBlockMethod = Literal[
|
62
|
-
"HARM_BLOCK_METHOD_UNSPECIFIED", "SEVERITY", "PROBABILITY"
|
63
|
-
]
|
64
56
|
|
57
|
+
class HarmCategory(_common.CaseInSensitiveEnum):
|
58
|
+
"""Required. Harm category."""
|
65
59
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
"OFF",
|
73
|
-
]
|
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'
|
74
66
|
|
75
67
|
|
76
|
-
|
68
|
+
class HarmBlockMethod(_common.CaseInSensitiveEnum):
|
69
|
+
"""Optional.
|
77
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
|
+
"""
|
78
74
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
"MAX_TOKENS",
|
83
|
-
"SAFETY",
|
84
|
-
"RECITATION",
|
85
|
-
"OTHER",
|
86
|
-
"BLOCKLIST",
|
87
|
-
"PROHIBITED_CONTENT",
|
88
|
-
"SPII",
|
89
|
-
"MALFORMED_FUNCTION_CALL",
|
90
|
-
]
|
75
|
+
HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED'
|
76
|
+
SEVERITY = 'SEVERITY'
|
77
|
+
PROBABILITY = 'PROBABILITY'
|
91
78
|
|
92
79
|
|
93
|
-
|
94
|
-
|
95
|
-
]
|
80
|
+
class HarmBlockThreshold(_common.CaseInSensitiveEnum):
|
81
|
+
"""Required. The harm block threshold."""
|
96
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'
|
97
89
|
|
98
|
-
HarmSeverity = Literal[
|
99
|
-
"HARM_SEVERITY_UNSPECIFIED",
|
100
|
-
"HARM_SEVERITY_NEGLIGIBLE",
|
101
|
-
"HARM_SEVERITY_LOW",
|
102
|
-
"HARM_SEVERITY_MEDIUM",
|
103
|
-
"HARM_SEVERITY_HIGH",
|
104
|
-
]
|
105
90
|
|
91
|
+
class Mode(_common.CaseInSensitiveEnum):
|
92
|
+
"""The mode of the predictor to be used in dynamic retrieval."""
|
106
93
|
|
107
|
-
|
108
|
-
|
109
|
-
"SAFETY",
|
110
|
-
"OTHER",
|
111
|
-
"BLOCKLIST",
|
112
|
-
"PROHIBITED_CONTENT",
|
113
|
-
]
|
94
|
+
MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
|
95
|
+
MODE_DYNAMIC = 'MODE_DYNAMIC'
|
114
96
|
|
115
97
|
|
116
|
-
|
117
|
-
|
118
|
-
"DEDICATED_RESOURCES",
|
119
|
-
"AUTOMATIC_RESOURCES",
|
120
|
-
"SHARED_RESOURCES",
|
121
|
-
]
|
98
|
+
class State(_common.CaseInSensitiveEnum):
|
99
|
+
"""Output only. RagFile state."""
|
122
100
|
|
101
|
+
STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
|
102
|
+
ACTIVE = 'ACTIVE'
|
103
|
+
ERROR = 'ERROR'
|
123
104
|
|
124
|
-
JobState = Literal[
|
125
|
-
"JOB_STATE_UNSPECIFIED",
|
126
|
-
"JOB_STATE_QUEUED",
|
127
|
-
"JOB_STATE_PENDING",
|
128
|
-
"JOB_STATE_RUNNING",
|
129
|
-
"JOB_STATE_SUCCEEDED",
|
130
|
-
"JOB_STATE_FAILED",
|
131
|
-
"JOB_STATE_CANCELLING",
|
132
|
-
"JOB_STATE_CANCELLED",
|
133
|
-
"JOB_STATE_PAUSED",
|
134
|
-
"JOB_STATE_EXPIRED",
|
135
|
-
"JOB_STATE_UPDATING",
|
136
|
-
"JOB_STATE_PARTIALLY_SUCCEEDED",
|
137
|
-
]
|
138
105
|
|
106
|
+
class FinishReason(_common.CaseInSensitiveEnum):
|
107
|
+
"""Output only.
|
139
108
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
"ADAPTER_SIZE_FOUR",
|
144
|
-
"ADAPTER_SIZE_EIGHT",
|
145
|
-
"ADAPTER_SIZE_SIXTEEN",
|
146
|
-
"ADAPTER_SIZE_THIRTY_TWO",
|
147
|
-
]
|
109
|
+
The reason why the model stopped generating tokens. If empty, the model has
|
110
|
+
not stopped generating the tokens.
|
111
|
+
"""
|
148
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'
|
149
123
|
|
150
|
-
State = Literal["STATE_UNSPECIFIED", "ACTIVE", "ERROR"]
|
151
124
|
|
125
|
+
class HarmProbability(_common.CaseInSensitiveEnum):
|
126
|
+
"""Output only. Harm probability levels in the content."""
|
152
127
|
|
153
|
-
|
128
|
+
HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED'
|
129
|
+
NEGLIGIBLE = 'NEGLIGIBLE'
|
130
|
+
LOW = 'LOW'
|
131
|
+
MEDIUM = 'MEDIUM'
|
132
|
+
HIGH = 'HIGH'
|
154
133
|
|
155
134
|
|
156
|
-
|
135
|
+
class HarmSeverity(_common.CaseInSensitiveEnum):
|
136
|
+
"""Output only. Harm severity levels in the content."""
|
157
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'
|
158
143
|
|
159
|
-
MediaResolution = Literal[
|
160
|
-
"MEDIA_RESOLUTION_UNSPECIFIED",
|
161
|
-
"MEDIA_RESOLUTION_LOW",
|
162
|
-
"MEDIA_RESOLUTION_MEDIUM",
|
163
|
-
"MEDIA_RESOLUTION_HIGH",
|
164
|
-
]
|
165
144
|
|
145
|
+
class BlockedReason(_common.CaseInSensitiveEnum):
|
146
|
+
"""Output only. Blocked reason."""
|
166
147
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
]
|
148
|
+
BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED'
|
149
|
+
SAFETY = 'SAFETY'
|
150
|
+
OTHER = 'OTHER'
|
151
|
+
BLOCKLIST = 'BLOCKLIST'
|
152
|
+
PROHIBITED_CONTENT = 'PROHIBITED_CONTENT'
|
173
153
|
|
174
154
|
|
175
|
-
|
155
|
+
class DeploymentResourcesType(_common.CaseInSensitiveEnum):
|
156
|
+
""""""
|
176
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'
|
177
164
|
|
178
|
-
ImagePromptLanguage = Literal["auto", "en", "ja", "ko", "hi"]
|
179
165
|
|
166
|
+
class JobState(_common.CaseInSensitiveEnum):
|
167
|
+
"""Config class for the job state."""
|
180
168
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
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'
|
188
181
|
|
189
182
|
|
190
|
-
|
191
|
-
|
192
|
-
"CONTROL_TYPE_CANNY",
|
193
|
-
"CONTROL_TYPE_SCRIBBLE",
|
194
|
-
"CONTROL_TYPE_FACE_MESH",
|
195
|
-
]
|
183
|
+
class AdapterSize(_common.CaseInSensitiveEnum):
|
184
|
+
"""Optional. Adapter size for tuning."""
|
196
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'
|
197
192
|
|
198
|
-
SubjectReferenceType = Literal[
|
199
|
-
"SUBJECT_TYPE_DEFAULT",
|
200
|
-
"SUBJECT_TYPE_PERSON",
|
201
|
-
"SUBJECT_TYPE_ANIMAL",
|
202
|
-
"SUBJECT_TYPE_PRODUCT",
|
203
|
-
]
|
204
193
|
|
194
|
+
class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
|
195
|
+
"""Config class for the dynamic retrieval config mode."""
|
205
196
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
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'
|
216
254
|
|
217
255
|
|
218
|
-
|
256
|
+
class ControlReferenceType(_common.CaseInSensitiveEnum):
|
257
|
+
"""Enum representing the control type of a control reference image."""
|
258
|
+
|
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'
|
219
311
|
|
220
312
|
|
221
313
|
class VideoMetadata(_common.BaseModel):
|
@@ -474,16 +566,16 @@ class Part(_common.BaseModel):
|
|
474
566
|
)
|
475
567
|
|
476
568
|
@classmethod
|
477
|
-
def from_uri(cls, file_uri: str, mime_type: str) ->
|
569
|
+
def from_uri(cls, file_uri: str, mime_type: str) -> 'Part':
|
478
570
|
file_data = FileData(file_uri=file_uri, mime_type=mime_type)
|
479
571
|
return cls(file_data=file_data)
|
480
572
|
|
481
573
|
@classmethod
|
482
|
-
def from_text(cls, text: str) ->
|
574
|
+
def from_text(cls, text: str) -> 'Part':
|
483
575
|
return cls(text=text)
|
484
576
|
|
485
577
|
@classmethod
|
486
|
-
def from_bytes(cls, data: bytes, mime_type: str) ->
|
578
|
+
def from_bytes(cls, data: bytes, mime_type: str) -> 'Part':
|
487
579
|
inline_data = Blob(
|
488
580
|
data=data,
|
489
581
|
mime_type=mime_type,
|
@@ -491,31 +583,31 @@ class Part(_common.BaseModel):
|
|
491
583
|
return cls(inline_data=inline_data)
|
492
584
|
|
493
585
|
@classmethod
|
494
|
-
def from_function_call(cls, name: str, args: dict[str, Any]) ->
|
586
|
+
def from_function_call(cls, name: str, args: dict[str, Any]) -> 'Part':
|
495
587
|
function_call = FunctionCall(name=name, args=args)
|
496
588
|
return cls(function_call=function_call)
|
497
589
|
|
498
590
|
@classmethod
|
499
591
|
def from_function_response(
|
500
592
|
cls, name: str, response: dict[str, Any]
|
501
|
-
) ->
|
593
|
+
) -> 'Part':
|
502
594
|
function_response = FunctionResponse(name=name, response=response)
|
503
595
|
return cls(function_response=function_response)
|
504
596
|
|
505
597
|
@classmethod
|
506
|
-
def from_video_metadata(cls, end_offset: str, start_offset: str) ->
|
598
|
+
def from_video_metadata(cls, end_offset: str, start_offset: str) -> 'Part':
|
507
599
|
video_metadata = VideoMetadata(
|
508
600
|
end_offset=end_offset, start_offset=start_offset
|
509
601
|
)
|
510
602
|
return cls(video_metadata=video_metadata)
|
511
603
|
|
512
604
|
@classmethod
|
513
|
-
def from_executable_code(cls, code: str, language: Language) ->
|
605
|
+
def from_executable_code(cls, code: str, language: Language) -> 'Part':
|
514
606
|
executable_code = ExecutableCode(code=code, language=language)
|
515
607
|
return cls(executable_code=executable_code)
|
516
608
|
|
517
609
|
@classmethod
|
518
|
-
def from_code_execution_result(cls, outcome: Outcome, output: str) ->
|
610
|
+
def from_code_execution_result(cls, outcome: Outcome, output: str) -> 'Part':
|
519
611
|
code_execution_result = CodeExecutionResult(outcome=outcome, output=output)
|
520
612
|
return cls(code_execution_result=code_execution_result)
|
521
613
|
|
@@ -557,8 +649,6 @@ class PartDict(TypedDict, total=False):
|
|
557
649
|
|
558
650
|
|
559
651
|
PartOrDict = Union[Part, PartDict]
|
560
|
-
PartUnion = Union[Part, PIL.Image.Image, str]
|
561
|
-
PartUnionDict = Union[PartUnion, PartDict]
|
562
652
|
|
563
653
|
|
564
654
|
class Content(_common.BaseModel):
|
@@ -591,11 +681,6 @@ class ContentDict(TypedDict, total=False):
|
|
591
681
|
|
592
682
|
|
593
683
|
ContentOrDict = Union[Content, ContentDict]
|
594
|
-
ContentUnion = Union[Content, list[PartUnion], PartUnion]
|
595
|
-
ContentUnionDict = Union[ContentUnion, ContentDict]
|
596
|
-
|
597
|
-
ContentListUnion = Union[list[ContentUnion], ContentUnion]
|
598
|
-
ContentListUnionDict = Union[list[ContentUnionDict], ContentUnionDict]
|
599
684
|
|
600
685
|
|
601
686
|
class Schema(_common.BaseModel):
|
@@ -627,7 +712,7 @@ class Schema(_common.BaseModel):
|
|
627
712
|
default: Optional[Any] = Field(
|
628
713
|
default=None, description="""Optional. Default value of the data."""
|
629
714
|
)
|
630
|
-
any_of: list[
|
715
|
+
any_of: list['Schema'] = Field(
|
631
716
|
default=None,
|
632
717
|
description="""Optional. The value should be validated against any (one or more) of the subschemas in the list.""",
|
633
718
|
)
|
@@ -676,11 +761,11 @@ class Schema(_common.BaseModel):
|
|
676
761
|
default=None,
|
677
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""",
|
678
763
|
)
|
679
|
-
items:
|
764
|
+
items: 'Schema' = Field(
|
680
765
|
default=None,
|
681
766
|
description="""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY.""",
|
682
767
|
)
|
683
|
-
properties: dict[str,
|
768
|
+
properties: dict[str, 'Schema'] = Field(
|
684
769
|
default=None,
|
685
770
|
description="""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT.""",
|
686
771
|
)
|
@@ -714,7 +799,7 @@ class SchemaDict(TypedDict, total=False):
|
|
714
799
|
default: Optional[Any]
|
715
800
|
"""Optional. Default value of the data."""
|
716
801
|
|
717
|
-
any_of: list[
|
802
|
+
any_of: list['SchemaDict']
|
718
803
|
"""Optional. The value should be validated against any (one or more) of the subschemas in the list."""
|
719
804
|
|
720
805
|
max_length: Optional[int]
|
@@ -753,10 +838,10 @@ class SchemaDict(TypedDict, total=False):
|
|
753
838
|
format: Optional[str]
|
754
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"""
|
755
840
|
|
756
|
-
items:
|
841
|
+
items: 'SchemaDict'
|
757
842
|
"""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY."""
|
758
843
|
|
759
|
-
properties: dict[str,
|
844
|
+
properties: dict[str, 'SchemaDict']
|
760
845
|
"""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT."""
|
761
846
|
|
762
847
|
required: Optional[list[str]]
|
@@ -764,8 +849,6 @@ class SchemaDict(TypedDict, total=False):
|
|
764
849
|
|
765
850
|
|
766
851
|
SchemaOrDict = Union[Schema, SchemaDict]
|
767
|
-
SchemaUnion = Union[dict, type, Schema]
|
768
|
-
SchemaUnionDict = Union[SchemaUnion, SchemaDict]
|
769
852
|
|
770
853
|
|
771
854
|
class SafetySetting(_common.BaseModel):
|
@@ -830,27 +913,27 @@ class FunctionDeclaration(_common.BaseModel):
|
|
830
913
|
def _get_variant(cls, client) -> str:
|
831
914
|
"""Returns the function variant based on the provided client object."""
|
832
915
|
if client.vertexai:
|
833
|
-
return
|
916
|
+
return 'VERTEX_AI'
|
834
917
|
else:
|
835
|
-
return
|
918
|
+
return 'GOOGLE_AI'
|
836
919
|
|
837
920
|
@classmethod
|
838
921
|
def from_function_with_options(
|
839
922
|
cls,
|
840
923
|
func: Callable,
|
841
|
-
variant: Literal[
|
842
|
-
) ->
|
924
|
+
variant: Literal['GOOGLE_AI', 'VERTEX_AI', 'DEFAULT'] = 'GOOGLE_AI',
|
925
|
+
) -> 'FunctionDeclaration':
|
843
926
|
"""Converts a function to a FunctionDeclaration based on an API endpoint.
|
844
927
|
|
845
928
|
Supported endpoints are: 'GOOGLE_AI', 'VERTEX_AI', or 'DEFAULT'.
|
846
929
|
"""
|
847
930
|
from . import _automatic_function_calling_util
|
848
931
|
|
849
|
-
supported_variants = [
|
932
|
+
supported_variants = ['GOOGLE_AI', 'VERTEX_AI', 'DEFAULT']
|
850
933
|
if variant not in supported_variants:
|
851
934
|
raise ValueError(
|
852
|
-
f
|
853
|
-
f
|
935
|
+
f'Unsupported variant: {variant}. Supported variants are:'
|
936
|
+
f' {", ".join(supported_variants)}'
|
854
937
|
)
|
855
938
|
|
856
939
|
# TODO: b/382524014 - Add support for DEFAULT API endpoint.
|
@@ -872,16 +955,16 @@ class FunctionDeclaration(_common.BaseModel):
|
|
872
955
|
)
|
873
956
|
if parameters_properties:
|
874
957
|
declaration.parameters = Schema(
|
875
|
-
type=
|
958
|
+
type='OBJECT',
|
876
959
|
properties=parameters_properties,
|
877
960
|
)
|
878
|
-
if variant ==
|
961
|
+
if variant == 'VERTEX_AI':
|
879
962
|
declaration.parameters.required = (
|
880
963
|
_automatic_function_calling_util._get_required_fields(
|
881
964
|
declaration.parameters
|
882
965
|
)
|
883
966
|
)
|
884
|
-
if not variant ==
|
967
|
+
if not variant == 'VERTEX_AI':
|
885
968
|
return declaration
|
886
969
|
|
887
970
|
return_annotation = inspect.signature(func).return_annotation
|
@@ -892,7 +975,7 @@ class FunctionDeclaration(_common.BaseModel):
|
|
892
975
|
_automatic_function_calling_util._parse_schema_from_parameter(
|
893
976
|
variant,
|
894
977
|
inspect.Parameter(
|
895
|
-
|
978
|
+
'return_value',
|
896
979
|
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
897
980
|
annotation=return_annotation,
|
898
981
|
),
|
@@ -902,7 +985,7 @@ class FunctionDeclaration(_common.BaseModel):
|
|
902
985
|
return declaration
|
903
986
|
|
904
987
|
@classmethod
|
905
|
-
def
|
988
|
+
def from_callable(cls, client, func: Callable) -> 'FunctionDeclaration':
|
906
989
|
"""Converts a function to a FunctionDeclaration."""
|
907
990
|
return cls.from_function_with_options(
|
908
991
|
variant=cls._get_variant(client),
|
@@ -1310,8 +1393,6 @@ class SpeechConfigDict(TypedDict, total=False):
|
|
1310
1393
|
|
1311
1394
|
|
1312
1395
|
SpeechConfigOrDict = Union[SpeechConfig, SpeechConfigDict]
|
1313
|
-
SpeechConfigUnion = Union[SpeechConfig, str]
|
1314
|
-
SpeechConfigUnionDict = Union[SpeechConfigUnion, SpeechConfigDict]
|
1315
1396
|
|
1316
1397
|
|
1317
1398
|
class AutomaticFunctionCallingConfig(_common.BaseModel):
|
@@ -1373,11 +1454,186 @@ AutomaticFunctionCallingConfigOrDict = Union[
|
|
1373
1454
|
]
|
1374
1455
|
|
1375
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
|
+
|
1376
1632
|
class GenerationConfigRoutingConfigAutoRoutingMode(_common.BaseModel):
|
1377
1633
|
"""When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference."""
|
1378
1634
|
|
1379
1635
|
model_routing_preference: Optional[
|
1380
|
-
Literal[
|
1636
|
+
Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']
|
1381
1637
|
] = Field(default=None, description="""The model routing preference.""")
|
1382
1638
|
|
1383
1639
|
|
@@ -1385,7 +1641,7 @@ class GenerationConfigRoutingConfigAutoRoutingModeDict(TypedDict, total=False):
|
|
1385
1641
|
"""When automated routing is specified, the routing will be determined by the pretrained routing model and customer provided model routing preference."""
|
1386
1642
|
|
1387
1643
|
model_routing_preference: Optional[
|
1388
|
-
Literal[
|
1644
|
+
Literal['UNKNOWN', 'PRIORITIZE_QUALITY', 'BALANCED', 'PRIORITIZE_COST']
|
1389
1645
|
]
|
1390
1646
|
"""The model routing preference."""
|
1391
1647
|
|
@@ -1446,6 +1702,12 @@ GenerationConfigRoutingConfigOrDict = Union[
|
|
1446
1702
|
]
|
1447
1703
|
|
1448
1704
|
|
1705
|
+
SpeechConfigUnion = Union[SpeechConfig, str]
|
1706
|
+
|
1707
|
+
|
1708
|
+
SpeechConfigUnionDict = Union[SpeechConfigUnion, SpeechConfigDict]
|
1709
|
+
|
1710
|
+
|
1449
1711
|
class GenerateContentConfig(_common.BaseModel):
|
1450
1712
|
"""Class for configuring optional model parameters.
|
1451
1713
|
|
@@ -1587,11 +1849,22 @@ class GenerateContentConfig(_common.BaseModel):
|
|
1587
1849
|
description="""The speech generation configuration.
|
1588
1850
|
""",
|
1589
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
|
+
)
|
1590
1858
|
automatic_function_calling: Optional[AutomaticFunctionCallingConfig] = Field(
|
1591
1859
|
default=None,
|
1592
1860
|
description="""The configuration for automatic function calling.
|
1593
1861
|
""",
|
1594
1862
|
)
|
1863
|
+
thinking_config: Optional[ThinkingConfig] = Field(
|
1864
|
+
default=None,
|
1865
|
+
description="""The thinking features configuration.
|
1866
|
+
""",
|
1867
|
+
)
|
1595
1868
|
|
1596
1869
|
|
1597
1870
|
class GenerateContentConfigDict(TypedDict, total=False):
|
@@ -1713,16 +1986,31 @@ class GenerateContentConfigDict(TypedDict, total=False):
|
|
1713
1986
|
"""The speech generation configuration.
|
1714
1987
|
"""
|
1715
1988
|
|
1989
|
+
audio_timestamp: Optional[bool]
|
1990
|
+
"""If enabled, audio timestamp will be included in the request to the
|
1991
|
+
model.
|
1992
|
+
"""
|
1993
|
+
|
1716
1994
|
automatic_function_calling: Optional[AutomaticFunctionCallingConfigDict]
|
1717
1995
|
"""The configuration for automatic function calling.
|
1718
1996
|
"""
|
1719
1997
|
|
1998
|
+
thinking_config: Optional[ThinkingConfigDict]
|
1999
|
+
"""The thinking features configuration.
|
2000
|
+
"""
|
2001
|
+
|
1720
2002
|
|
1721
2003
|
GenerateContentConfigOrDict = Union[
|
1722
2004
|
GenerateContentConfig, GenerateContentConfigDict
|
1723
2005
|
]
|
1724
2006
|
|
1725
2007
|
|
2008
|
+
ContentListUnion = Union[list[ContentUnion], ContentUnion]
|
2009
|
+
|
2010
|
+
|
2011
|
+
ContentListUnionDict = Union[list[ContentUnionDict], ContentUnionDict]
|
2012
|
+
|
2013
|
+
|
1726
2014
|
class _GenerateContentParameters(_common.BaseModel):
|
1727
2015
|
"""Class for configuring the content of the request to the model."""
|
1728
2016
|
|
@@ -2471,20 +2759,20 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2471
2759
|
return None
|
2472
2760
|
if len(self.candidates) > 1:
|
2473
2761
|
logging.warning(
|
2474
|
-
f
|
2475
|
-
|
2476
|
-
|
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.'
|
2477
2765
|
)
|
2478
|
-
text =
|
2766
|
+
text = ''
|
2479
2767
|
any_text_part_text = False
|
2480
2768
|
for part in self.candidates[0].content.parts:
|
2481
2769
|
for field_name, field_value in part.dict(
|
2482
|
-
exclude={
|
2770
|
+
exclude={'text', 'thought'}
|
2483
2771
|
).items():
|
2484
2772
|
if field_value is not None:
|
2485
2773
|
raise ValueError(
|
2486
|
-
|
2487
|
-
f
|
2774
|
+
'GenerateContentResponse.text only supports text parts, but got'
|
2775
|
+
f' {field_name} part{part}'
|
2488
2776
|
)
|
2489
2777
|
if isinstance(part.text, str):
|
2490
2778
|
if isinstance(part.thought, bool) and part.thought:
|
@@ -2505,8 +2793,8 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2505
2793
|
return None
|
2506
2794
|
if len(self.candidates) > 1:
|
2507
2795
|
logging.warning(
|
2508
|
-
|
2509
|
-
|
2796
|
+
'Warning: there are multiple candidates in the response, returning'
|
2797
|
+
' function calls from the first one.'
|
2510
2798
|
)
|
2511
2799
|
function_calls = [
|
2512
2800
|
part.function_call
|
@@ -2524,7 +2812,7 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2524
2812
|
|
2525
2813
|
# Handles response schema.
|
2526
2814
|
response_schema = _common.get_value_by_path(
|
2527
|
-
kwargs, [
|
2815
|
+
kwargs, ['config', 'response_schema']
|
2528
2816
|
)
|
2529
2817
|
if inspect.isclass(response_schema) and issubclass(
|
2530
2818
|
response_schema, pydantic.BaseModel
|
@@ -2536,6 +2824,23 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2536
2824
|
except pydantic.ValidationError:
|
2537
2825
|
pass
|
2538
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
|
+
|
2539
2844
|
elif isinstance(response_schema, dict) or isinstance(
|
2540
2845
|
response_schema, pydantic.BaseModel
|
2541
2846
|
):
|
@@ -3028,7 +3333,7 @@ class Image(_common.BaseModel):
|
|
3028
3333
|
"""Image."""
|
3029
3334
|
|
3030
3335
|
@staticmethod
|
3031
|
-
def from_file(location: str) ->
|
3336
|
+
def from_file(location: str) -> 'Image':
|
3032
3337
|
"""Lazy-loads an image from a local file or Google Cloud Storage.
|
3033
3338
|
|
3034
3339
|
Args:
|
@@ -3043,17 +3348,17 @@ class Image(_common.BaseModel):
|
|
3043
3348
|
|
3044
3349
|
parsed_url = urllib.parse.urlparse(location)
|
3045
3350
|
if (
|
3046
|
-
parsed_url.scheme ==
|
3047
|
-
and parsed_url.netloc ==
|
3351
|
+
parsed_url.scheme == 'https'
|
3352
|
+
and parsed_url.netloc == 'storage.googleapis.com'
|
3048
3353
|
):
|
3049
3354
|
parsed_url = parsed_url._replace(
|
3050
|
-
scheme=
|
3051
|
-
netloc=
|
3052
|
-
path=f
|
3355
|
+
scheme='gs',
|
3356
|
+
netloc='',
|
3357
|
+
path=f'/{urllib.parse.unquote(parsed_url.path)}',
|
3053
3358
|
)
|
3054
3359
|
location = urllib.parse.urlunparse(parsed_url)
|
3055
3360
|
|
3056
|
-
if parsed_url.scheme ==
|
3361
|
+
if parsed_url.scheme == 'gs':
|
3057
3362
|
return Image(gcs_uri=location)
|
3058
3363
|
|
3059
3364
|
# Load image from local path
|
@@ -3079,7 +3384,7 @@ class Image(_common.BaseModel):
|
|
3079
3384
|
IPython_display.display(self._pil_image)
|
3080
3385
|
|
3081
3386
|
@property
|
3082
|
-
def _pil_image(self) ->
|
3387
|
+
def _pil_image(self) -> 'PIL_Image.Image':
|
3083
3388
|
try:
|
3084
3389
|
from PIL import Image as PIL_Image
|
3085
3390
|
except ImportError:
|
@@ -3089,8 +3394,8 @@ class Image(_common.BaseModel):
|
|
3089
3394
|
if self._loaded_image is None:
|
3090
3395
|
if not PIL_Image:
|
3091
3396
|
raise RuntimeError(
|
3092
|
-
|
3093
|
-
|
3397
|
+
'The PIL module is not available. Please install the Pillow'
|
3398
|
+
' package.'
|
3094
3399
|
)
|
3095
3400
|
self._loaded_image = PIL_Image.open(io.BytesIO(self.image_bytes))
|
3096
3401
|
return self._loaded_image
|
@@ -3106,29 +3411,27 @@ class Image(_common.BaseModel):
|
|
3106
3411
|
pathlib.Path(location).write_bytes(self.image_bytes)
|
3107
3412
|
|
3108
3413
|
|
3109
|
-
Modality = Literal["MODALITY_UNSPECIFIED", "TEXT", "IMAGE", "AUDIO"]
|
3110
|
-
|
3111
3414
|
JOB_STATES_SUCCEEDED_VERTEX = [
|
3112
|
-
|
3415
|
+
'JOB_STATE_SUCCEEDED',
|
3113
3416
|
]
|
3114
3417
|
|
3115
3418
|
JOB_STATES_SUCCEEDED_MLDEV = [
|
3116
|
-
|
3419
|
+
'ACTIVE',
|
3117
3420
|
]
|
3118
3421
|
|
3119
3422
|
JOB_STATES_SUCCEEDED = JOB_STATES_SUCCEEDED_VERTEX + JOB_STATES_SUCCEEDED_MLDEV
|
3120
3423
|
|
3121
3424
|
|
3122
3425
|
JOB_STATES_ENDED_VERTEX = [
|
3123
|
-
|
3124
|
-
|
3125
|
-
|
3126
|
-
|
3426
|
+
'JOB_STATE_SUCCEEDED',
|
3427
|
+
'JOB_STATE_FAILED',
|
3428
|
+
'JOB_STATE_CANCELLED',
|
3429
|
+
'JOB_STATE_EXPIRED',
|
3127
3430
|
]
|
3128
3431
|
|
3129
3432
|
JOB_STATES_ENDED_MLDEV = [
|
3130
|
-
|
3131
|
-
|
3433
|
+
'ACTIVE',
|
3434
|
+
'FAILED',
|
3132
3435
|
]
|
3133
3436
|
|
3134
3437
|
JOB_STATES_ENDED = JOB_STATES_ENDED_VERTEX + JOB_STATES_ENDED_MLDEV
|
@@ -6159,129 +6462,6 @@ _ListFilesParametersOrDict = Union[
|
|
6159
6462
|
]
|
6160
6463
|
|
6161
6464
|
|
6162
|
-
class FileStatus(_common.BaseModel):
|
6163
|
-
"""Status of a File that uses a common error model."""
|
6164
|
-
|
6165
|
-
details: Optional[list[dict[str, Any]]] = Field(
|
6166
|
-
default=None,
|
6167
|
-
description="""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] = Field(
|
6170
|
-
default=None,
|
6171
|
-
description="""A list of messages that carry the error details. There is a common set of message types for APIs to use.""",
|
6172
|
-
)
|
6173
|
-
code: Optional[int] = Field(
|
6174
|
-
default=None, description="""The status code. 0 for OK, 1 for CANCELLED"""
|
6175
|
-
)
|
6176
|
-
|
6177
|
-
|
6178
|
-
class FileStatusDict(TypedDict, total=False):
|
6179
|
-
"""Status of a File that uses a common error model."""
|
6180
|
-
|
6181
|
-
details: Optional[list[dict[str, Any]]]
|
6182
|
-
"""A list of messages that carry the error details. There is a common set of message types for APIs to use."""
|
6183
|
-
|
6184
|
-
message: Optional[str]
|
6185
|
-
"""A list of messages that carry the error details. There is a common set of message types for APIs to use."""
|
6186
|
-
|
6187
|
-
code: Optional[int]
|
6188
|
-
"""The status code. 0 for OK, 1 for CANCELLED"""
|
6189
|
-
|
6190
|
-
|
6191
|
-
FileStatusOrDict = Union[FileStatus, FileStatusDict]
|
6192
|
-
|
6193
|
-
|
6194
|
-
class File(_common.BaseModel):
|
6195
|
-
"""A file uploaded to the API."""
|
6196
|
-
|
6197
|
-
name: Optional[str] = Field(
|
6198
|
-
default=None,
|
6199
|
-
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`""",
|
6200
|
-
)
|
6201
|
-
display_name: Optional[str] = Field(
|
6202
|
-
default=None,
|
6203
|
-
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'""",
|
6204
|
-
)
|
6205
|
-
mime_type: Optional[str] = Field(
|
6206
|
-
default=None, description="""Output only. MIME type of the file."""
|
6207
|
-
)
|
6208
|
-
size_bytes: Optional[int] = Field(
|
6209
|
-
default=None, description="""Output only. Size of the file in bytes."""
|
6210
|
-
)
|
6211
|
-
create_time: Optional[datetime.datetime] = Field(
|
6212
|
-
default=None,
|
6213
|
-
description="""Output only. The timestamp of when the `File` was created.""",
|
6214
|
-
)
|
6215
|
-
expiration_time: Optional[datetime.datetime] = Field(
|
6216
|
-
default=None,
|
6217
|
-
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'""",
|
6218
|
-
)
|
6219
|
-
update_time: Optional[datetime.datetime] = Field(
|
6220
|
-
default=None,
|
6221
|
-
description="""Output only. The timestamp of when the `File` was last updated.""",
|
6222
|
-
)
|
6223
|
-
sha256_hash: Optional[bytes] = Field(
|
6224
|
-
default=None,
|
6225
|
-
description="""Output only. SHA-256 hash of the uploaded bytes.""",
|
6226
|
-
)
|
6227
|
-
uri: Optional[str] = Field(
|
6228
|
-
default=None, description="""Output only. The URI of the `File`."""
|
6229
|
-
)
|
6230
|
-
state: Optional[FileState] = Field(
|
6231
|
-
default=None, description="""Output only. Processing state of the File."""
|
6232
|
-
)
|
6233
|
-
video_metadata: Optional[dict[str, Any]] = Field(
|
6234
|
-
default=None, description="""Output only. Metadata for a video."""
|
6235
|
-
)
|
6236
|
-
error: Optional[FileStatus] = Field(
|
6237
|
-
default=None,
|
6238
|
-
description="""Output only. Error status if File processing failed.""",
|
6239
|
-
)
|
6240
|
-
|
6241
|
-
|
6242
|
-
class FileDict(TypedDict, total=False):
|
6243
|
-
"""A file uploaded to the API."""
|
6244
|
-
|
6245
|
-
name: Optional[str]
|
6246
|
-
"""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`"""
|
6247
|
-
|
6248
|
-
display_name: Optional[str]
|
6249
|
-
"""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'"""
|
6250
|
-
|
6251
|
-
mime_type: Optional[str]
|
6252
|
-
"""Output only. MIME type of the file."""
|
6253
|
-
|
6254
|
-
size_bytes: Optional[int]
|
6255
|
-
"""Output only. Size of the file in bytes."""
|
6256
|
-
|
6257
|
-
create_time: Optional[datetime.datetime]
|
6258
|
-
"""Output only. The timestamp of when the `File` was created."""
|
6259
|
-
|
6260
|
-
expiration_time: Optional[datetime.datetime]
|
6261
|
-
"""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'"""
|
6262
|
-
|
6263
|
-
update_time: Optional[datetime.datetime]
|
6264
|
-
"""Output only. The timestamp of when the `File` was last updated."""
|
6265
|
-
|
6266
|
-
sha256_hash: Optional[bytes]
|
6267
|
-
"""Output only. SHA-256 hash of the uploaded bytes."""
|
6268
|
-
|
6269
|
-
uri: Optional[str]
|
6270
|
-
"""Output only. The URI of the `File`."""
|
6271
|
-
|
6272
|
-
state: Optional[FileState]
|
6273
|
-
"""Output only. Processing state of the File."""
|
6274
|
-
|
6275
|
-
video_metadata: Optional[dict[str, Any]]
|
6276
|
-
"""Output only. Metadata for a video."""
|
6277
|
-
|
6278
|
-
error: Optional[FileStatusDict]
|
6279
|
-
"""Output only. Error status if File processing failed."""
|
6280
|
-
|
6281
|
-
|
6282
|
-
FileOrDict = Union[File, FileDict]
|
6283
|
-
|
6284
|
-
|
6285
6465
|
class ListFilesResponse(_common.BaseModel):
|
6286
6466
|
"""Response for the list files method."""
|
6287
6467
|
|
@@ -7224,6 +7404,24 @@ class UploadFileConfigDict(TypedDict, total=False):
|
|
7224
7404
|
UploadFileConfigOrDict = Union[UploadFileConfig, UploadFileConfigDict]
|
7225
7405
|
|
7226
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
|
+
|
7227
7425
|
class UpscaleImageConfig(_common.BaseModel):
|
7228
7426
|
"""Configuration for upscaling an image.
|
7229
7427
|
|
@@ -7343,7 +7541,7 @@ class RawReferenceImage(_common.BaseModel):
|
|
7343
7541
|
super().__init__(
|
7344
7542
|
reference_image=reference_image,
|
7345
7543
|
reference_id=reference_id,
|
7346
|
-
reference_type=
|
7544
|
+
reference_type='REFERENCE_TYPE_RAW',
|
7347
7545
|
)
|
7348
7546
|
|
7349
7547
|
|
@@ -7395,7 +7593,7 @@ class MaskReferenceImage(_common.BaseModel):
|
|
7395
7593
|
description="""Configuration for the mask reference image.""",
|
7396
7594
|
)
|
7397
7595
|
"""Re-map config to mask_reference_config to send to API."""
|
7398
|
-
mask_image_config: Optional[
|
7596
|
+
mask_image_config: Optional['MaskReferenceConfig'] = Field(
|
7399
7597
|
default=None, description=""""""
|
7400
7598
|
)
|
7401
7599
|
|
@@ -7403,12 +7601,12 @@ class MaskReferenceImage(_common.BaseModel):
|
|
7403
7601
|
self,
|
7404
7602
|
reference_image: Optional[Image] = None,
|
7405
7603
|
reference_id: Optional[int] = None,
|
7406
|
-
config: Optional[
|
7604
|
+
config: Optional['MaskReferenceConfig'] = None,
|
7407
7605
|
):
|
7408
7606
|
super().__init__(
|
7409
7607
|
reference_image=reference_image,
|
7410
7608
|
reference_id=reference_id,
|
7411
|
-
reference_type=
|
7609
|
+
reference_type='REFERENCE_TYPE_MASK',
|
7412
7610
|
)
|
7413
7611
|
self.mask_image_config = config
|
7414
7612
|
|
@@ -7468,7 +7666,7 @@ class ControlReferenceImage(_common.BaseModel):
|
|
7468
7666
|
description="""Configuration for the control reference image.""",
|
7469
7667
|
)
|
7470
7668
|
"""Re-map config to control_reference_config to send to API."""
|
7471
|
-
control_image_config: Optional[
|
7669
|
+
control_image_config: Optional['ControlReferenceConfig'] = Field(
|
7472
7670
|
default=None, description=""""""
|
7473
7671
|
)
|
7474
7672
|
|
@@ -7476,12 +7674,12 @@ class ControlReferenceImage(_common.BaseModel):
|
|
7476
7674
|
self,
|
7477
7675
|
reference_image: Optional[Image] = None,
|
7478
7676
|
reference_id: Optional[int] = None,
|
7479
|
-
config: Optional[
|
7677
|
+
config: Optional['ControlReferenceConfig'] = None,
|
7480
7678
|
):
|
7481
7679
|
super().__init__(
|
7482
7680
|
reference_image=reference_image,
|
7483
7681
|
reference_id=reference_id,
|
7484
|
-
reference_type=
|
7682
|
+
reference_type='REFERENCE_TYPE_CONTROL',
|
7485
7683
|
)
|
7486
7684
|
self.control_image_config = config
|
7487
7685
|
|
@@ -7541,7 +7739,7 @@ class StyleReferenceImage(_common.BaseModel):
|
|
7541
7739
|
description="""Configuration for the style reference image.""",
|
7542
7740
|
)
|
7543
7741
|
"""Re-map config to style_reference_config to send to API."""
|
7544
|
-
style_image_config: Optional[
|
7742
|
+
style_image_config: Optional['StyleReferenceConfig'] = Field(
|
7545
7743
|
default=None, description=""""""
|
7546
7744
|
)
|
7547
7745
|
|
@@ -7549,12 +7747,12 @@ class StyleReferenceImage(_common.BaseModel):
|
|
7549
7747
|
self,
|
7550
7748
|
reference_image: Optional[Image] = None,
|
7551
7749
|
reference_id: Optional[int] = None,
|
7552
|
-
config: Optional[
|
7750
|
+
config: Optional['StyleReferenceConfig'] = None,
|
7553
7751
|
):
|
7554
7752
|
super().__init__(
|
7555
7753
|
reference_image=reference_image,
|
7556
7754
|
reference_id=reference_id,
|
7557
|
-
reference_type=
|
7755
|
+
reference_type='REFERENCE_TYPE_STYLE',
|
7558
7756
|
)
|
7559
7757
|
self.style_image_config = config
|
7560
7758
|
|
@@ -7610,7 +7808,7 @@ class SubjectReferenceImage(_common.BaseModel):
|
|
7610
7808
|
description="""Configuration for the subject reference image.""",
|
7611
7809
|
)
|
7612
7810
|
"""Re-map config to subject_reference_config to send to API."""
|
7613
|
-
subject_image_config: Optional[
|
7811
|
+
subject_image_config: Optional['SubjectReferenceConfig'] = Field(
|
7614
7812
|
default=None, description=""""""
|
7615
7813
|
)
|
7616
7814
|
|
@@ -7618,12 +7816,12 @@ class SubjectReferenceImage(_common.BaseModel):
|
|
7618
7816
|
self,
|
7619
7817
|
reference_image: Optional[Image] = None,
|
7620
7818
|
reference_id: Optional[int] = None,
|
7621
|
-
config: Optional[
|
7819
|
+
config: Optional['SubjectReferenceConfig'] = None,
|
7622
7820
|
):
|
7623
7821
|
super().__init__(
|
7624
7822
|
reference_image=reference_image,
|
7625
7823
|
reference_id=reference_id,
|
7626
|
-
reference_type=
|
7824
|
+
reference_type='REFERENCE_TYPE_SUBJECT',
|
7627
7825
|
)
|
7628
7826
|
self.subject_image_config = config
|
7629
7827
|
|
@@ -7792,7 +7990,7 @@ class LiveServerMessage(_common.BaseModel):
|
|
7792
7990
|
or not self.server_content.model_turn.parts
|
7793
7991
|
):
|
7794
7992
|
return None
|
7795
|
-
text =
|
7993
|
+
text = ''
|
7796
7994
|
for part in self.server_content.model_turn.parts:
|
7797
7995
|
if isinstance(part.text, str):
|
7798
7996
|
if isinstance(part.thought, bool) and part.thought:
|
@@ -7810,7 +8008,7 @@ class LiveServerMessage(_common.BaseModel):
|
|
7810
8008
|
or not self.server_content.model_turn.parts
|
7811
8009
|
):
|
7812
8010
|
return None
|
7813
|
-
concatenated_data = b
|
8011
|
+
concatenated_data = b''
|
7814
8012
|
for part in self.server_content.model_turn.parts:
|
7815
8013
|
if part.inline_data and isinstance(part.inline_data.data, bytes):
|
7816
8014
|
concatenated_data += part.inline_data.data
|