google-genai 1.38.0__py3-none-any.whl → 1.39.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 +12 -0
- google/genai/_common.py +25 -10
- google/genai/_live_converters.py +2074 -1924
- google/genai/_operations_converters.py +108 -117
- google/genai/_replay_api_client.py +8 -4
- google/genai/_tokens_converters.py +465 -458
- google/genai/_transformers.py +44 -26
- google/genai/batches.py +1101 -1138
- google/genai/caches.py +747 -771
- google/genai/client.py +87 -0
- google/genai/files.py +110 -123
- google/genai/local_tokenizer.py +7 -2
- google/genai/models.py +2716 -2814
- google/genai/operations.py +10 -22
- google/genai/tunings.py +358 -391
- google/genai/types.py +192 -4
- google/genai/version.py +1 -1
- {google_genai-1.38.0.dist-info → google_genai-1.39.0.dist-info}/METADATA +82 -1
- google_genai-1.39.0.dist-info/RECORD +39 -0
- google_genai-1.38.0.dist-info/RECORD +0 -39
- {google_genai-1.38.0.dist-info → google_genai-1.39.0.dist-info}/WHEEL +0 -0
- {google_genai-1.38.0.dist-info → google_genai-1.39.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.38.0.dist-info → google_genai-1.39.0.dist-info}/top_level.txt +0 -0
google/genai/_api_client.py
CHANGED
@@ -37,6 +37,7 @@ import time
|
|
37
37
|
from typing import Any, AsyncIterator, Iterator, Optional, Tuple, TYPE_CHECKING, Union
|
38
38
|
from urllib.parse import urlparse
|
39
39
|
from urllib.parse import urlunparse
|
40
|
+
import warnings
|
40
41
|
|
41
42
|
import anyio
|
42
43
|
import certifi
|
@@ -1763,3 +1764,14 @@ class BaseApiClient:
|
|
1763
1764
|
# recorded response.
|
1764
1765
|
def _verify_response(self, response_model: _common.BaseModel) -> None:
|
1765
1766
|
pass
|
1767
|
+
|
1768
|
+
def close(self) -> None:
|
1769
|
+
"""Closes the API client."""
|
1770
|
+
self._httpx_client.close()
|
1771
|
+
|
1772
|
+
async def aclose(self) -> None:
|
1773
|
+
"""Closes the API async client."""
|
1774
|
+
|
1775
|
+
await self._async_httpx_client.aclose()
|
1776
|
+
if self._aiohttp_session:
|
1777
|
+
await self._aiohttp_session.close()
|
google/genai/_common.py
CHANGED
@@ -314,8 +314,15 @@ def _pretty_repr(
|
|
314
314
|
elif isinstance(obj, collections.abc.Mapping):
|
315
315
|
if not obj:
|
316
316
|
return '{}'
|
317
|
+
|
318
|
+
# Check if the next level of recursion for keys/values will exceed the depth limit.
|
319
|
+
if depth <= 0:
|
320
|
+
item_count_str = f"{len(obj)} item{'s' if len(obj) != 1 else ''}"
|
321
|
+
return f'{{<... {item_count_str} at Max depth ...>}}'
|
322
|
+
|
317
323
|
if len(obj) > max_items:
|
318
324
|
return f'<dict len={len(obj)}>'
|
325
|
+
|
319
326
|
items = []
|
320
327
|
try:
|
321
328
|
sorted_keys = sorted(obj.keys(), key=str)
|
@@ -374,10 +381,12 @@ def _format_collection(
|
|
374
381
|
"""Formats a collection (list, tuple, set)."""
|
375
382
|
if isinstance(obj, list):
|
376
383
|
brackets = ('[', ']')
|
384
|
+
internal_obj = obj
|
377
385
|
elif isinstance(obj, tuple):
|
378
386
|
brackets = ('(', ')')
|
387
|
+
internal_obj = list(obj)
|
379
388
|
elif isinstance(obj, set):
|
380
|
-
|
389
|
+
internal_obj = list(obj)
|
381
390
|
if obj:
|
382
391
|
brackets = ('{', '}')
|
383
392
|
else:
|
@@ -385,19 +394,21 @@ def _format_collection(
|
|
385
394
|
else:
|
386
395
|
raise ValueError(f"Unsupported collection type: {type(obj)}")
|
387
396
|
|
388
|
-
if not
|
397
|
+
if not internal_obj:
|
389
398
|
return brackets[0] + brackets[1]
|
390
399
|
|
400
|
+
# If the call to _pretty_repr for elements will have depth < 0
|
401
|
+
if depth <= 0:
|
402
|
+
item_count_str = f"{len(internal_obj)} item{'s'*(len(internal_obj)!=1)}"
|
403
|
+
return f'{brackets[0]}<... {item_count_str} at Max depth ...>{brackets[1]}'
|
404
|
+
|
391
405
|
indent = ' ' * indent_level
|
392
406
|
next_indent_str = ' ' * (indent_level + indent_delta)
|
393
407
|
elements = []
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
)
|
399
|
-
break
|
400
|
-
# Each element starts on a new line, fully indented
|
408
|
+
num_to_show = min(len(internal_obj), max_items)
|
409
|
+
|
410
|
+
for i in range(num_to_show):
|
411
|
+
elem = internal_obj[i]
|
401
412
|
elements.append(
|
402
413
|
next_indent_str
|
403
414
|
+ _pretty_repr(
|
@@ -411,8 +422,12 @@ def _format_collection(
|
|
411
422
|
)
|
412
423
|
)
|
413
424
|
|
414
|
-
|
425
|
+
if len(internal_obj) > max_items:
|
426
|
+
elements.append(
|
427
|
+
f'{next_indent_str}<... {len(internal_obj) - max_items} more items ...>'
|
428
|
+
)
|
415
429
|
|
430
|
+
return f'{brackets[0]}\n' + ',\n'.join(elements) + f',\n{indent}{brackets[1]}'
|
416
431
|
|
417
432
|
class BaseModel(pydantic.BaseModel):
|
418
433
|
|