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/_transformers.py
CHANGED
@@ -21,10 +21,12 @@ import inspect
|
|
21
21
|
import io
|
22
22
|
import re
|
23
23
|
import time
|
24
|
-
|
24
|
+
import typing
|
25
|
+
from typing import Any, GenericAlias, Optional, Union
|
25
26
|
|
26
27
|
import PIL.Image
|
27
28
|
import PIL.PngImagePlugin
|
29
|
+
import pydantic
|
28
30
|
|
29
31
|
from . import _api_client
|
30
32
|
from . import types
|
@@ -35,7 +37,7 @@ def _resource_name(
|
|
35
37
|
resource_name: str,
|
36
38
|
*,
|
37
39
|
collection_identifier: str,
|
38
|
-
|
40
|
+
collection_hierarchy_depth: int = 2,
|
39
41
|
):
|
40
42
|
# pylint: disable=line-too-long
|
41
43
|
"""Prepends resource name with project, location, collection_identifier if needed.
|
@@ -48,13 +50,13 @@ def _resource_name(
|
|
48
50
|
Args:
|
49
51
|
client: The API client.
|
50
52
|
resource_name: The user input resource name to be completed.
|
51
|
-
collection_identifier: The collection identifier to be prepended.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
collection_identifier: The collection identifier to be prepended. See
|
54
|
+
collection identifiers in https://google.aip.dev/122.
|
55
|
+
collection_hierarchy_depth: The collection hierarchy depth. Only set this
|
56
|
+
field when the resource has nested collections. For example,
|
57
|
+
`users/vhugo1802/events/birthday-dinner-226`, the collection_identifier is
|
58
|
+
`users` and collection_hierarchy_depth is 4. See nested collections in
|
59
|
+
https://google.aip.dev/122.
|
58
60
|
|
59
61
|
Example:
|
60
62
|
|
@@ -62,7 +64,8 @@ def _resource_name(
|
|
62
64
|
client.vertexai = True
|
63
65
|
client.project = 'bar'
|
64
66
|
client.location = 'us-west1'
|
65
|
-
_resource_name(client, 'cachedContents/123',
|
67
|
+
_resource_name(client, 'cachedContents/123',
|
68
|
+
collection_identifier='cachedContents')
|
66
69
|
returns: 'projects/bar/locations/us-west1/cachedContents/123'
|
67
70
|
|
68
71
|
Example:
|
@@ -72,7 +75,8 @@ def _resource_name(
|
|
72
75
|
client.vertexai = True
|
73
76
|
client.project = 'bar'
|
74
77
|
client.location = 'us-west1'
|
75
|
-
_resource_name(client, resource_name,
|
78
|
+
_resource_name(client, resource_name,
|
79
|
+
collection_identifier='cachedContents')
|
76
80
|
returns: 'projects/foo/locations/us-central1/cachedContents/123'
|
77
81
|
|
78
82
|
Example:
|
@@ -80,7 +84,8 @@ def _resource_name(
|
|
80
84
|
resource_name = '123'
|
81
85
|
# resource_name = 'cachedContents/123'
|
82
86
|
client.vertexai = False
|
83
|
-
_resource_name(client, resource_name,
|
87
|
+
_resource_name(client, resource_name,
|
88
|
+
collection_identifier='cachedContents')
|
84
89
|
returns 'cachedContents/123'
|
85
90
|
|
86
91
|
Example:
|
@@ -88,7 +93,8 @@ def _resource_name(
|
|
88
93
|
resource_prefix = 'cachedContents'
|
89
94
|
client.vertexai = False
|
90
95
|
# client.vertexai = True
|
91
|
-
_resource_name(client, resource_name,
|
96
|
+
_resource_name(client, resource_name,
|
97
|
+
collection_identifier='cachedContents')
|
92
98
|
returns: 'some/wrong/cachedContents/resource/name/123'
|
93
99
|
|
94
100
|
Returns:
|
@@ -99,7 +105,7 @@ def _resource_name(
|
|
99
105
|
# Check if prepending the collection identifier won't violate the
|
100
106
|
# collection hierarchy depth.
|
101
107
|
and f'{collection_identifier}/{resource_name}'.count('/') + 1
|
102
|
-
==
|
108
|
+
== collection_hierarchy_depth
|
103
109
|
)
|
104
110
|
if client.vertexai:
|
105
111
|
if resource_name.startswith('projects/'):
|
@@ -142,6 +148,7 @@ def t_model(client: _api_client.ApiClient, model: str):
|
|
142
148
|
else:
|
143
149
|
return f'models/{model}'
|
144
150
|
|
151
|
+
|
145
152
|
def t_models_url(api_client: _api_client.ApiClient, base_models: bool) -> str:
|
146
153
|
if api_client.vertexai:
|
147
154
|
if base_models:
|
@@ -155,8 +162,12 @@ def t_models_url(api_client: _api_client.ApiClient, base_models: bool) -> str:
|
|
155
162
|
return 'tunedModels'
|
156
163
|
|
157
164
|
|
158
|
-
def t_extract_models(
|
159
|
-
|
165
|
+
def t_extract_models(
|
166
|
+
api_client: _api_client.ApiClient, response: dict
|
167
|
+
) -> list[types.Model]:
|
168
|
+
if not response:
|
169
|
+
return []
|
170
|
+
elif response.get('models') is not None:
|
160
171
|
return response.get('models')
|
161
172
|
elif response.get('tunedModels') is not None:
|
162
173
|
return response.get('tunedModels')
|
@@ -204,6 +215,10 @@ def t_part(client: _api_client.ApiClient, part: PartType) -> types.Part:
|
|
204
215
|
return types.Part(text=part)
|
205
216
|
if isinstance(part, PIL.Image.Image):
|
206
217
|
return types.Part(inline_data=pil_to_blob(part))
|
218
|
+
if isinstance(part, types.File):
|
219
|
+
if not part.uri or not part.mime_type:
|
220
|
+
raise ValueError('file uri and mime_type are required.')
|
221
|
+
return types.Part.from_uri(part.uri, part.mime_type)
|
207
222
|
else:
|
208
223
|
return part
|
209
224
|
|
@@ -282,32 +297,135 @@ def t_contents(
|
|
282
297
|
return [t_content(client, contents)]
|
283
298
|
|
284
299
|
|
285
|
-
def process_schema(
|
300
|
+
def process_schema(
|
301
|
+
data: dict[str, Any], client: Optional[_api_client.ApiClient] = None
|
302
|
+
):
|
286
303
|
if isinstance(data, dict):
|
287
304
|
# Iterate over a copy of keys to allow deletion
|
288
305
|
for key in list(data.keys()):
|
289
|
-
|
306
|
+
# Only delete 'title'for the Gemini API
|
307
|
+
if client and not client.vertexai and key == 'title':
|
290
308
|
del data[key]
|
291
|
-
elif key == 'type':
|
292
|
-
data[key] = data[key].upper()
|
293
309
|
else:
|
294
|
-
process_schema(data[key])
|
310
|
+
process_schema(data[key], client)
|
295
311
|
elif isinstance(data, list):
|
296
312
|
for item in data:
|
297
|
-
process_schema(item)
|
313
|
+
process_schema(item, client)
|
298
314
|
|
299
315
|
return data
|
300
316
|
|
301
317
|
|
318
|
+
def _build_schema(fname: str, fields_dict: dict[str, Any]) -> dict[str, Any]:
|
319
|
+
parameters = pydantic.create_model(fname, **fields_dict).model_json_schema()
|
320
|
+
defs = parameters.pop('$defs', {})
|
321
|
+
|
322
|
+
for _, value in defs.items():
|
323
|
+
unpack_defs(value, defs)
|
324
|
+
|
325
|
+
unpack_defs(parameters, defs)
|
326
|
+
return parameters['properties']['dummy']
|
327
|
+
|
328
|
+
|
329
|
+
def unpack_defs(schema: dict[str, Any], defs: dict[str, Any]):
|
330
|
+
"""Unpacks the $defs values in the schema generated by pydantic so they can be understood by the API.
|
331
|
+
|
332
|
+
Example of a schema before and after unpacking:
|
333
|
+
Before:
|
334
|
+
|
335
|
+
`schema`
|
336
|
+
|
337
|
+
{'properties': {
|
338
|
+
'dummy': {
|
339
|
+
'items': {
|
340
|
+
'$ref': '#/$defs/CountryInfo'
|
341
|
+
},
|
342
|
+
'title': 'Dummy',
|
343
|
+
'type': 'array'
|
344
|
+
}
|
345
|
+
},
|
346
|
+
'required': ['dummy'],
|
347
|
+
'title': 'dummy',
|
348
|
+
'type': 'object'}
|
349
|
+
|
350
|
+
`defs`
|
351
|
+
|
352
|
+
{'CountryInfo': {'properties': {'continent': {'title': 'Continent', 'type':
|
353
|
+
'string'}, 'gdp': {'title': 'Gdp', 'type': 'integer'}}, 'required':
|
354
|
+
['continent', 'gdp'], 'title': 'CountryInfo', 'type': 'object'}}
|
355
|
+
|
356
|
+
After:
|
357
|
+
|
358
|
+
`schema`
|
359
|
+
{'properties': {
|
360
|
+
'continent': {'title': 'Continent', 'type': 'string'},
|
361
|
+
'gdp': {'title': 'Gdp', 'type': 'integer'}
|
362
|
+
},
|
363
|
+
'required': ['continent', 'gdp'],
|
364
|
+
'title': 'CountryInfo',
|
365
|
+
'type': 'object'
|
366
|
+
}
|
367
|
+
"""
|
368
|
+
properties = schema.get('properties', None)
|
369
|
+
if properties is None:
|
370
|
+
return
|
371
|
+
|
372
|
+
for name, value in properties.items():
|
373
|
+
ref_key = value.get('$ref', None)
|
374
|
+
if ref_key is not None:
|
375
|
+
ref = defs[ref_key.split('defs/')[-1]]
|
376
|
+
unpack_defs(ref, defs)
|
377
|
+
properties[name] = ref
|
378
|
+
continue
|
379
|
+
|
380
|
+
anyof = value.get('anyOf', None)
|
381
|
+
if anyof is not None:
|
382
|
+
for i, atype in enumerate(anyof):
|
383
|
+
ref_key = atype.get('$ref', None)
|
384
|
+
if ref_key is not None:
|
385
|
+
ref = defs[ref_key.split('defs/')[-1]]
|
386
|
+
unpack_defs(ref, defs)
|
387
|
+
anyof[i] = ref
|
388
|
+
continue
|
389
|
+
|
390
|
+
items = value.get('items', None)
|
391
|
+
if items is not None:
|
392
|
+
ref_key = items.get('$ref', None)
|
393
|
+
if ref_key is not None:
|
394
|
+
ref = defs[ref_key.split('defs/')[-1]]
|
395
|
+
unpack_defs(ref, defs)
|
396
|
+
value['items'] = ref
|
397
|
+
continue
|
398
|
+
|
399
|
+
|
302
400
|
def t_schema(
|
303
|
-
|
401
|
+
client: _api_client.ApiClient, origin: Union[types.SchemaUnionDict, Any]
|
304
402
|
) -> Optional[types.Schema]:
|
305
403
|
if not origin:
|
306
404
|
return None
|
307
405
|
if isinstance(origin, dict):
|
308
|
-
return origin
|
309
|
-
|
310
|
-
|
406
|
+
return process_schema(origin, client)
|
407
|
+
if isinstance(origin, types.Schema):
|
408
|
+
if dict(origin) == dict(types.Schema()):
|
409
|
+
# response_schema value was coerced to an empty Schema instance because it did not adhere to the Schema field annotation
|
410
|
+
raise ValueError(f'Unsupported schema type.')
|
411
|
+
schema = process_schema(origin.model_dump(exclude_unset=True), client)
|
412
|
+
return types.Schema.model_validate(schema)
|
413
|
+
if isinstance(origin, GenericAlias):
|
414
|
+
if origin.__origin__ is list:
|
415
|
+
if isinstance(origin.__args__[0], typing.types.UnionType):
|
416
|
+
raise ValueError(f'Unsupported schema type: GenericAlias {origin}')
|
417
|
+
if issubclass(origin.__args__[0], pydantic.BaseModel):
|
418
|
+
# Handle cases where response schema is `list[pydantic.BaseModel]`
|
419
|
+
list_schema = _build_schema(
|
420
|
+
'dummy', {'dummy': (origin, pydantic.Field())}
|
421
|
+
)
|
422
|
+
list_schema = process_schema(list_schema, client)
|
423
|
+
return types.Schema.model_validate(list_schema)
|
424
|
+
raise ValueError(f'Unsupported schema type: GenericAlias {origin}')
|
425
|
+
if issubclass(origin, pydantic.BaseModel):
|
426
|
+
schema = process_schema(origin.model_json_schema(), client)
|
427
|
+
return types.Schema.model_validate(schema)
|
428
|
+
raise ValueError(f'Unsupported schema type: {origin}')
|
311
429
|
|
312
430
|
|
313
431
|
def t_speech_config(
|
@@ -343,10 +461,10 @@ def t_speech_config(
|
|
343
461
|
def t_tool(client: _api_client.ApiClient, origin) -> types.Tool:
|
344
462
|
if not origin:
|
345
463
|
return None
|
346
|
-
if inspect.isfunction(origin):
|
464
|
+
if inspect.isfunction(origin) or inspect.ismethod(origin):
|
347
465
|
return types.Tool(
|
348
466
|
function_declarations=[
|
349
|
-
types.FunctionDeclaration.
|
467
|
+
types.FunctionDeclaration.from_callable(client, origin)
|
350
468
|
]
|
351
469
|
)
|
352
470
|
else:
|
@@ -456,10 +574,25 @@ def t_resolve_operation(api_client: _api_client.ApiClient, struct: dict):
|
|
456
574
|
return struct
|
457
575
|
|
458
576
|
|
459
|
-
def t_file_name(
|
460
|
-
|
461
|
-
|
462
|
-
|
577
|
+
def t_file_name(
|
578
|
+
api_client: _api_client.ApiClient, name: Union[str, types.File]
|
579
|
+
):
|
580
|
+
# Remove the files/ prefix since it's added to the url path.
|
581
|
+
if isinstance(name, types.File):
|
582
|
+
name = name.name
|
583
|
+
|
584
|
+
if name is None:
|
585
|
+
raise ValueError('File name is required.')
|
586
|
+
|
587
|
+
if name.startswith('https://'):
|
588
|
+
suffix = name.split('files/')[1]
|
589
|
+
match = re.match('[a-z0-9]+', suffix)
|
590
|
+
if match is None:
|
591
|
+
raise ValueError(f'Could not extract file name from URI: {name}')
|
592
|
+
name = match.group(0)
|
593
|
+
elif name.startswith('files/'):
|
594
|
+
name = name.split('files/')[1]
|
595
|
+
|
463
596
|
return name
|
464
597
|
|
465
598
|
|
@@ -481,12 +614,8 @@ def t_tuning_job_status(
|
|
481
614
|
# Some fields don't accept url safe base64 encoding.
|
482
615
|
# We shouldn't use this transformer if the backend adhere to Cloud Type
|
483
616
|
# format https://cloud.google.com/docs/discovery/type-format.
|
484
|
-
# TODO(b/389133914): Remove the hack after
|
617
|
+
# TODO(b/389133914,b/390320301): Remove the hack after backend fix the issue.
|
485
618
|
def t_bytes(api_client: _api_client.ApiClient, data: bytes) -> str:
|
486
619
|
if not isinstance(data, bytes):
|
487
620
|
return data
|
488
|
-
|
489
|
-
return base64.b64encode(data).decode('ascii')
|
490
|
-
else:
|
491
|
-
return base64.urlsafe_encode(data).decode('ascii')
|
492
|
-
|
621
|
+
return base64.b64encode(data).decode('ascii')
|
google/genai/batches.py
CHANGED
@@ -731,7 +731,7 @@ class Batches(_common.BaseModule):
|
|
731
731
|
config = request_dict.pop('config', None)
|
732
732
|
http_options = config.pop('httpOptions', None) if config else None
|
733
733
|
request_dict = _common.convert_to_dict(request_dict)
|
734
|
-
request_dict = _common.
|
734
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
735
735
|
|
736
736
|
response_dict = self._api_client.request(
|
737
737
|
'post', path, request_dict, http_options
|
@@ -787,7 +787,7 @@ class Batches(_common.BaseModule):
|
|
787
787
|
config = request_dict.pop('config', None)
|
788
788
|
http_options = config.pop('httpOptions', None) if config else None
|
789
789
|
request_dict = _common.convert_to_dict(request_dict)
|
790
|
-
request_dict = _common.
|
790
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
791
791
|
|
792
792
|
response_dict = self._api_client.request(
|
793
793
|
'get', path, request_dict, http_options
|
@@ -830,7 +830,7 @@ class Batches(_common.BaseModule):
|
|
830
830
|
config = request_dict.pop('config', None)
|
831
831
|
http_options = config.pop('httpOptions', None) if config else None
|
832
832
|
request_dict = _common.convert_to_dict(request_dict)
|
833
|
-
request_dict = _common.
|
833
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
834
834
|
|
835
835
|
response_dict = self._api_client.request(
|
836
836
|
'post', path, request_dict, http_options
|
@@ -858,7 +858,7 @@ class Batches(_common.BaseModule):
|
|
858
858
|
config = request_dict.pop('config', None)
|
859
859
|
http_options = config.pop('httpOptions', None) if config else None
|
860
860
|
request_dict = _common.convert_to_dict(request_dict)
|
861
|
-
request_dict = _common.
|
861
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
862
862
|
|
863
863
|
response_dict = self._api_client.request(
|
864
864
|
'get', path, request_dict, http_options
|
@@ -916,7 +916,7 @@ class Batches(_common.BaseModule):
|
|
916
916
|
config = request_dict.pop('config', None)
|
917
917
|
http_options = config.pop('httpOptions', None) if config else None
|
918
918
|
request_dict = _common.convert_to_dict(request_dict)
|
919
|
-
request_dict = _common.
|
919
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
920
920
|
|
921
921
|
response_dict = self._api_client.request(
|
922
922
|
'delete', path, request_dict, http_options
|
@@ -1027,7 +1027,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1027
1027
|
config = request_dict.pop('config', None)
|
1028
1028
|
http_options = config.pop('httpOptions', None) if config else None
|
1029
1029
|
request_dict = _common.convert_to_dict(request_dict)
|
1030
|
-
request_dict = _common.
|
1030
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1031
1031
|
|
1032
1032
|
response_dict = await self._api_client.async_request(
|
1033
1033
|
'post', path, request_dict, http_options
|
@@ -1083,7 +1083,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1083
1083
|
config = request_dict.pop('config', None)
|
1084
1084
|
http_options = config.pop('httpOptions', None) if config else None
|
1085
1085
|
request_dict = _common.convert_to_dict(request_dict)
|
1086
|
-
request_dict = _common.
|
1086
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1087
1087
|
|
1088
1088
|
response_dict = await self._api_client.async_request(
|
1089
1089
|
'get', path, request_dict, http_options
|
@@ -1126,7 +1126,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1126
1126
|
config = request_dict.pop('config', None)
|
1127
1127
|
http_options = config.pop('httpOptions', None) if config else None
|
1128
1128
|
request_dict = _common.convert_to_dict(request_dict)
|
1129
|
-
request_dict = _common.
|
1129
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1130
1130
|
|
1131
1131
|
response_dict = await self._api_client.async_request(
|
1132
1132
|
'post', path, request_dict, http_options
|
@@ -1154,7 +1154,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1154
1154
|
config = request_dict.pop('config', None)
|
1155
1155
|
http_options = config.pop('httpOptions', None) if config else None
|
1156
1156
|
request_dict = _common.convert_to_dict(request_dict)
|
1157
|
-
request_dict = _common.
|
1157
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1158
1158
|
|
1159
1159
|
response_dict = await self._api_client.async_request(
|
1160
1160
|
'get', path, request_dict, http_options
|
@@ -1212,7 +1212,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1212
1212
|
config = request_dict.pop('config', None)
|
1213
1213
|
http_options = config.pop('httpOptions', None) if config else None
|
1214
1214
|
request_dict = _common.convert_to_dict(request_dict)
|
1215
|
-
request_dict = _common.
|
1215
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1216
1216
|
|
1217
1217
|
response_dict = await self._api_client.async_request(
|
1218
1218
|
'delete', path, request_dict, http_options
|
google/genai/caches.py
CHANGED
@@ -1291,7 +1291,7 @@ class Caches(_common.BaseModule):
|
|
1291
1291
|
config = request_dict.pop('config', None)
|
1292
1292
|
http_options = config.pop('httpOptions', None) if config else None
|
1293
1293
|
request_dict = _common.convert_to_dict(request_dict)
|
1294
|
-
request_dict = _common.
|
1294
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1295
1295
|
|
1296
1296
|
response_dict = self._api_client.request(
|
1297
1297
|
'post', path, request_dict, http_options
|
@@ -1346,7 +1346,7 @@ class Caches(_common.BaseModule):
|
|
1346
1346
|
config = request_dict.pop('config', None)
|
1347
1347
|
http_options = config.pop('httpOptions', None) if config else None
|
1348
1348
|
request_dict = _common.convert_to_dict(request_dict)
|
1349
|
-
request_dict = _common.
|
1349
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1350
1350
|
|
1351
1351
|
response_dict = self._api_client.request(
|
1352
1352
|
'get', path, request_dict, http_options
|
@@ -1403,7 +1403,7 @@ class Caches(_common.BaseModule):
|
|
1403
1403
|
config = request_dict.pop('config', None)
|
1404
1404
|
http_options = config.pop('httpOptions', None) if config else None
|
1405
1405
|
request_dict = _common.convert_to_dict(request_dict)
|
1406
|
-
request_dict = _common.
|
1406
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1407
1407
|
|
1408
1408
|
response_dict = self._api_client.request(
|
1409
1409
|
'delete', path, request_dict, http_options
|
@@ -1464,7 +1464,7 @@ class Caches(_common.BaseModule):
|
|
1464
1464
|
config = request_dict.pop('config', None)
|
1465
1465
|
http_options = config.pop('httpOptions', None) if config else None
|
1466
1466
|
request_dict = _common.convert_to_dict(request_dict)
|
1467
|
-
request_dict = _common.
|
1467
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1468
1468
|
|
1469
1469
|
response_dict = self._api_client.request(
|
1470
1470
|
'patch', path, request_dict, http_options
|
@@ -1516,7 +1516,7 @@ class Caches(_common.BaseModule):
|
|
1516
1516
|
config = request_dict.pop('config', None)
|
1517
1517
|
http_options = config.pop('httpOptions', None) if config else None
|
1518
1518
|
request_dict = _common.convert_to_dict(request_dict)
|
1519
|
-
request_dict = _common.
|
1519
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1520
1520
|
|
1521
1521
|
response_dict = self._api_client.request(
|
1522
1522
|
'get', path, request_dict, http_options
|
@@ -1599,7 +1599,7 @@ class AsyncCaches(_common.BaseModule):
|
|
1599
1599
|
config = request_dict.pop('config', None)
|
1600
1600
|
http_options = config.pop('httpOptions', None) if config else None
|
1601
1601
|
request_dict = _common.convert_to_dict(request_dict)
|
1602
|
-
request_dict = _common.
|
1602
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1603
1603
|
|
1604
1604
|
response_dict = await self._api_client.async_request(
|
1605
1605
|
'post', path, request_dict, http_options
|
@@ -1654,7 +1654,7 @@ class AsyncCaches(_common.BaseModule):
|
|
1654
1654
|
config = request_dict.pop('config', None)
|
1655
1655
|
http_options = config.pop('httpOptions', None) if config else None
|
1656
1656
|
request_dict = _common.convert_to_dict(request_dict)
|
1657
|
-
request_dict = _common.
|
1657
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1658
1658
|
|
1659
1659
|
response_dict = await self._api_client.async_request(
|
1660
1660
|
'get', path, request_dict, http_options
|
@@ -1711,7 +1711,7 @@ class AsyncCaches(_common.BaseModule):
|
|
1711
1711
|
config = request_dict.pop('config', None)
|
1712
1712
|
http_options = config.pop('httpOptions', None) if config else None
|
1713
1713
|
request_dict = _common.convert_to_dict(request_dict)
|
1714
|
-
request_dict = _common.
|
1714
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1715
1715
|
|
1716
1716
|
response_dict = await self._api_client.async_request(
|
1717
1717
|
'delete', path, request_dict, http_options
|
@@ -1772,7 +1772,7 @@ class AsyncCaches(_common.BaseModule):
|
|
1772
1772
|
config = request_dict.pop('config', None)
|
1773
1773
|
http_options = config.pop('httpOptions', None) if config else None
|
1774
1774
|
request_dict = _common.convert_to_dict(request_dict)
|
1775
|
-
request_dict = _common.
|
1775
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1776
1776
|
|
1777
1777
|
response_dict = await self._api_client.async_request(
|
1778
1778
|
'patch', path, request_dict, http_options
|
@@ -1824,7 +1824,7 @@ class AsyncCaches(_common.BaseModule):
|
|
1824
1824
|
config = request_dict.pop('config', None)
|
1825
1825
|
http_options = config.pop('httpOptions', None) if config else None
|
1826
1826
|
request_dict = _common.convert_to_dict(request_dict)
|
1827
|
-
request_dict = _common.
|
1827
|
+
request_dict = _common.encode_unserializable_types(request_dict)
|
1828
1828
|
|
1829
1829
|
response_dict = await self._api_client.async_request(
|
1830
1830
|
'get', path, request_dict, http_options
|
google/genai/client.py
CHANGED
@@ -187,7 +187,8 @@ class Client:
|
|
187
187
|
self._debug_config = debug_config or DebugConfig()
|
188
188
|
|
189
189
|
# Throw ValueError if response_payload is set in http_options due to
|
190
|
-
#
|
190
|
+
# unpredictable behavior when running multiple coroutines through
|
191
|
+
# client.aio.
|
191
192
|
if http_options and 'response_payload' in http_options:
|
192
193
|
raise ValueError(
|
193
194
|
'Setting response_payload in http_options is not supported.'
|
google/genai/errors.py
CHANGED
@@ -114,7 +114,7 @@ class ServerError(APIError):
|
|
114
114
|
pass
|
115
115
|
|
116
116
|
|
117
|
-
class
|
117
|
+
class UnknownFunctionCallArgumentError(ValueError):
|
118
118
|
"""Raised when the function call argument cannot be converted to the parameter annotation."""
|
119
119
|
|
120
120
|
pass
|