google-genai 1.50.1__py3-none-any.whl → 1.51.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/_common.py +37 -0
- google/genai/_extra_utils.py +25 -0
- google/genai/_live_converters.py +34 -2
- google/genai/_tokens_converters.py +34 -2
- google/genai/batches.py +114 -4
- google/genai/caches.py +85 -3
- google/genai/models.py +155 -5
- google/genai/types.py +324 -59
- google/genai/version.py +1 -1
- {google_genai-1.50.1.dist-info → google_genai-1.51.0.dist-info}/METADATA +10 -9
- {google_genai-1.50.1.dist-info → google_genai-1.51.0.dist-info}/RECORD +14 -14
- {google_genai-1.50.1.dist-info → google_genai-1.51.0.dist-info}/WHEEL +0 -0
- {google_genai-1.50.1.dist-info → google_genai-1.51.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.50.1.dist-info → google_genai-1.51.0.dist-info}/top_level.txt +0 -0
google/genai/models.py
CHANGED
|
@@ -863,6 +863,53 @@ def _FileData_to_mldev(
|
|
|
863
863
|
return to_object
|
|
864
864
|
|
|
865
865
|
|
|
866
|
+
def _FunctionCall_to_mldev(
|
|
867
|
+
from_object: Union[dict[str, Any], object],
|
|
868
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
869
|
+
) -> dict[str, Any]:
|
|
870
|
+
to_object: dict[str, Any] = {}
|
|
871
|
+
if getv(from_object, ['id']) is not None:
|
|
872
|
+
setv(to_object, ['id'], getv(from_object, ['id']))
|
|
873
|
+
|
|
874
|
+
if getv(from_object, ['args']) is not None:
|
|
875
|
+
setv(to_object, ['args'], getv(from_object, ['args']))
|
|
876
|
+
|
|
877
|
+
if getv(from_object, ['name']) is not None:
|
|
878
|
+
setv(to_object, ['name'], getv(from_object, ['name']))
|
|
879
|
+
|
|
880
|
+
if getv(from_object, ['partial_args']) is not None:
|
|
881
|
+
raise ValueError('partial_args parameter is not supported in Gemini API.')
|
|
882
|
+
|
|
883
|
+
if getv(from_object, ['will_continue']) is not None:
|
|
884
|
+
raise ValueError('will_continue parameter is not supported in Gemini API.')
|
|
885
|
+
|
|
886
|
+
return to_object
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
def _FunctionCallingConfig_to_mldev(
|
|
890
|
+
from_object: Union[dict[str, Any], object],
|
|
891
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
892
|
+
) -> dict[str, Any]:
|
|
893
|
+
to_object: dict[str, Any] = {}
|
|
894
|
+
if getv(from_object, ['mode']) is not None:
|
|
895
|
+
setv(to_object, ['mode'], getv(from_object, ['mode']))
|
|
896
|
+
|
|
897
|
+
if getv(from_object, ['allowed_function_names']) is not None:
|
|
898
|
+
setv(
|
|
899
|
+
to_object,
|
|
900
|
+
['allowedFunctionNames'],
|
|
901
|
+
getv(from_object, ['allowed_function_names']),
|
|
902
|
+
)
|
|
903
|
+
|
|
904
|
+
if getv(from_object, ['stream_function_call_arguments']) is not None:
|
|
905
|
+
raise ValueError(
|
|
906
|
+
'stream_function_call_arguments parameter is not supported in Gemini'
|
|
907
|
+
' API.'
|
|
908
|
+
)
|
|
909
|
+
|
|
910
|
+
return to_object
|
|
911
|
+
|
|
912
|
+
|
|
866
913
|
def _FunctionDeclaration_to_vertex(
|
|
867
914
|
from_object: Union[dict[str, Any], object],
|
|
868
915
|
parent_object: Optional[dict[str, Any]] = None,
|
|
@@ -1011,7 +1058,11 @@ def _GenerateContentConfig_to_mldev(
|
|
|
1011
1058
|
)
|
|
1012
1059
|
|
|
1013
1060
|
if getv(from_object, ['tool_config']) is not None:
|
|
1014
|
-
setv(
|
|
1061
|
+
setv(
|
|
1062
|
+
parent_object,
|
|
1063
|
+
['toolConfig'],
|
|
1064
|
+
_ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
|
|
1065
|
+
)
|
|
1015
1066
|
|
|
1016
1067
|
if getv(from_object, ['labels']) is not None:
|
|
1017
1068
|
raise ValueError('labels parameter is not supported in Gemini API.')
|
|
@@ -1053,7 +1104,11 @@ def _GenerateContentConfig_to_mldev(
|
|
|
1053
1104
|
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
|
1054
1105
|
|
|
1055
1106
|
if getv(from_object, ['image_config']) is not None:
|
|
1056
|
-
setv(
|
|
1107
|
+
setv(
|
|
1108
|
+
to_object,
|
|
1109
|
+
['imageConfig'],
|
|
1110
|
+
_ImageConfig_to_mldev(getv(from_object, ['image_config']), to_object),
|
|
1111
|
+
)
|
|
1057
1112
|
|
|
1058
1113
|
return to_object
|
|
1059
1114
|
|
|
@@ -1208,7 +1263,11 @@ def _GenerateContentConfig_to_vertex(
|
|
|
1208
1263
|
setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
|
|
1209
1264
|
|
|
1210
1265
|
if getv(from_object, ['image_config']) is not None:
|
|
1211
|
-
setv(
|
|
1266
|
+
setv(
|
|
1267
|
+
to_object,
|
|
1268
|
+
['imageConfig'],
|
|
1269
|
+
_ImageConfig_to_vertex(getv(from_object, ['image_config']), to_object),
|
|
1270
|
+
)
|
|
1212
1271
|
|
|
1213
1272
|
return to_object
|
|
1214
1273
|
|
|
@@ -2475,6 +2534,58 @@ def _GoogleSearch_to_mldev(
|
|
|
2475
2534
|
return to_object
|
|
2476
2535
|
|
|
2477
2536
|
|
|
2537
|
+
def _ImageConfig_to_mldev(
|
|
2538
|
+
from_object: Union[dict[str, Any], object],
|
|
2539
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
2540
|
+
) -> dict[str, Any]:
|
|
2541
|
+
to_object: dict[str, Any] = {}
|
|
2542
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
|
2543
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
|
2544
|
+
|
|
2545
|
+
if getv(from_object, ['image_size']) is not None:
|
|
2546
|
+
setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
|
|
2547
|
+
|
|
2548
|
+
if getv(from_object, ['output_mime_type']) is not None:
|
|
2549
|
+
raise ValueError(
|
|
2550
|
+
'output_mime_type parameter is not supported in Gemini API.'
|
|
2551
|
+
)
|
|
2552
|
+
|
|
2553
|
+
if getv(from_object, ['output_compression_quality']) is not None:
|
|
2554
|
+
raise ValueError(
|
|
2555
|
+
'output_compression_quality parameter is not supported in Gemini API.'
|
|
2556
|
+
)
|
|
2557
|
+
|
|
2558
|
+
return to_object
|
|
2559
|
+
|
|
2560
|
+
|
|
2561
|
+
def _ImageConfig_to_vertex(
|
|
2562
|
+
from_object: Union[dict[str, Any], object],
|
|
2563
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
2564
|
+
) -> dict[str, Any]:
|
|
2565
|
+
to_object: dict[str, Any] = {}
|
|
2566
|
+
if getv(from_object, ['aspect_ratio']) is not None:
|
|
2567
|
+
setv(to_object, ['aspectRatio'], getv(from_object, ['aspect_ratio']))
|
|
2568
|
+
|
|
2569
|
+
if getv(from_object, ['image_size']) is not None:
|
|
2570
|
+
setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
|
|
2571
|
+
|
|
2572
|
+
if getv(from_object, ['output_mime_type']) is not None:
|
|
2573
|
+
setv(
|
|
2574
|
+
to_object,
|
|
2575
|
+
['imageOutputOptions', 'mimeType'],
|
|
2576
|
+
getv(from_object, ['output_mime_type']),
|
|
2577
|
+
)
|
|
2578
|
+
|
|
2579
|
+
if getv(from_object, ['output_compression_quality']) is not None:
|
|
2580
|
+
setv(
|
|
2581
|
+
to_object,
|
|
2582
|
+
['imageOutputOptions', 'compressionQuality'],
|
|
2583
|
+
getv(from_object, ['output_compression_quality']),
|
|
2584
|
+
)
|
|
2585
|
+
|
|
2586
|
+
return to_object
|
|
2587
|
+
|
|
2588
|
+
|
|
2478
2589
|
def _Image_from_mldev(
|
|
2479
2590
|
from_object: Union[dict[str, Any], object],
|
|
2480
2591
|
parent_object: Optional[dict[str, Any]] = None,
|
|
@@ -2836,8 +2947,10 @@ def _Part_to_mldev(
|
|
|
2836
2947
|
parent_object: Optional[dict[str, Any]] = None,
|
|
2837
2948
|
) -> dict[str, Any]:
|
|
2838
2949
|
to_object: dict[str, Any] = {}
|
|
2839
|
-
if getv(from_object, ['
|
|
2840
|
-
setv(
|
|
2950
|
+
if getv(from_object, ['media_resolution']) is not None:
|
|
2951
|
+
setv(
|
|
2952
|
+
to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
|
|
2953
|
+
)
|
|
2841
2954
|
|
|
2842
2955
|
if getv(from_object, ['code_execution_result']) is not None:
|
|
2843
2956
|
setv(
|
|
@@ -2856,6 +2969,13 @@ def _Part_to_mldev(
|
|
|
2856
2969
|
_FileData_to_mldev(getv(from_object, ['file_data']), to_object),
|
|
2857
2970
|
)
|
|
2858
2971
|
|
|
2972
|
+
if getv(from_object, ['function_call']) is not None:
|
|
2973
|
+
setv(
|
|
2974
|
+
to_object,
|
|
2975
|
+
['functionCall'],
|
|
2976
|
+
_FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
|
|
2977
|
+
)
|
|
2978
|
+
|
|
2859
2979
|
if getv(from_object, ['function_response']) is not None:
|
|
2860
2980
|
setv(
|
|
2861
2981
|
to_object,
|
|
@@ -3314,6 +3434,28 @@ def _SpeechConfig_to_vertex(
|
|
|
3314
3434
|
return to_object
|
|
3315
3435
|
|
|
3316
3436
|
|
|
3437
|
+
def _ToolConfig_to_mldev(
|
|
3438
|
+
from_object: Union[dict[str, Any], object],
|
|
3439
|
+
parent_object: Optional[dict[str, Any]] = None,
|
|
3440
|
+
) -> dict[str, Any]:
|
|
3441
|
+
to_object: dict[str, Any] = {}
|
|
3442
|
+
if getv(from_object, ['function_calling_config']) is not None:
|
|
3443
|
+
setv(
|
|
3444
|
+
to_object,
|
|
3445
|
+
['functionCallingConfig'],
|
|
3446
|
+
_FunctionCallingConfig_to_mldev(
|
|
3447
|
+
getv(from_object, ['function_calling_config']), to_object
|
|
3448
|
+
),
|
|
3449
|
+
)
|
|
3450
|
+
|
|
3451
|
+
if getv(from_object, ['retrieval_config']) is not None:
|
|
3452
|
+
setv(
|
|
3453
|
+
to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
|
|
3454
|
+
)
|
|
3455
|
+
|
|
3456
|
+
return to_object
|
|
3457
|
+
|
|
3458
|
+
|
|
3317
3459
|
def _Tool_to_mldev(
|
|
3318
3460
|
from_object: Union[dict[str, Any], object],
|
|
3319
3461
|
parent_object: Optional[dict[str, Any]] = None,
|
|
@@ -5224,6 +5366,10 @@ class Models(_api_module.BaseModule):
|
|
|
5224
5366
|
)
|
|
5225
5367
|
return
|
|
5226
5368
|
|
|
5369
|
+
# With tool compatibility confirmed, validate that the configuration are
|
|
5370
|
+
# compatible with each other and raise an error if invalid.
|
|
5371
|
+
_extra_utils.raise_error_for_afc_incompatible_config(parsed_config)
|
|
5372
|
+
|
|
5227
5373
|
remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(
|
|
5228
5374
|
parsed_config
|
|
5229
5375
|
)
|
|
@@ -7046,6 +7192,10 @@ class AsyncModels(_api_module.BaseModule):
|
|
|
7046
7192
|
|
|
7047
7193
|
return base_async_generator(model, contents, parsed_config) # type: ignore[no-untyped-call, no-any-return]
|
|
7048
7194
|
|
|
7195
|
+
# With tool compatibility confirmed, validate that the configuration are
|
|
7196
|
+
# compatible with each other and raise an error if invalid.
|
|
7197
|
+
_extra_utils.raise_error_for_afc_incompatible_config(parsed_config)
|
|
7198
|
+
|
|
7049
7199
|
async def async_generator(model, contents, config): # type: ignore[no-untyped-def]
|
|
7050
7200
|
remaining_remote_calls_afc = _extra_utils.get_max_remote_calls_afc(config)
|
|
7051
7201
|
logger.info(
|