google-genai 1.50.1__tar.gz → 1.52.0__tar.gz
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-1.50.1/google_genai.egg-info → google_genai-1.52.0}/PKG-INFO +11 -10
- {google_genai-1.50.1 → google_genai-1.52.0}/README.md +9 -8
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_api_client.py +65 -7
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_common.py +38 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_extra_utils.py +25 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_live_converters.py +34 -2
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_tokens_converters.py +34 -2
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/batches.py +114 -4
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/caches.py +85 -3
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/models.py +155 -5
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/types.py +342 -59
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/version.py +1 -1
- {google_genai-1.50.1 → google_genai-1.52.0/google_genai.egg-info}/PKG-INFO +11 -10
- {google_genai-1.50.1 → google_genai-1.52.0}/google_genai.egg-info/requires.txt +1 -1
- {google_genai-1.50.1 → google_genai-1.52.0}/pyproject.toml +2 -2
- {google_genai-1.50.1 → google_genai-1.52.0}/LICENSE +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/MANIFEST.in +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/__init__.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_adapters.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_api_module.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_automatic_function_calling_util.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_base_transformers.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_base_url.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_local_tokenizer_loader.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_mcp_utils.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_operations_converters.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_replay_api_client.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_test_api_client.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/_transformers.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/chats.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/client.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/documents.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/errors.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/file_search_stores.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/files.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/live.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/live_music.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/local_tokenizer.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/operations.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/pagers.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/py.typed +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/tokens.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google/genai/tunings.py +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google_genai.egg-info/SOURCES.txt +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google_genai.egg-info/dependency_links.txt +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/google_genai.egg-info/top_level.txt +0 -0
- {google_genai-1.50.1 → google_genai-1.52.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-genai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.52.0
|
|
4
4
|
Summary: GenAI Python SDK
|
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -28,7 +28,7 @@ Requires-Dist: tenacity<9.2.0,>=8.2.3
|
|
|
28
28
|
Requires-Dist: websockets<15.1.0,>=13.0.0
|
|
29
29
|
Requires-Dist: typing-extensions<5.0.0,>=4.11.0
|
|
30
30
|
Provides-Extra: aiohttp
|
|
31
|
-
Requires-Dist: aiohttp<
|
|
31
|
+
Requires-Dist: aiohttp<3.13.3; extra == "aiohttp"
|
|
32
32
|
Provides-Extra: local-tokenizer
|
|
33
33
|
Requires-Dist: sentencepiece>=0.2.0; extra == "local-tokenizer"
|
|
34
34
|
Requires-Dist: protobuf; extra == "local-tokenizer"
|
|
@@ -1233,7 +1233,7 @@ from google.genai import types
|
|
|
1233
1233
|
|
|
1234
1234
|
# Generate Image
|
|
1235
1235
|
response1 = client.models.generate_images(
|
|
1236
|
-
model='imagen-
|
|
1236
|
+
model='imagen-4.0-generate-001',
|
|
1237
1237
|
prompt='An umbrella in the foreground, and a rainy night sky in the background',
|
|
1238
1238
|
config=types.GenerateImagesConfig(
|
|
1239
1239
|
number_of_images=1,
|
|
@@ -1253,7 +1253,7 @@ from google.genai import types
|
|
|
1253
1253
|
|
|
1254
1254
|
# Upscale the generated image from above
|
|
1255
1255
|
response2 = client.models.upscale_image(
|
|
1256
|
-
model='imagen-
|
|
1256
|
+
model='imagen-4.0-upscale-preview',
|
|
1257
1257
|
image=response1.generated_images[0].image,
|
|
1258
1258
|
upscale_factor='x2',
|
|
1259
1259
|
config=types.UpscaleImageConfig(
|
|
@@ -1314,7 +1314,7 @@ from google.genai import types
|
|
|
1314
1314
|
|
|
1315
1315
|
# Create operation
|
|
1316
1316
|
operation = client.models.generate_videos(
|
|
1317
|
-
model='veo-
|
|
1317
|
+
model='veo-3.1-generate-preview',
|
|
1318
1318
|
prompt='A neon hologram of a cat driving at top speed',
|
|
1319
1319
|
config=types.GenerateVideosConfig(
|
|
1320
1320
|
number_of_videos=1,
|
|
@@ -1342,7 +1342,7 @@ image = types.Image.from_file("local/path/file.png")
|
|
|
1342
1342
|
|
|
1343
1343
|
# Create operation
|
|
1344
1344
|
operation = client.models.generate_videos(
|
|
1345
|
-
model='veo-
|
|
1345
|
+
model='veo-3.1-generate-preview',
|
|
1346
1346
|
# Prompt is optional if image is provided
|
|
1347
1347
|
prompt='Night sky',
|
|
1348
1348
|
image=image,
|
|
@@ -1365,7 +1365,8 @@ video.show()
|
|
|
1365
1365
|
|
|
1366
1366
|
#### Generate Videos (Video to Video)
|
|
1367
1367
|
|
|
1368
|
-
Currently, only
|
|
1368
|
+
Currently, only Gemini Developer API supports video extension on Veo 3.1 for
|
|
1369
|
+
previously generated videos. Vertex supports video extension on Veo 2.0.
|
|
1369
1370
|
|
|
1370
1371
|
```python
|
|
1371
1372
|
from google.genai import types
|
|
@@ -1375,10 +1376,10 @@ video = types.Video.from_file("local/path/video.mp4")
|
|
|
1375
1376
|
|
|
1376
1377
|
# Create operation
|
|
1377
1378
|
operation = client.models.generate_videos(
|
|
1378
|
-
model='veo-
|
|
1379
|
+
model='veo-3.1-generate-preview',
|
|
1379
1380
|
# Prompt is optional if Video is provided
|
|
1380
1381
|
prompt='Night sky',
|
|
1381
|
-
# Input video must be in GCS
|
|
1382
|
+
# Input video must be in GCS for Vertex or a URI for Gemini
|
|
1382
1383
|
video=types.Video(
|
|
1383
1384
|
uri="gs://bucket-name/inputs/videos/cat_driving.mp4",
|
|
1384
1385
|
),
|
|
@@ -1553,7 +1554,7 @@ from google.genai import types
|
|
|
1553
1554
|
model = 'gemini-2.5-flash'
|
|
1554
1555
|
training_dataset = types.TuningDataset(
|
|
1555
1556
|
# or gcs_uri=my_vertex_multimodal_dataset
|
|
1556
|
-
gcs_uri='gs://
|
|
1557
|
+
gcs_uri='gs://your-gcs-bucket/your-tuning-data.jsonl',
|
|
1557
1558
|
)
|
|
1558
1559
|
```
|
|
1559
1560
|
|
|
@@ -1197,7 +1197,7 @@ from google.genai import types
|
|
|
1197
1197
|
|
|
1198
1198
|
# Generate Image
|
|
1199
1199
|
response1 = client.models.generate_images(
|
|
1200
|
-
model='imagen-
|
|
1200
|
+
model='imagen-4.0-generate-001',
|
|
1201
1201
|
prompt='An umbrella in the foreground, and a rainy night sky in the background',
|
|
1202
1202
|
config=types.GenerateImagesConfig(
|
|
1203
1203
|
number_of_images=1,
|
|
@@ -1217,7 +1217,7 @@ from google.genai import types
|
|
|
1217
1217
|
|
|
1218
1218
|
# Upscale the generated image from above
|
|
1219
1219
|
response2 = client.models.upscale_image(
|
|
1220
|
-
model='imagen-
|
|
1220
|
+
model='imagen-4.0-upscale-preview',
|
|
1221
1221
|
image=response1.generated_images[0].image,
|
|
1222
1222
|
upscale_factor='x2',
|
|
1223
1223
|
config=types.UpscaleImageConfig(
|
|
@@ -1278,7 +1278,7 @@ from google.genai import types
|
|
|
1278
1278
|
|
|
1279
1279
|
# Create operation
|
|
1280
1280
|
operation = client.models.generate_videos(
|
|
1281
|
-
model='veo-
|
|
1281
|
+
model='veo-3.1-generate-preview',
|
|
1282
1282
|
prompt='A neon hologram of a cat driving at top speed',
|
|
1283
1283
|
config=types.GenerateVideosConfig(
|
|
1284
1284
|
number_of_videos=1,
|
|
@@ -1306,7 +1306,7 @@ image = types.Image.from_file("local/path/file.png")
|
|
|
1306
1306
|
|
|
1307
1307
|
# Create operation
|
|
1308
1308
|
operation = client.models.generate_videos(
|
|
1309
|
-
model='veo-
|
|
1309
|
+
model='veo-3.1-generate-preview',
|
|
1310
1310
|
# Prompt is optional if image is provided
|
|
1311
1311
|
prompt='Night sky',
|
|
1312
1312
|
image=image,
|
|
@@ -1329,7 +1329,8 @@ video.show()
|
|
|
1329
1329
|
|
|
1330
1330
|
#### Generate Videos (Video to Video)
|
|
1331
1331
|
|
|
1332
|
-
Currently, only
|
|
1332
|
+
Currently, only Gemini Developer API supports video extension on Veo 3.1 for
|
|
1333
|
+
previously generated videos. Vertex supports video extension on Veo 2.0.
|
|
1333
1334
|
|
|
1334
1335
|
```python
|
|
1335
1336
|
from google.genai import types
|
|
@@ -1339,10 +1340,10 @@ video = types.Video.from_file("local/path/video.mp4")
|
|
|
1339
1340
|
|
|
1340
1341
|
# Create operation
|
|
1341
1342
|
operation = client.models.generate_videos(
|
|
1342
|
-
model='veo-
|
|
1343
|
+
model='veo-3.1-generate-preview',
|
|
1343
1344
|
# Prompt is optional if Video is provided
|
|
1344
1345
|
prompt='Night sky',
|
|
1345
|
-
# Input video must be in GCS
|
|
1346
|
+
# Input video must be in GCS for Vertex or a URI for Gemini
|
|
1346
1347
|
video=types.Video(
|
|
1347
1348
|
uri="gs://bucket-name/inputs/videos/cat_driving.mp4",
|
|
1348
1349
|
),
|
|
@@ -1517,7 +1518,7 @@ from google.genai import types
|
|
|
1517
1518
|
model = 'gemini-2.5-flash'
|
|
1518
1519
|
training_dataset = types.TuningDataset(
|
|
1519
1520
|
# or gcs_uri=my_vertex_multimodal_dataset
|
|
1520
|
-
gcs_uri='gs://
|
|
1521
|
+
gcs_uri='gs://your-gcs-bucket/your-tuning-data.jsonl',
|
|
1521
1522
|
)
|
|
1522
1523
|
```
|
|
1523
1524
|
|
|
@@ -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
|
|
@@ -55,6 +56,7 @@ from .types import HttpOptions
|
|
|
55
56
|
from .types import HttpOptionsOrDict
|
|
56
57
|
from .types import HttpResponse as SdkHttpResponse
|
|
57
58
|
from .types import HttpRetryOptions
|
|
59
|
+
from .types import ResourceScope
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
try:
|
|
@@ -578,6 +580,12 @@ class BaseApiClient:
|
|
|
578
580
|
elif isinstance(http_options, HttpOptions):
|
|
579
581
|
validated_http_options = http_options
|
|
580
582
|
|
|
583
|
+
if validated_http_options.base_url_resource_scope and not validated_http_options.base_url:
|
|
584
|
+
# base_url_resource_scope is only valid when base_url is set.
|
|
585
|
+
raise ValueError(
|
|
586
|
+
'base_url must be set when base_url_resource_scope is set.'
|
|
587
|
+
)
|
|
588
|
+
|
|
581
589
|
# Retrieve implicitly set values from the environment.
|
|
582
590
|
env_project = os.environ.get('GOOGLE_CLOUD_PROJECT', None)
|
|
583
591
|
env_location = os.environ.get('GOOGLE_CLOUD_LOCATION', None)
|
|
@@ -727,10 +735,44 @@ class BaseApiClient:
|
|
|
727
735
|
|
|
728
736
|
async def _get_aiohttp_session(self) -> 'aiohttp.ClientSession':
|
|
729
737
|
"""Returns the aiohttp client session."""
|
|
730
|
-
if
|
|
738
|
+
if (
|
|
739
|
+
self._aiohttp_session is None
|
|
740
|
+
or self._aiohttp_session.closed
|
|
741
|
+
or self._aiohttp_session._loop.is_closed() # pylint: disable=protected-access
|
|
742
|
+
):
|
|
731
743
|
# Initialize the aiohttp client session if it's not set up or closed.
|
|
732
|
-
|
|
733
|
-
|
|
744
|
+
class AiohttpClientSession(aiohttp.ClientSession): # type: ignore[misc]
|
|
745
|
+
|
|
746
|
+
def __del__(self, _warnings: Any = warnings) -> None:
|
|
747
|
+
if not self.closed:
|
|
748
|
+
context = {
|
|
749
|
+
'client_session': self,
|
|
750
|
+
'message': 'Unclosed client session',
|
|
751
|
+
}
|
|
752
|
+
if self._source_traceback is not None:
|
|
753
|
+
context['source_traceback'] = self._source_traceback
|
|
754
|
+
# Remove this self._loop.call_exception_handler(context)
|
|
755
|
+
|
|
756
|
+
class AiohttpTCPConnector(aiohttp.TCPConnector): # type: ignore[misc]
|
|
757
|
+
|
|
758
|
+
def __del__(self, _warnings: Any = warnings) -> None:
|
|
759
|
+
if self._closed:
|
|
760
|
+
return
|
|
761
|
+
if not self._conns:
|
|
762
|
+
return
|
|
763
|
+
conns = [repr(c) for c in self._conns.values()]
|
|
764
|
+
# After v3.13.2, it may change to self._close_immediately()
|
|
765
|
+
self._close()
|
|
766
|
+
context = {
|
|
767
|
+
'connector': self,
|
|
768
|
+
'connections': conns,
|
|
769
|
+
'message': 'Unclosed connector',
|
|
770
|
+
}
|
|
771
|
+
if self._source_traceback is not None:
|
|
772
|
+
context['source_traceback'] = self._source_traceback
|
|
773
|
+
# Remove this self._loop.call_exception_handler(context)
|
|
774
|
+
self._aiohttp_session = AiohttpClientSession(
|
|
775
|
+
connector=AiohttpTCPConnector(limit=0),
|
|
734
776
|
trust_env=True,
|
|
735
777
|
read_bufsize=READ_BUFFER_SIZE,
|
|
736
778
|
)
|
|
@@ -1044,6 +1086,11 @@ class BaseApiClient:
|
|
|
1044
1086
|
and not path.startswith('projects/')
|
|
1045
1087
|
and not query_vertex_base_models
|
|
1046
1088
|
and (self.project or self.location)
|
|
1089
|
+
and not (
|
|
1090
|
+
self.custom_base_url
|
|
1091
|
+
and patched_http_options.base_url_resource_scope
|
|
1092
|
+
== ResourceScope.COLLECTION
|
|
1093
|
+
)
|
|
1047
1094
|
):
|
|
1048
1095
|
path = f'projects/{self.project}/locations/{self.location}/' + path
|
|
1049
1096
|
|
|
@@ -1073,10 +1120,21 @@ class BaseApiClient:
|
|
|
1073
1120
|
or (self.project and self.location)
|
|
1074
1121
|
or self.api_key
|
|
1075
1122
|
):
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
)
|
|
1123
|
+
if (
|
|
1124
|
+
patched_http_options.base_url_resource_scope
|
|
1125
|
+
== ResourceScope.COLLECTION
|
|
1126
|
+
):
|
|
1127
|
+
url = join_url_path(base_url, path)
|
|
1128
|
+
else:
|
|
1129
|
+
url = join_url_path(
|
|
1130
|
+
base_url,
|
|
1131
|
+
versioned_path,
|
|
1132
|
+
)
|
|
1133
|
+
elif(
|
|
1134
|
+
self.custom_base_url
|
|
1135
|
+
and patched_http_options.base_url_resource_scope == ResourceScope.COLLECTION
|
|
1136
|
+
):
|
|
1137
|
+
url = join_url_path(base_url, path)
|
|
1080
1138
|
|
|
1081
1139
|
if self.api_key and self.api_key.startswith('auth_tokens/'):
|
|
1082
1140
|
raise EphemeralTokenAPIKeyError(
|
|
@@ -561,6 +561,44 @@ class BaseModel(pydantic.BaseModel):
|
|
|
561
561
|
ignored_types=(typing.TypeVar,),
|
|
562
562
|
)
|
|
563
563
|
|
|
564
|
+
@pydantic.model_validator(mode='before')
|
|
565
|
+
@classmethod
|
|
566
|
+
def _check_field_type_mismatches(cls, data: Any) -> Any:
|
|
567
|
+
"""Check for type mismatches and warn before Pydantic processes the data."""
|
|
568
|
+
# Handle both dict and Pydantic model inputs
|
|
569
|
+
if not isinstance(data, (dict, pydantic.BaseModel)):
|
|
570
|
+
return data
|
|
571
|
+
|
|
572
|
+
for field_name, field_info in cls.model_fields.items():
|
|
573
|
+
if isinstance(data, dict):
|
|
574
|
+
value = data.get(field_name)
|
|
575
|
+
else:
|
|
576
|
+
value = getattr(data, field_name, None)
|
|
577
|
+
|
|
578
|
+
if value is None:
|
|
579
|
+
continue
|
|
580
|
+
|
|
581
|
+
expected_type = field_info.annotation
|
|
582
|
+
origin = get_origin(expected_type)
|
|
583
|
+
|
|
584
|
+
if origin is Union:
|
|
585
|
+
args = get_args(expected_type)
|
|
586
|
+
non_none_types = [arg for arg in args if arg is not type(None)]
|
|
587
|
+
if len(non_none_types) == 1:
|
|
588
|
+
expected_type = non_none_types[0]
|
|
589
|
+
|
|
590
|
+
if (isinstance(expected_type, type) and
|
|
591
|
+
get_origin(expected_type) is None and
|
|
592
|
+
issubclass(expected_type, pydantic.BaseModel) and
|
|
593
|
+
isinstance(value, pydantic.BaseModel) and
|
|
594
|
+
not isinstance(value, expected_type)):
|
|
595
|
+
logger.warning(
|
|
596
|
+
f"Type mismatch in {cls.__name__}.{field_name}: "
|
|
597
|
+
f"expected {expected_type.__name__}, got {type(value).__name__}"
|
|
598
|
+
)
|
|
599
|
+
|
|
600
|
+
return data
|
|
601
|
+
|
|
564
602
|
def __repr__(self) -> str:
|
|
565
603
|
try:
|
|
566
604
|
return _pretty_repr(self)
|
|
@@ -489,6 +489,31 @@ def get_max_remote_calls_afc(
|
|
|
489
489
|
return int(config_model.automatic_function_calling.maximum_remote_calls)
|
|
490
490
|
|
|
491
491
|
|
|
492
|
+
def raise_error_for_afc_incompatible_config(config: Optional[types.GenerateContentConfig]
|
|
493
|
+
) -> None:
|
|
494
|
+
"""Raises an error if the config is not compatible with AFC."""
|
|
495
|
+
if (
|
|
496
|
+
not config
|
|
497
|
+
or not config.tool_config
|
|
498
|
+
or not config.tool_config.function_calling_config
|
|
499
|
+
):
|
|
500
|
+
return
|
|
501
|
+
afc_config = config.automatic_function_calling
|
|
502
|
+
disable_afc_config = afc_config.disable if afc_config else False
|
|
503
|
+
stream_function_call = (
|
|
504
|
+
config.tool_config.function_calling_config.stream_function_call_arguments
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
if stream_function_call and not disable_afc_config:
|
|
508
|
+
raise ValueError(
|
|
509
|
+
'Running in streaming mode with stream_function_call_arguments'
|
|
510
|
+
' enabled, this feature is not compatible with automatic function'
|
|
511
|
+
' calling (AFC). Please set config.automatic_function_calling.disable'
|
|
512
|
+
' to True to disable AFC or leave config.tool_config.'
|
|
513
|
+
' function_calling_config.stream_function_call_arguments to be empty'
|
|
514
|
+
' or set to False to disable streaming function call arguments.'
|
|
515
|
+
)
|
|
516
|
+
|
|
492
517
|
def should_append_afc_history(
|
|
493
518
|
config: Optional[types.GenerateContentConfigOrDict] = None,
|
|
494
519
|
) -> bool:
|
|
@@ -78,6 +78,29 @@ def _FileData_to_mldev(
|
|
|
78
78
|
return to_object
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
def _FunctionCall_to_mldev(
|
|
82
|
+
from_object: Union[dict[str, Any], object],
|
|
83
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
84
|
+
) -> dict[str, Any]:
|
|
85
|
+
to_object: dict[str, Any] = {}
|
|
86
|
+
if getv(from_object, ['id']) is not None:
|
|
87
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
88
|
+
|
|
89
|
+
if getv(from_object, ['args']) is not None:
|
|
90
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
91
|
+
|
|
92
|
+
if getv(from_object, ['name']) is not None:
|
|
93
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
94
|
+
|
|
95
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
96
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
97
|
+
|
|
98
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
99
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
100
|
+
|
|
101
|
+
return to_object
|
|
102
|
+
|
|
103
|
+
|
|
81
104
|
def _FunctionDeclaration_to_vertex(
|
|
82
105
|
from_object: Union[dict[str, Any], object],
|
|
83
106
|
parent_object: Optional[dict[str, Any]] = None,
|
|
@@ -1161,8 +1184,10 @@ def _Part_to_mldev(
|
|
|
1161
1184
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1162
1185
|
) -> dict[str, Any]:
|
|
1163
1186
|
to_object: dict[str, Any] = {}
|
|
1164
|
-
if getv(from_object, ['
|
|
1165
|
-
setv(
|
|
1187
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
1188
|
+
setv(
|
|
1189
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
1190
|
+
)
|
|
1166
1191
|
|
|
1167
1192
|
if getv(from_object, ['code_execution_result']) is not None:
|
|
1168
1193
|
setv(
|
|
@@ -1181,6 +1206,13 @@ def _Part_to_mldev(
|
|
|
1181
1206
|
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
1182
1207
|
)
|
|
1183
1208
|
|
|
1209
|
+
if getv(from_object, ['function_call']) is not None:
|
|
1210
|
+
setv(
|
|
1211
|
+
to_object,
|
|
1212
|
+
['functionCall'],
|
|
1213
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1184
1216
|
if getv(from_object, ['function_response']) is not None:
|
|
1185
1217
|
setv(
|
|
1186
1218
|
to_object,
|
|
@@ -148,6 +148,29 @@ def _FileData_to_mldev(
|
|
|
148
148
|
return to_object
|
|
149
149
|
|
|
150
150
|
|
|
151
|
+
def _FunctionCall_to_mldev(
|
|
152
|
+
from_object: Union[dict[str, Any], object],
|
|
153
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
154
|
+
) -> dict[str, Any]:
|
|
155
|
+
to_object: dict[str, Any] = {}
|
|
156
|
+
if getv(from_object, ['id']) is not None:
|
|
157
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
158
|
+
|
|
159
|
+
if getv(from_object, ['args']) is not None:
|
|
160
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
161
|
+
|
|
162
|
+
if getv(from_object, ['name']) is not None:
|
|
163
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
164
|
+
|
|
165
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
166
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
167
|
+
|
|
168
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
169
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
170
|
+
|
|
171
|
+
return to_object
|
|
172
|
+
|
|
173
|
+
|
|
151
174
|
def _GoogleMaps_to_mldev(
|
|
152
175
|
from_object: Union[dict[str, Any], object],
|
|
153
176
|
parent_object: Optional[dict[str, Any]] = None,
|
|
@@ -365,8 +388,10 @@ def _Part_to_mldev(
|
|
|
365
388
|
parent_object: Optional[dict[str, Any]] = None,
|
|
366
389
|
) -> dict[str, Any]:
|
|
367
390
|
to_object: dict[str, Any] = {}
|
|
368
|
-
if getv(from_object, ['
|
|
369
|
-
setv(
|
|
391
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
392
|
+
setv(
|
|
393
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
394
|
+
)
|
|
370
395
|
|
|
371
396
|
if getv(from_object, ['code_execution_result']) is not None:
|
|
372
397
|
setv(
|
|
@@ -385,6 +410,13 @@ def _Part_to_mldev(
|
|
|
385
410
|
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
386
411
|
)
|
|
387
412
|
|
|
413
|
+
if getv(from_object, ['function_call']) is not None:
|
|
414
|
+
setv(
|
|
415
|
+
to_object,
|
|
416
|
+
['functionCall'],
|
|
417
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
418
|
+
)
|
|
419
|
+
|
|
388
420
|
if getv(from_object, ['function_response']) is not None:
|
|
389
421
|
setv(
|
|
390
422
|
to_object,
|
|
@@ -796,6 +796,53 @@ def _FileData_to_mldev(
|
|
|
796
796
|
return to_object
|
|
797
797
|
|
|
798
798
|
|
|
799
|
+
def _FunctionCall_to_mldev(
|
|
800
|
+
from_object: Union[dict[str, Any], object],
|
|
801
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
802
|
+
) -> dict[str, Any]:
|
|
803
|
+
to_object: dict[str, Any] = {}
|
|
804
|
+
if getv(from_object, ['id']) is not None:
|
|
805
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
806
|
+
|
|
807
|
+
if getv(from_object, ['args']) is not None:
|
|
808
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
809
|
+
|
|
810
|
+
if getv(from_object, ['name']) is not None:
|
|
811
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
812
|
+
|
|
813
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
814
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
815
|
+
|
|
816
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
817
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
818
|
+
|
|
819
|
+
return to_object
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
def _FunctionCallingConfig_to_mldev(
|
|
823
|
+
from_object: Union[dict[str, Any], object],
|
|
824
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
825
|
+
) -> dict[str, Any]:
|
|
826
|
+
to_object: dict[str, Any] = {}
|
|
827
|
+
if getv(from_object, ['mode']) is not None:
|
|
828
|
+
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
829
|
+
|
|
830
|
+
if getv(from_object, ['allowed_function_names']) is not None:
|
|
831
|
+
setv(
|
|
832
|
+
to_object,
|
|
833
|
+
['allowedFunctionNames'],
|
|
834
|
+
getv(from_object, ['allowed_function_names']),
|
|
835
|
+
)
|
|
836
|
+
|
|
837
|
+
if getv(from_object, ['stream_function_call_arguments']) is not None:
|
|
838
|
+
raise ValueError(
|
|
839
|
+
'stream_function_call_arguments parameter is not supported in Gemini'
|
|
840
|
+
' API.'
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
return to_object
|
|
844
|
+
|
|
845
|
+
|
|
799
846
|
def _GenerateContentConfig_to_mldev(
|
|
800
847
|
api_client: BaseApiClient,
|
|
801
848
|
from_object: Union[dict[str, Any], object],
|
|
@@ -907,7 +954,11 @@ def _GenerateContentConfig_to_mldev(
|
|
|
907
954
|
)
|
|
908
955
|
|
|
909
956
|
if getv(from_object, ['tool_config']) is not None:
|
|
910
|
-
setv(
|
|
957
|
+
setv(
|
|
958
|
+
parent_object,
|
|
959
|
+
['toolConfig'],
|
|
960
|
+
_ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
|
|
961
|
+
)
|
|
911
962
|
|
|
912
963
|
if getv(from_object, ['labels']) is not None:
|
|
913
964
|
raise ValueError('labels parameter is not supported in Gemini API.')
|
|
@@ -949,7 +1000,11 @@ def _GenerateContentConfig_to_mldev(
|
|
|
949
1000
|
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
|
950
1001
|
|
|
951
1002
|
if getv(from_object, ['image_config']) is not None:
|
|
952
|
-
setv(
|
|
1003
|
+
setv(
|
|
1004
|
+
to_object,
|
|
1005
|
+
['imageConfig'],
|
|
1006
|
+
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
|
|
1007
|
+
)
|
|
953
1008
|
|
|
954
1009
|
return to_object
|
|
955
1010
|
|
|
@@ -1058,6 +1113,30 @@ def _GoogleSearch_to_mldev(
|
|
|
1058
1113
|
return to_object
|
|
1059
1114
|
|
|
1060
1115
|
|
|
1116
|
+
def _ImageConfig_to_mldev(
|
|
1117
|
+
from_object: Union[dict[str, Any], object],
|
|
1118
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1119
|
+
) -> dict[str, Any]:
|
|
1120
|
+
to_object: dict[str, Any] = {}
|
|
1121
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
|
1122
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
|
1123
|
+
|
|
1124
|
+
if getv(from_object, ['image_size']) is not None:
|
|
1125
|
+
setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
|
|
1126
|
+
|
|
1127
|
+
if getv(from_object, ['output_mime_type']) is not None:
|
|
1128
|
+
raise ValueError(
|
|
1129
|
+
'output_mime_type parameter is not supported in Gemini API.'
|
|
1130
|
+
)
|
|
1131
|
+
|
|
1132
|
+
if getv(from_object, ['output_compression_quality']) is not None:
|
|
1133
|
+
raise ValueError(
|
|
1134
|
+
'output_compression_quality parameter is not supported in Gemini API.'
|
|
1135
|
+
)
|
|
1136
|
+
|
|
1137
|
+
return to_object
|
|
1138
|
+
|
|
1139
|
+
|
|
1061
1140
|
def _InlinedRequest_to_mldev(
|
|
1062
1141
|
api_client: BaseApiClient,
|
|
1063
1142
|
from_object: Union[dict[str, Any], object],
|
|
@@ -1245,8 +1324,10 @@ def _Part_to_mldev(
|
|
|
1245
1324
|
parent_object: Optional[dict[str, Any]] = None,
|
|
1246
1325
|
) -> dict[str, Any]:
|
|
1247
1326
|
to_object: dict[str, Any] = {}
|
|
1248
|
-
if getv(from_object, ['
|
|
1249
|
-
setv(
|
|
1327
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
1328
|
+
setv(
|
|
1329
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
1330
|
+
)
|
|
1250
1331
|
|
|
1251
1332
|
if getv(from_object, ['code_execution_result']) is not None:
|
|
1252
1333
|
setv(
|
|
@@ -1265,6 +1346,13 @@ def _Part_to_mldev(
|
|
|
1265
1346
|
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
1266
1347
|
)
|
|
1267
1348
|
|
|
1349
|
+
if getv(from_object, ['function_call']) is not None:
|
|
1350
|
+
setv(
|
|
1351
|
+
to_object,
|
|
1352
|
+
['functionCall'],
|
|
1353
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
1354
|
+
)
|
|
1355
|
+
|
|
1268
1356
|
if getv(from_object, ['function_response']) is not None:
|
|
1269
1357
|
setv(
|
|
1270
1358
|
to_object,
|
|
@@ -1315,6 +1403,28 @@ def _SafetySetting_to_mldev(
|
|
|
1315
1403
|
return to_object
|
|
1316
1404
|
|
|
1317
1405
|
|
|
1406
|
+
def _ToolConfig_to_mldev(
|
|
1407
|
+
from_object: Union[dict[str, Any], object],
|
|
1408
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
1409
|
+
) -> dict[str, Any]:
|
|
1410
|
+
to_object: dict[str, Any] = {}
|
|
1411
|
+
if getv(from_object, ['function_calling_config']) is not None:
|
|
1412
|
+
setv(
|
|
1413
|
+
to_object,
|
|
1414
|
+
['functionCallingConfig'],
|
|
1415
|
+
_FunctionCallingConfig_to_mldev(
|
|
1416
|
+
getv(from_object, ['function_calling_config']), to_object
|
|
1417
|
+
),
|
|
1418
|
+
)
|
|
1419
|
+
|
|
1420
|
+
if getv(from_object, ['retrieval_config']) is not None:
|
|
1421
|
+
setv(
|
|
1422
|
+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
return to_object
|
|
1426
|
+
|
|
1427
|
+
|
|
1318
1428
|
def _Tool_to_mldev(
|
|
1319
1429
|
from_object: Union[dict[str, Any], object],
|
|
1320
1430
|
parent_object: Optional[dict[str, Any]] = None,
|