google-genai 1.52.0__py3-none-any.whl → 1.54.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 +6 -6
- google/genai/_live_converters.py +3 -3
- google/genai/batches.py +11 -15
- google/genai/caches.py +40 -20
- google/genai/documents.py +3 -23
- google/genai/errors.py +16 -1
- google/genai/file_search_stores.py +9 -25
- google/genai/files.py +47 -45
- google/genai/live.py +8 -1
- google/genai/models.py +3 -3
- google/genai/tunings.py +121 -43
- google/genai/types.py +197 -127
- google/genai/version.py +1 -1
- {google_genai-1.52.0.dist-info → google_genai-1.54.0.dist-info}/METADATA +51 -30
- {google_genai-1.52.0.dist-info → google_genai-1.54.0.dist-info}/RECORD +18 -18
- {google_genai-1.52.0.dist-info → google_genai-1.54.0.dist-info}/WHEEL +0 -0
- {google_genai-1.52.0.dist-info → google_genai-1.54.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.52.0.dist-info → google_genai-1.54.0.dist-info}/top_level.txt +0 -0
google/genai/_api_client.py
CHANGED
|
@@ -1254,7 +1254,7 @@ class BaseApiClient:
|
|
|
1254
1254
|
url=http_request.url,
|
|
1255
1255
|
headers=http_request.headers,
|
|
1256
1256
|
data=data,
|
|
1257
|
-
timeout=aiohttp.ClientTimeout(
|
|
1257
|
+
timeout=aiohttp.ClientTimeout(total=http_request.timeout),
|
|
1258
1258
|
**self._async_client_session_request_args,
|
|
1259
1259
|
)
|
|
1260
1260
|
except (
|
|
@@ -1276,7 +1276,7 @@ class BaseApiClient:
|
|
|
1276
1276
|
url=http_request.url,
|
|
1277
1277
|
headers=http_request.headers,
|
|
1278
1278
|
data=data,
|
|
1279
|
-
timeout=aiohttp.ClientTimeout(
|
|
1279
|
+
timeout=aiohttp.ClientTimeout(total=http_request.timeout),
|
|
1280
1280
|
**self._async_client_session_request_args,
|
|
1281
1281
|
)
|
|
1282
1282
|
|
|
@@ -1306,7 +1306,7 @@ class BaseApiClient:
|
|
|
1306
1306
|
url=http_request.url,
|
|
1307
1307
|
headers=http_request.headers,
|
|
1308
1308
|
data=data,
|
|
1309
|
-
timeout=aiohttp.ClientTimeout(
|
|
1309
|
+
timeout=aiohttp.ClientTimeout(total=http_request.timeout),
|
|
1310
1310
|
**self._async_client_session_request_args,
|
|
1311
1311
|
)
|
|
1312
1312
|
await errors.APIError.raise_for_async_response(response)
|
|
@@ -1330,7 +1330,7 @@ class BaseApiClient:
|
|
|
1330
1330
|
url=http_request.url,
|
|
1331
1331
|
headers=http_request.headers,
|
|
1332
1332
|
data=data,
|
|
1333
|
-
timeout=aiohttp.ClientTimeout(
|
|
1333
|
+
timeout=aiohttp.ClientTimeout(total=http_request.timeout),
|
|
1334
1334
|
**self._async_client_session_request_args,
|
|
1335
1335
|
)
|
|
1336
1336
|
await errors.APIError.raise_for_async_response(response)
|
|
@@ -1718,7 +1718,7 @@ class BaseApiClient:
|
|
|
1718
1718
|
url=upload_url,
|
|
1719
1719
|
data=file_chunk,
|
|
1720
1720
|
headers=upload_headers,
|
|
1721
|
-
timeout=aiohttp.ClientTimeout(
|
|
1721
|
+
timeout=aiohttp.ClientTimeout(total=timeout_in_seconds),
|
|
1722
1722
|
)
|
|
1723
1723
|
|
|
1724
1724
|
if response.headers.get('X-Goog-Upload-Status'):
|
|
@@ -1864,7 +1864,7 @@ class BaseApiClient:
|
|
|
1864
1864
|
url=http_request.url,
|
|
1865
1865
|
headers=http_request.headers,
|
|
1866
1866
|
data=data,
|
|
1867
|
-
timeout=aiohttp.ClientTimeout(
|
|
1867
|
+
timeout=aiohttp.ClientTimeout(total=http_request.timeout),
|
|
1868
1868
|
)
|
|
1869
1869
|
await errors.APIError.raise_for_async_response(response)
|
|
1870
1870
|
|
google/genai/_live_converters.py
CHANGED
|
@@ -1265,12 +1265,12 @@ def _SpeechConfig_to_vertex(
|
|
|
1265
1265
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1266
1266
|
) -> dict[str, Any]:
|
|
1267
1267
|
to_object: dict[str, Any] = {}
|
|
1268
|
-
if getv(from_object, ['language_code']) is not None:
|
|
1269
|
-
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
1270
|
-
|
|
1271
1268
|
if getv(from_object, ['voice_config']) is not None:
|
|
1272
1269
|
setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
|
|
1273
1270
|
|
|
1271
|
+
if getv(from_object, ['language_code']) is not None:
|
|
1272
|
+
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
1273
|
+
|
|
1274
1274
|
if getv(from_object, ['multi_speaker_voice_config']) is not None:
|
|
1275
1275
|
raise ValueError(
|
|
1276
1276
|
'multi_speaker_voice_config parameter is not supported in Vertex AI.'
|
google/genai/batches.py
CHANGED
|
@@ -2012,16 +2012,15 @@ class Batches(_api_module.BaseModule):
|
|
|
2012
2012
|
Usage:
|
|
2013
2013
|
|
|
2014
2014
|
.. code-block:: python
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
print(f"Batch job: {batch_job.name}, state {batch_job.state}")
|
|
2015
|
+
config = {'page_size': 10}
|
|
2016
|
+
for batch_job in client.batches.list(config):
|
|
2017
|
+
print(batch_job.name)
|
|
2019
2018
|
"""
|
|
2020
|
-
|
|
2021
|
-
|
|
2019
|
+
|
|
2020
|
+
list_request = self._list
|
|
2022
2021
|
return Pager(
|
|
2023
2022
|
'batch_jobs',
|
|
2024
|
-
|
|
2023
|
+
list_request,
|
|
2025
2024
|
self._list(config=config),
|
|
2026
2025
|
config,
|
|
2027
2026
|
)
|
|
@@ -2568,17 +2567,14 @@ class AsyncBatches(_api_module.BaseModule):
|
|
|
2568
2567
|
Usage:
|
|
2569
2568
|
|
|
2570
2569
|
.. code-block:: python
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
print(f"current page: {batch_jobs.page}")
|
|
2574
|
-
await batch_jobs_pager.next_page()
|
|
2575
|
-
print(f"next page: {batch_jobs_pager.page}")
|
|
2570
|
+
async for batch_job in await client.aio.batches.list():
|
|
2571
|
+
print(batch_job.name)
|
|
2576
2572
|
"""
|
|
2577
|
-
|
|
2578
|
-
|
|
2573
|
+
|
|
2574
|
+
list_request = self._list
|
|
2579
2575
|
return AsyncPager(
|
|
2580
2576
|
'batch_jobs',
|
|
2581
|
-
|
|
2577
|
+
list_request,
|
|
2582
2578
|
await self._list(config=config),
|
|
2583
2579
|
config,
|
|
2584
2580
|
)
|
google/genai/caches.py
CHANGED
|
@@ -1129,15 +1129,6 @@ class Caches(_api_module.BaseModule):
|
|
|
1129
1129
|
def _list(
|
|
1130
1130
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1131
1131
|
) -> types.ListCachedContentsResponse:
|
|
1132
|
-
"""Lists cached content configurations.
|
|
1133
|
-
|
|
1134
|
-
.. code-block:: python
|
|
1135
|
-
|
|
1136
|
-
cached_contents = client.caches.list(config={'page_size': 2})
|
|
1137
|
-
for cached_content in cached_contents:
|
|
1138
|
-
print(cached_content)
|
|
1139
|
-
"""
|
|
1140
|
-
|
|
1141
1132
|
parameter_model = types._ListCachedContentsParameters(
|
|
1142
1133
|
config=config,
|
|
1143
1134
|
)
|
|
@@ -1196,9 +1187,28 @@ class Caches(_api_module.BaseModule):
|
|
|
1196
1187
|
def list(
|
|
1197
1188
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1198
1189
|
) -> Pager[types.CachedContent]:
|
|
1190
|
+
"""Lists cached contents.
|
|
1191
|
+
|
|
1192
|
+
Args:
|
|
1193
|
+
config (ListCachedContentsConfig): Optional configuration for the list
|
|
1194
|
+
request.
|
|
1195
|
+
|
|
1196
|
+
Returns:
|
|
1197
|
+
A Pager object that contains one page of cached contents. When iterating
|
|
1198
|
+
over
|
|
1199
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1200
|
+
|
|
1201
|
+
Usage:
|
|
1202
|
+
|
|
1203
|
+
.. code-block:: python
|
|
1204
|
+
for cached_content in client.caches.list():
|
|
1205
|
+
print(cached_content.name)
|
|
1206
|
+
"""
|
|
1207
|
+
|
|
1208
|
+
list_request = self._list
|
|
1199
1209
|
return Pager(
|
|
1200
1210
|
'cached_contents',
|
|
1201
|
-
|
|
1211
|
+
list_request,
|
|
1202
1212
|
self._list(config=config),
|
|
1203
1213
|
config,
|
|
1204
1214
|
)
|
|
@@ -1505,15 +1515,6 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
1505
1515
|
async def _list(
|
|
1506
1516
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1507
1517
|
) -> types.ListCachedContentsResponse:
|
|
1508
|
-
"""Lists cached content configurations.
|
|
1509
|
-
|
|
1510
|
-
.. code-block:: python
|
|
1511
|
-
|
|
1512
|
-
cached_contents = await client.aio.caches.list(config={'page_size': 2})
|
|
1513
|
-
async for cached_content in cached_contents:
|
|
1514
|
-
print(cached_content)
|
|
1515
|
-
"""
|
|
1516
|
-
|
|
1517
1518
|
parameter_model = types._ListCachedContentsParameters(
|
|
1518
1519
|
config=config,
|
|
1519
1520
|
)
|
|
@@ -1574,9 +1575,28 @@ class AsyncCaches(_api_module.BaseModule):
|
|
|
1574
1575
|
async def list(
|
|
1575
1576
|
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
|
|
1576
1577
|
) -> AsyncPager[types.CachedContent]:
|
|
1578
|
+
"""Lists cached contents asynchronously.
|
|
1579
|
+
|
|
1580
|
+
Args:
|
|
1581
|
+
config (ListCachedContentsConfig): Optional configuration for the list
|
|
1582
|
+
request.
|
|
1583
|
+
|
|
1584
|
+
Returns:
|
|
1585
|
+
A Pager object that contains one page of cached contents. When iterating
|
|
1586
|
+
over
|
|
1587
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1588
|
+
|
|
1589
|
+
Usage:
|
|
1590
|
+
|
|
1591
|
+
.. code-block:: python
|
|
1592
|
+
async for cached_content in await client.aio.caches.list():
|
|
1593
|
+
print(cached_content.name)
|
|
1594
|
+
"""
|
|
1595
|
+
|
|
1596
|
+
list_request = self._list
|
|
1577
1597
|
return AsyncPager(
|
|
1578
1598
|
'cached_contents',
|
|
1579
|
-
|
|
1599
|
+
list_request,
|
|
1580
1600
|
await self._list(config=config),
|
|
1581
1601
|
config,
|
|
1582
1602
|
)
|
google/genai/documents.py
CHANGED
|
@@ -249,17 +249,6 @@ class Documents(_api_module.BaseModule):
|
|
|
249
249
|
parent: str,
|
|
250
250
|
config: Optional[types.ListDocumentsConfigOrDict] = None,
|
|
251
251
|
) -> types.ListDocumentsResponse:
|
|
252
|
-
"""Lists all Documents in a FileSearchStore.
|
|
253
|
-
|
|
254
|
-
Args:
|
|
255
|
-
parent (str): The name of the FileSearchStore containing the Documents.
|
|
256
|
-
config (ListDocumentsConfig | None): Optional parameters for the request,
|
|
257
|
-
such as page_size.
|
|
258
|
-
|
|
259
|
-
Returns:
|
|
260
|
-
ListDocumentsResponse: A paginated list of Documents.
|
|
261
|
-
"""
|
|
262
|
-
|
|
263
252
|
parameter_model = types._ListDocumentsParameters(
|
|
264
253
|
parent=parent,
|
|
265
254
|
config=config,
|
|
@@ -328,6 +317,7 @@ class Documents(_api_module.BaseModule):
|
|
|
328
317
|
for document in client.documents.list(parent='rag_store_name'):
|
|
329
318
|
print(f"document: {document.name} - {document.display_name}")
|
|
330
319
|
"""
|
|
320
|
+
|
|
331
321
|
list_request = partial(self._list, parent=parent)
|
|
332
322
|
return Pager(
|
|
333
323
|
'documents',
|
|
@@ -461,17 +451,6 @@ class AsyncDocuments(_api_module.BaseModule):
|
|
|
461
451
|
parent: str,
|
|
462
452
|
config: Optional[types.ListDocumentsConfigOrDict] = None,
|
|
463
453
|
) -> types.ListDocumentsResponse:
|
|
464
|
-
"""Lists all Documents in a FileSearchStore.
|
|
465
|
-
|
|
466
|
-
Args:
|
|
467
|
-
parent (str): The name of the FileSearchStore containing the Documents.
|
|
468
|
-
config (ListDocumentsConfig | None): Optional parameters for the request,
|
|
469
|
-
such as page_size.
|
|
470
|
-
|
|
471
|
-
Returns:
|
|
472
|
-
ListDocumentsResponse: A paginated list of Documents.
|
|
473
|
-
"""
|
|
474
|
-
|
|
475
454
|
parameter_model = types._ListDocumentsParameters(
|
|
476
455
|
parent=parent,
|
|
477
456
|
config=config,
|
|
@@ -540,9 +519,10 @@ class AsyncDocuments(_api_module.BaseModule):
|
|
|
540
519
|
Usage:
|
|
541
520
|
.. code-block:: python
|
|
542
521
|
async for document in await
|
|
543
|
-
client.documents.list(parent='rag_store_name'):
|
|
522
|
+
client.aio.documents.list(parent='rag_store_name'):
|
|
544
523
|
print(f"document: {document.name} - {document.display_name}")
|
|
545
524
|
"""
|
|
525
|
+
|
|
546
526
|
list_request = partial(self._list, parent=parent)
|
|
547
527
|
return AsyncPager(
|
|
548
528
|
'documents',
|
google/genai/errors.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
"""Error classes for the GenAI SDK."""
|
|
17
17
|
|
|
18
|
-
from typing import Any, Optional, TYPE_CHECKING, Union
|
|
18
|
+
from typing import Any, Callable, Optional, TYPE_CHECKING, Union
|
|
19
19
|
import httpx
|
|
20
20
|
import json
|
|
21
21
|
from . import _common
|
|
@@ -53,6 +53,21 @@ class APIError(Exception):
|
|
|
53
53
|
|
|
54
54
|
super().__init__(f'{self.code} {self.status}. {self.details}')
|
|
55
55
|
|
|
56
|
+
def __reduce__(
|
|
57
|
+
self,
|
|
58
|
+
) -> tuple[Callable[..., 'APIError'], tuple[dict[str, Any]]]:
|
|
59
|
+
"""Returns a tuple that can be used to reconstruct the error for pickling."""
|
|
60
|
+
state = self.__dict__.copy()
|
|
61
|
+
return (self.__class__._rebuild, (state,))
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def _rebuild(state: dict[str, Any]) -> 'APIError':
|
|
65
|
+
"""Rebuilds the error from the state."""
|
|
66
|
+
obj = APIError.__new__(APIError)
|
|
67
|
+
obj.__dict__.update(state)
|
|
68
|
+
Exception.__init__(obj, f'{obj.code} {obj.status}. {obj.details}')
|
|
69
|
+
return obj
|
|
70
|
+
|
|
56
71
|
def _get_status(self, response_json: Any) -> Any:
|
|
57
72
|
return response_json.get(
|
|
58
73
|
'status', response_json.get('error', {}).get('status', None)
|
|
@@ -499,16 +499,6 @@ class FileSearchStores(_api_module.BaseModule):
|
|
|
499
499
|
def _list(
|
|
500
500
|
self, *, config: Optional[types.ListFileSearchStoresConfigOrDict] = None
|
|
501
501
|
) -> types.ListFileSearchStoresResponse:
|
|
502
|
-
"""Lists all FileSearchStore owned by the user.
|
|
503
|
-
|
|
504
|
-
Args:
|
|
505
|
-
config (ListFileSearchStoresConfig | None): Optional parameters for the
|
|
506
|
-
request, such as page_size.
|
|
507
|
-
|
|
508
|
-
Returns:
|
|
509
|
-
ListFileSearchStoresResponse: A paginated list of FileSearchStore.
|
|
510
|
-
"""
|
|
511
|
-
|
|
512
502
|
parameter_model = types._ListFileSearchStoresParameters(
|
|
513
503
|
config=config,
|
|
514
504
|
)
|
|
@@ -802,9 +792,11 @@ class FileSearchStores(_api_module.BaseModule):
|
|
|
802
792
|
print(f"file search store: {file_search_store.name} -
|
|
803
793
|
{file_search_store.display_name}")
|
|
804
794
|
"""
|
|
795
|
+
|
|
796
|
+
list_request = self._list
|
|
805
797
|
return Pager(
|
|
806
798
|
'file_search_stores',
|
|
807
|
-
|
|
799
|
+
list_request,
|
|
808
800
|
self._list(config=config),
|
|
809
801
|
config,
|
|
810
802
|
)
|
|
@@ -999,16 +991,6 @@ class AsyncFileSearchStores(_api_module.BaseModule):
|
|
|
999
991
|
async def _list(
|
|
1000
992
|
self, *, config: Optional[types.ListFileSearchStoresConfigOrDict] = None
|
|
1001
993
|
) -> types.ListFileSearchStoresResponse:
|
|
1002
|
-
"""Lists all FileSearchStore owned by the user.
|
|
1003
|
-
|
|
1004
|
-
Args:
|
|
1005
|
-
config (ListFileSearchStoresConfig | None): Optional parameters for the
|
|
1006
|
-
request, such as page_size.
|
|
1007
|
-
|
|
1008
|
-
Returns:
|
|
1009
|
-
ListFileSearchStoresResponse: A paginated list of FileSearchStore.
|
|
1010
|
-
"""
|
|
1011
|
-
|
|
1012
994
|
parameter_model = types._ListFileSearchStoresParameters(
|
|
1013
995
|
config=config,
|
|
1014
996
|
)
|
|
@@ -1289,8 +1271,8 @@ class AsyncFileSearchStores(_api_module.BaseModule):
|
|
|
1289
1271
|
"""Lists FileSearchStores asynchronously.
|
|
1290
1272
|
|
|
1291
1273
|
Args:
|
|
1292
|
-
config (ListFileSearchStoresConfig): Optional
|
|
1293
|
-
|
|
1274
|
+
config (ListFileSearchStoresConfig): Optional parameters for the request,
|
|
1275
|
+
such as page_size.
|
|
1294
1276
|
|
|
1295
1277
|
Returns:
|
|
1296
1278
|
A Pager object that contains one page of FileSearchStores. When iterating
|
|
@@ -1300,13 +1282,15 @@ class AsyncFileSearchStores(_api_module.BaseModule):
|
|
|
1300
1282
|
Usage:
|
|
1301
1283
|
|
|
1302
1284
|
.. code-block:: python
|
|
1303
|
-
async for file_search_store in await client.file_search_stores.list():
|
|
1285
|
+
async for file_search_store in await client.aio.file_search_stores.list():
|
|
1304
1286
|
print(f"file search store: {file_search_store.name} -
|
|
1305
1287
|
{file_search_store.display_name}")
|
|
1306
1288
|
"""
|
|
1289
|
+
|
|
1290
|
+
list_request = self._list
|
|
1307
1291
|
return AsyncPager(
|
|
1308
1292
|
'file_search_stores',
|
|
1309
|
-
|
|
1293
|
+
list_request,
|
|
1310
1294
|
await self._list(config=config),
|
|
1311
1295
|
config,
|
|
1312
1296
|
)
|
google/genai/files.py
CHANGED
|
@@ -154,23 +154,6 @@ class Files(_api_module.BaseModule):
|
|
|
154
154
|
def _list(
|
|
155
155
|
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
156
156
|
) -> types.ListFilesResponse:
|
|
157
|
-
"""Lists all files from the service.
|
|
158
|
-
|
|
159
|
-
Args:
|
|
160
|
-
config (ListFilesConfig): Optional, configuration for the list method.
|
|
161
|
-
|
|
162
|
-
Returns:
|
|
163
|
-
ListFilesResponse: The response for the list method.
|
|
164
|
-
|
|
165
|
-
Usage:
|
|
166
|
-
|
|
167
|
-
.. code-block:: python
|
|
168
|
-
|
|
169
|
-
pager = client.files.list(config={'page_size': 10})
|
|
170
|
-
for file in pager.page:
|
|
171
|
-
print(file.name)
|
|
172
|
-
"""
|
|
173
|
-
|
|
174
157
|
parameter_model = types._ListFilesParameters(
|
|
175
158
|
config=config,
|
|
176
159
|
)
|
|
@@ -495,16 +478,6 @@ class Files(_api_module.BaseModule):
|
|
|
495
478
|
kwargs=config_model.model_dump() if config else {},
|
|
496
479
|
)
|
|
497
480
|
|
|
498
|
-
def list(
|
|
499
|
-
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
500
|
-
) -> Pager[types.File]:
|
|
501
|
-
return Pager(
|
|
502
|
-
'files',
|
|
503
|
-
self._list,
|
|
504
|
-
self._list(config=config),
|
|
505
|
-
config,
|
|
506
|
-
)
|
|
507
|
-
|
|
508
481
|
def download(
|
|
509
482
|
self,
|
|
510
483
|
*,
|
|
@@ -586,29 +559,40 @@ class Files(_api_module.BaseModule):
|
|
|
586
559
|
|
|
587
560
|
return data
|
|
588
561
|
|
|
589
|
-
|
|
590
|
-
class AsyncFiles(_api_module.BaseModule):
|
|
591
|
-
|
|
592
|
-
async def _list(
|
|
562
|
+
def list(
|
|
593
563
|
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
594
|
-
) -> types.
|
|
564
|
+
) -> Pager[types.File]:
|
|
595
565
|
"""Lists all files from the service.
|
|
596
566
|
|
|
597
567
|
Args:
|
|
598
568
|
config (ListFilesConfig): Optional, configuration for the list method.
|
|
599
569
|
|
|
600
570
|
Returns:
|
|
601
|
-
|
|
571
|
+
A Pager object that contains one page of files. When iterating over
|
|
572
|
+
the pager, it automatically fetches the next page if there are more.
|
|
602
573
|
|
|
603
574
|
Usage:
|
|
604
575
|
|
|
605
576
|
.. code-block:: python
|
|
606
577
|
|
|
607
|
-
|
|
608
|
-
for file in pager.page:
|
|
578
|
+
for file in client.files.list(config={'page_size': 10}):
|
|
609
579
|
print(file.name)
|
|
610
580
|
"""
|
|
611
581
|
|
|
582
|
+
list_request = self._list
|
|
583
|
+
return Pager(
|
|
584
|
+
'files',
|
|
585
|
+
list_request,
|
|
586
|
+
self._list(config=config),
|
|
587
|
+
config,
|
|
588
|
+
)
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
class AsyncFiles(_api_module.BaseModule):
|
|
592
|
+
|
|
593
|
+
async def _list(
|
|
594
|
+
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
595
|
+
) -> types.ListFilesResponse:
|
|
612
596
|
parameter_model = types._ListFilesParameters(
|
|
613
597
|
config=config,
|
|
614
598
|
)
|
|
@@ -942,16 +926,6 @@ class AsyncFiles(_api_module.BaseModule):
|
|
|
942
926
|
kwargs=config_model.model_dump() if config else {},
|
|
943
927
|
)
|
|
944
928
|
|
|
945
|
-
async def list(
|
|
946
|
-
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
947
|
-
) -> AsyncPager[types.File]:
|
|
948
|
-
return AsyncPager(
|
|
949
|
-
'files',
|
|
950
|
-
self._list,
|
|
951
|
-
await self._list(config=config),
|
|
952
|
-
config,
|
|
953
|
-
)
|
|
954
|
-
|
|
955
929
|
async def download(
|
|
956
930
|
self,
|
|
957
931
|
*,
|
|
@@ -1017,3 +991,31 @@ class AsyncFiles(_api_module.BaseModule):
|
|
|
1017
991
|
)
|
|
1018
992
|
|
|
1019
993
|
return data
|
|
994
|
+
|
|
995
|
+
async def list(
|
|
996
|
+
self, *, config: Optional[types.ListFilesConfigOrDict] = None
|
|
997
|
+
) -> AsyncPager[types.File]:
|
|
998
|
+
"""Lists all files from the service asynchronously.
|
|
999
|
+
|
|
1000
|
+
Args:
|
|
1001
|
+
config (ListFilesConfig): Optional, configuration for the list method.
|
|
1002
|
+
|
|
1003
|
+
Returns:
|
|
1004
|
+
A Pager object that contains one page of files. When iterating over
|
|
1005
|
+
the pager, it automatically fetches the next page if there are more.
|
|
1006
|
+
|
|
1007
|
+
Usage:
|
|
1008
|
+
|
|
1009
|
+
.. code-block:: python
|
|
1010
|
+
|
|
1011
|
+
async for file in await client.aio.files.list(config={'page_size': 10}):
|
|
1012
|
+
print(file.name)
|
|
1013
|
+
"""
|
|
1014
|
+
|
|
1015
|
+
list_request = self._list
|
|
1016
|
+
return AsyncPager(
|
|
1017
|
+
'files',
|
|
1018
|
+
list_request,
|
|
1019
|
+
await self._list(config=config),
|
|
1020
|
+
config,
|
|
1021
|
+
)
|
google/genai/live.py
CHANGED
|
@@ -50,6 +50,11 @@ except ModuleNotFoundError:
|
|
|
50
50
|
from websockets.client import ClientConnection # type: ignore
|
|
51
51
|
from websockets.client import connect as ws_connect # type: ignore
|
|
52
52
|
|
|
53
|
+
try:
|
|
54
|
+
from google.auth.transport import requests
|
|
55
|
+
except ImportError:
|
|
56
|
+
requests = None # type: ignore[assignment]
|
|
57
|
+
|
|
53
58
|
if typing.TYPE_CHECKING:
|
|
54
59
|
from mcp import ClientSession as McpClientSession
|
|
55
60
|
from mcp.types import Tool as McpTool
|
|
@@ -1027,7 +1032,9 @@ class AsyncLive(_api_module.BaseModule):
|
|
|
1027
1032
|
# creds.valid is False, and creds.token is None
|
|
1028
1033
|
# Need to refresh credentials to populate those
|
|
1029
1034
|
if not (creds.token and creds.valid):
|
|
1030
|
-
|
|
1035
|
+
if requests is None:
|
|
1036
|
+
raise ValueError('The requests module is required to refresh google-auth credentials. Please install with `pip install google-auth[requests]`')
|
|
1037
|
+
auth_req = requests.Request() # type: ignore
|
|
1031
1038
|
creds.refresh(auth_req)
|
|
1032
1039
|
bearer_token = creds.token
|
|
1033
1040
|
|
google/genai/models.py
CHANGED
|
@@ -3420,12 +3420,12 @@ def _SpeechConfig_to_vertex(
|
|
|
3420
3420
|
parent_object: Optional[dict[str, Any]] = None,
|
|
3421
3421
|
) -> dict[str, Any]:
|
|
3422
3422
|
to_object: dict[str, Any] = {}
|
|
3423
|
-
if getv(from_object, ['language_code']) is not None:
|
|
3424
|
-
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
3425
|
-
|
|
3426
3423
|
if getv(from_object, ['voice_config']) is not None:
|
|
3427
3424
|
setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
|
|
3428
3425
|
|
|
3426
|
+
if getv(from_object, ['language_code']) is not None:
|
|
3427
|
+
setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
|
|
3428
|
+
|
|
3429
3429
|
if getv(from_object, ['multi_speaker_voice_config']) is not None:
|
|
3430
3430
|
raise ValueError(
|
|
3431
3431
|
'multi_speaker_voice_config parameter is not supported in Vertex AI.'
|