google-genai 1.4.0__py3-none-any.whl → 1.5.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 +115 -45
- google/genai/_automatic_function_calling_util.py +3 -3
- google/genai/_common.py +5 -2
- google/genai/_extra_utils.py +62 -47
- google/genai/_replay_api_client.py +70 -2
- google/genai/_transformers.py +43 -26
- google/genai/batches.py +10 -10
- google/genai/caches.py +10 -10
- google/genai/files.py +22 -9
- google/genai/models.py +70 -46
- google/genai/operations.py +10 -10
- google/genai/pagers.py +14 -5
- google/genai/tunings.py +9 -9
- google/genai/types.py +59 -26
- google/genai/version.py +1 -1
- {google_genai-1.4.0.dist-info → google_genai-1.5.0.dist-info}/METADATA +2 -1
- google_genai-1.5.0.dist-info/RECORD +27 -0
- google_genai-1.4.0.dist-info/RECORD +0 -27
- {google_genai-1.4.0.dist-info → google_genai-1.5.0.dist-info}/LICENSE +0 -0
- {google_genai-1.4.0.dist-info → google_genai-1.5.0.dist-info}/WHEEL +0 -0
- {google_genai-1.4.0.dist-info → google_genai-1.5.0.dist-info}/top_level.txt +0 -0
google/genai/models.py
CHANGED
@@ -2813,8 +2813,10 @@ def _GenerateVideosConfig_to_mldev(
|
|
2813
2813
|
raise ValueError('fps parameter is not supported in Gemini API.')
|
2814
2814
|
|
2815
2815
|
if getv(from_object, ['duration_seconds']) is not None:
|
2816
|
-
|
2817
|
-
|
2816
|
+
setv(
|
2817
|
+
parent_object,
|
2818
|
+
['parameters', 'durationSeconds'],
|
2819
|
+
getv(from_object, ['duration_seconds']),
|
2818
2820
|
)
|
2819
2821
|
|
2820
2822
|
if getv(from_object, ['seed']) is not None:
|
@@ -2948,6 +2950,13 @@ def _GenerateVideosParameters_to_mldev(
|
|
2948
2950
|
if getv(from_object, ['prompt']) is not None:
|
2949
2951
|
setv(to_object, ['instances[0]', 'prompt'], getv(from_object, ['prompt']))
|
2950
2952
|
|
2953
|
+
if getv(from_object, ['image']) is not None:
|
2954
|
+
setv(
|
2955
|
+
to_object,
|
2956
|
+
['instances[0]', 'image'],
|
2957
|
+
_Image_to_mldev(api_client, getv(from_object, ['image']), to_object),
|
2958
|
+
)
|
2959
|
+
|
2951
2960
|
if getv(from_object, ['config']) is not None:
|
2952
2961
|
setv(
|
2953
2962
|
to_object,
|
@@ -2976,6 +2985,13 @@ def _GenerateVideosParameters_to_vertex(
|
|
2976
2985
|
if getv(from_object, ['prompt']) is not None:
|
2977
2986
|
setv(to_object, ['instances[0]', 'prompt'], getv(from_object, ['prompt']))
|
2978
2987
|
|
2988
|
+
if getv(from_object, ['image']) is not None:
|
2989
|
+
setv(
|
2990
|
+
to_object,
|
2991
|
+
['instances[0]', 'image'],
|
2992
|
+
_Image_to_vertex(api_client, getv(from_object, ['image']), to_object),
|
2993
|
+
)
|
2994
|
+
|
2979
2995
|
if getv(from_object, ['config']) is not None:
|
2980
2996
|
setv(
|
2981
2997
|
to_object,
|
@@ -3999,14 +4015,14 @@ def _Video_from_mldev(
|
|
3999
4015
|
parent_object: Optional[dict] = None,
|
4000
4016
|
) -> dict:
|
4001
4017
|
to_object: dict[str, Any] = {}
|
4002
|
-
if getv(from_object, ['uri']) is not None:
|
4003
|
-
setv(to_object, ['uri'], getv(from_object, ['uri']))
|
4018
|
+
if getv(from_object, ['video', 'uri']) is not None:
|
4019
|
+
setv(to_object, ['uri'], getv(from_object, ['video', 'uri']))
|
4004
4020
|
|
4005
|
-
if getv(from_object, ['encodedVideo']) is not None:
|
4021
|
+
if getv(from_object, ['video', 'encodedVideo']) is not None:
|
4006
4022
|
setv(
|
4007
4023
|
to_object,
|
4008
4024
|
['video_bytes'],
|
4009
|
-
t.t_bytes(api_client, getv(from_object, ['encodedVideo'])),
|
4025
|
+
t.t_bytes(api_client, getv(from_object, ['video', 'encodedVideo'])),
|
4010
4026
|
)
|
4011
4027
|
|
4012
4028
|
if getv(from_object, ['encoding']) is not None:
|
@@ -4075,13 +4091,13 @@ def _GenerateVideosResponse_from_mldev(
|
|
4075
4091
|
parent_object: Optional[dict] = None,
|
4076
4092
|
) -> dict:
|
4077
4093
|
to_object: dict[str, Any] = {}
|
4078
|
-
if getv(from_object, ['
|
4094
|
+
if getv(from_object, ['generatedSamples']) is not None:
|
4079
4095
|
setv(
|
4080
4096
|
to_object,
|
4081
4097
|
['generated_videos'],
|
4082
4098
|
[
|
4083
4099
|
_GeneratedVideo_from_mldev(api_client, item, to_object)
|
4084
|
-
for item in getv(from_object, ['
|
4100
|
+
for item in getv(from_object, ['generatedSamples'])
|
4085
4101
|
],
|
4086
4102
|
)
|
4087
4103
|
|
@@ -4247,7 +4263,7 @@ class Models(_api_module.BaseModule):
|
|
4247
4263
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4248
4264
|
if isinstance(config, dict):
|
4249
4265
|
http_options = config.get('http_options', None)
|
4250
|
-
elif hasattr(config, 'http_options'):
|
4266
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4251
4267
|
http_options = config.http_options
|
4252
4268
|
|
4253
4269
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4318,7 +4334,7 @@ class Models(_api_module.BaseModule):
|
|
4318
4334
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4319
4335
|
if isinstance(config, dict):
|
4320
4336
|
http_options = config.get('http_options', None)
|
4321
|
-
elif hasattr(config, 'http_options'):
|
4337
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4322
4338
|
http_options = config.http_options
|
4323
4339
|
|
4324
4340
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4408,7 +4424,7 @@ class Models(_api_module.BaseModule):
|
|
4408
4424
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4409
4425
|
if isinstance(config, dict):
|
4410
4426
|
http_options = config.get('http_options', None)
|
4411
|
-
elif hasattr(config, 'http_options'):
|
4427
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4412
4428
|
http_options = config.http_options
|
4413
4429
|
|
4414
4430
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4498,7 +4514,7 @@ class Models(_api_module.BaseModule):
|
|
4498
4514
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4499
4515
|
if isinstance(config, dict):
|
4500
4516
|
http_options = config.get('http_options', None)
|
4501
|
-
elif hasattr(config, 'http_options'):
|
4517
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4502
4518
|
http_options = config.http_options
|
4503
4519
|
|
4504
4520
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4602,7 +4618,7 @@ class Models(_api_module.BaseModule):
|
|
4602
4618
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4603
4619
|
if isinstance(config, dict):
|
4604
4620
|
http_options = config.get('http_options', None)
|
4605
|
-
elif hasattr(config, 'http_options'):
|
4621
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4606
4622
|
http_options = config.http_options
|
4607
4623
|
|
4608
4624
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4673,7 +4689,7 @@ class Models(_api_module.BaseModule):
|
|
4673
4689
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4674
4690
|
if isinstance(config, dict):
|
4675
4691
|
http_options = config.get('http_options', None)
|
4676
|
-
elif hasattr(config, 'http_options'):
|
4692
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4677
4693
|
http_options = config.http_options
|
4678
4694
|
|
4679
4695
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4735,7 +4751,7 @@ class Models(_api_module.BaseModule):
|
|
4735
4751
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4736
4752
|
if isinstance(config, dict):
|
4737
4753
|
http_options = config.get('http_options', None)
|
4738
|
-
elif hasattr(config, 'http_options'):
|
4754
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4739
4755
|
http_options = config.http_options
|
4740
4756
|
|
4741
4757
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4792,7 +4808,7 @@ class Models(_api_module.BaseModule):
|
|
4792
4808
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4793
4809
|
if isinstance(config, dict):
|
4794
4810
|
http_options = config.get('http_options', None)
|
4795
|
-
elif hasattr(config, 'http_options'):
|
4811
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4796
4812
|
http_options = config.http_options
|
4797
4813
|
|
4798
4814
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4857,7 +4873,7 @@ class Models(_api_module.BaseModule):
|
|
4857
4873
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4858
4874
|
if isinstance(config, dict):
|
4859
4875
|
http_options = config.get('http_options', None)
|
4860
|
-
elif hasattr(config, 'http_options'):
|
4876
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4861
4877
|
http_options = config.http_options
|
4862
4878
|
|
4863
4879
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -4918,7 +4934,7 @@ class Models(_api_module.BaseModule):
|
|
4918
4934
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
4919
4935
|
if isinstance(config, dict):
|
4920
4936
|
http_options = config.get('http_options', None)
|
4921
|
-
elif hasattr(config, 'http_options'):
|
4937
|
+
elif hasattr(config, 'http_options') and config is not None:
|
4922
4938
|
http_options = config.http_options
|
4923
4939
|
|
4924
4940
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5006,7 +5022,7 @@ class Models(_api_module.BaseModule):
|
|
5006
5022
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5007
5023
|
if isinstance(config, dict):
|
5008
5024
|
http_options = config.get('http_options', None)
|
5009
|
-
elif hasattr(config, 'http_options'):
|
5025
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5010
5026
|
http_options = config.http_options
|
5011
5027
|
|
5012
5028
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5089,7 +5105,7 @@ class Models(_api_module.BaseModule):
|
|
5089
5105
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5090
5106
|
if isinstance(config, dict):
|
5091
5107
|
http_options = config.get('http_options', None)
|
5092
|
-
elif hasattr(config, 'http_options'):
|
5108
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5093
5109
|
http_options = config.http_options
|
5094
5110
|
|
5095
5111
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5122,6 +5138,7 @@ class Models(_api_module.BaseModule):
|
|
5122
5138
|
*,
|
5123
5139
|
model: str,
|
5124
5140
|
prompt: Optional[str] = None,
|
5141
|
+
image: Optional[types.ImageOrDict] = None,
|
5125
5142
|
config: Optional[types.GenerateVideosConfigOrDict] = None,
|
5126
5143
|
) -> types.GenerateVideosOperation:
|
5127
5144
|
"""Generates videos based on a text description and configuration.
|
@@ -5149,6 +5166,7 @@ class Models(_api_module.BaseModule):
|
|
5149
5166
|
parameter_model = types._GenerateVideosParameters(
|
5150
5167
|
model=model,
|
5151
5168
|
prompt=prompt,
|
5169
|
+
image=image,
|
5152
5170
|
config=config,
|
5153
5171
|
)
|
5154
5172
|
|
@@ -5181,7 +5199,7 @@ class Models(_api_module.BaseModule):
|
|
5181
5199
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5182
5200
|
if isinstance(config, dict):
|
5183
5201
|
http_options = config.get('http_options', None)
|
5184
|
-
elif hasattr(config, 'http_options'):
|
5202
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5185
5203
|
http_options = config.http_options
|
5186
5204
|
|
5187
5205
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5279,7 +5297,7 @@ class Models(_api_module.BaseModule):
|
|
5279
5297
|
f'AFC is enabled with max remote calls: {remaining_remote_calls_afc}.'
|
5280
5298
|
)
|
5281
5299
|
automatic_function_calling_history: list[types.Content] = []
|
5282
|
-
response =
|
5300
|
+
response = types.GenerateContentResponse()
|
5283
5301
|
i = 0
|
5284
5302
|
while remaining_remote_calls_afc > 0:
|
5285
5303
|
i += 1
|
@@ -5315,11 +5333,12 @@ class Models(_api_module.BaseModule):
|
|
5315
5333
|
contents = t.t_contents(self._api_client, contents)
|
5316
5334
|
if not automatic_function_calling_history:
|
5317
5335
|
automatic_function_calling_history.extend(contents)
|
5318
|
-
contents
|
5319
|
-
|
5336
|
+
if isinstance(contents, list):
|
5337
|
+
contents.append(func_call_content)
|
5338
|
+
contents.append(func_response_content)
|
5320
5339
|
automatic_function_calling_history.append(func_call_content)
|
5321
5340
|
automatic_function_calling_history.append(func_response_content)
|
5322
|
-
if _extra_utils.should_append_afc_history(config):
|
5341
|
+
if _extra_utils.should_append_afc_history(config) and response is not None:
|
5323
5342
|
response.automatic_function_calling_history = (
|
5324
5343
|
automatic_function_calling_history
|
5325
5344
|
)
|
@@ -5467,8 +5486,9 @@ class Models(_api_module.BaseModule):
|
|
5467
5486
|
contents = t.t_contents(self._api_client, contents)
|
5468
5487
|
if not automatic_function_calling_history:
|
5469
5488
|
automatic_function_calling_history.extend(contents)
|
5470
|
-
contents
|
5471
|
-
|
5489
|
+
if isinstance(contents, list):
|
5490
|
+
contents.append(func_call_content)
|
5491
|
+
contents.append(func_response_content)
|
5472
5492
|
automatic_function_calling_history.append(func_call_content)
|
5473
5493
|
automatic_function_calling_history.append(func_response_content)
|
5474
5494
|
|
@@ -5623,7 +5643,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
5623
5643
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5624
5644
|
if isinstance(config, dict):
|
5625
5645
|
http_options = config.get('http_options', None)
|
5626
|
-
elif hasattr(config, 'http_options'):
|
5646
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5627
5647
|
http_options = config.http_options
|
5628
5648
|
|
5629
5649
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5694,7 +5714,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
5694
5714
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5695
5715
|
if isinstance(config, dict):
|
5696
5716
|
http_options = config.get('http_options', None)
|
5697
|
-
elif hasattr(config, 'http_options'):
|
5717
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5698
5718
|
http_options = config.http_options
|
5699
5719
|
|
5700
5720
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5789,7 +5809,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
5789
5809
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5790
5810
|
if isinstance(config, dict):
|
5791
5811
|
http_options = config.get('http_options', None)
|
5792
|
-
elif hasattr(config, 'http_options'):
|
5812
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5793
5813
|
http_options = config.http_options
|
5794
5814
|
|
5795
5815
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5879,7 +5899,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
5879
5899
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5880
5900
|
if isinstance(config, dict):
|
5881
5901
|
http_options = config.get('http_options', None)
|
5882
|
-
elif hasattr(config, 'http_options'):
|
5902
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5883
5903
|
http_options = config.http_options
|
5884
5904
|
|
5885
5905
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -5983,7 +6003,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
5983
6003
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
5984
6004
|
if isinstance(config, dict):
|
5985
6005
|
http_options = config.get('http_options', None)
|
5986
|
-
elif hasattr(config, 'http_options'):
|
6006
|
+
elif hasattr(config, 'http_options') and config is not None:
|
5987
6007
|
http_options = config.http_options
|
5988
6008
|
|
5989
6009
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6054,7 +6074,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6054
6074
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6055
6075
|
if isinstance(config, dict):
|
6056
6076
|
http_options = config.get('http_options', None)
|
6057
|
-
elif hasattr(config, 'http_options'):
|
6077
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6058
6078
|
http_options = config.http_options
|
6059
6079
|
|
6060
6080
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6116,7 +6136,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6116
6136
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6117
6137
|
if isinstance(config, dict):
|
6118
6138
|
http_options = config.get('http_options', None)
|
6119
|
-
elif hasattr(config, 'http_options'):
|
6139
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6120
6140
|
http_options = config.http_options
|
6121
6141
|
|
6122
6142
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6173,7 +6193,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6173
6193
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6174
6194
|
if isinstance(config, dict):
|
6175
6195
|
http_options = config.get('http_options', None)
|
6176
|
-
elif hasattr(config, 'http_options'):
|
6196
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6177
6197
|
http_options = config.http_options
|
6178
6198
|
|
6179
6199
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6238,7 +6258,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6238
6258
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6239
6259
|
if isinstance(config, dict):
|
6240
6260
|
http_options = config.get('http_options', None)
|
6241
|
-
elif hasattr(config, 'http_options'):
|
6261
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6242
6262
|
http_options = config.http_options
|
6243
6263
|
|
6244
6264
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6299,7 +6319,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6299
6319
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6300
6320
|
if isinstance(config, dict):
|
6301
6321
|
http_options = config.get('http_options', None)
|
6302
|
-
elif hasattr(config, 'http_options'):
|
6322
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6303
6323
|
http_options = config.http_options
|
6304
6324
|
|
6305
6325
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6387,7 +6407,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6387
6407
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6388
6408
|
if isinstance(config, dict):
|
6389
6409
|
http_options = config.get('http_options', None)
|
6390
|
-
elif hasattr(config, 'http_options'):
|
6410
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6391
6411
|
http_options = config.http_options
|
6392
6412
|
|
6393
6413
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6470,7 +6490,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6470
6490
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6471
6491
|
if isinstance(config, dict):
|
6472
6492
|
http_options = config.get('http_options', None)
|
6473
|
-
elif hasattr(config, 'http_options'):
|
6493
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6474
6494
|
http_options = config.http_options
|
6475
6495
|
|
6476
6496
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6503,6 +6523,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6503
6523
|
*,
|
6504
6524
|
model: str,
|
6505
6525
|
prompt: Optional[str] = None,
|
6526
|
+
image: Optional[types.ImageOrDict] = None,
|
6506
6527
|
config: Optional[types.GenerateVideosConfigOrDict] = None,
|
6507
6528
|
) -> types.GenerateVideosOperation:
|
6508
6529
|
"""Generates videos based on a text description and configuration.
|
@@ -6530,6 +6551,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6530
6551
|
parameter_model = types._GenerateVideosParameters(
|
6531
6552
|
model=model,
|
6532
6553
|
prompt=prompt,
|
6554
|
+
image=image,
|
6533
6555
|
config=config,
|
6534
6556
|
)
|
6535
6557
|
|
@@ -6562,7 +6584,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6562
6584
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
6563
6585
|
if isinstance(config, dict):
|
6564
6586
|
http_options = config.get('http_options', None)
|
6565
|
-
elif hasattr(config, 'http_options'):
|
6587
|
+
elif hasattr(config, 'http_options') and config is not None:
|
6566
6588
|
http_options = config.http_options
|
6567
6589
|
|
6568
6590
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -6632,7 +6654,7 @@ class AsyncModels(_api_module.BaseModule):
|
|
6632
6654
|
f'AFC is enabled with max remote calls: {remaining_remote_calls_afc}.'
|
6633
6655
|
)
|
6634
6656
|
automatic_function_calling_history: list[types.Content] = []
|
6635
|
-
response =
|
6657
|
+
response = types.GenerateContentResponse()
|
6636
6658
|
while remaining_remote_calls_afc > 0:
|
6637
6659
|
response = await self._generate_content(
|
6638
6660
|
model=model, contents=contents, config=config
|
@@ -6665,12 +6687,13 @@ class AsyncModels(_api_module.BaseModule):
|
|
6665
6687
|
contents = t.t_contents(self._api_client, contents)
|
6666
6688
|
if not automatic_function_calling_history:
|
6667
6689
|
automatic_function_calling_history.extend(contents)
|
6668
|
-
contents
|
6669
|
-
|
6690
|
+
if isinstance(contents, list):
|
6691
|
+
contents.append(func_call_content)
|
6692
|
+
contents.append(func_response_content)
|
6670
6693
|
automatic_function_calling_history.append(func_call_content)
|
6671
6694
|
automatic_function_calling_history.append(func_response_content)
|
6672
6695
|
|
6673
|
-
if _extra_utils.should_append_afc_history(config):
|
6696
|
+
if _extra_utils.should_append_afc_history(config) and response is not None:
|
6674
6697
|
response.automatic_function_calling_history = (
|
6675
6698
|
automatic_function_calling_history
|
6676
6699
|
)
|
@@ -6827,8 +6850,9 @@ class AsyncModels(_api_module.BaseModule):
|
|
6827
6850
|
contents = t.t_contents(self._api_client, contents)
|
6828
6851
|
if not automatic_function_calling_history:
|
6829
6852
|
automatic_function_calling_history.extend(contents)
|
6830
|
-
contents
|
6831
|
-
|
6853
|
+
if isinstance(contents, list):
|
6854
|
+
contents.append(func_call_content)
|
6855
|
+
contents.append(func_response_content)
|
6832
6856
|
automatic_function_calling_history.append(func_call_content)
|
6833
6857
|
automatic_function_calling_history.append(func_response_content)
|
6834
6858
|
|
google/genai/operations.py
CHANGED
@@ -113,14 +113,14 @@ def _Video_from_mldev(
|
|
113
113
|
parent_object: Optional[dict] = None,
|
114
114
|
) -> dict:
|
115
115
|
to_object: dict[str, Any] = {}
|
116
|
-
if getv(from_object, ['uri']) is not None:
|
117
|
-
setv(to_object, ['uri'], getv(from_object, ['uri']))
|
116
|
+
if getv(from_object, ['video', 'uri']) is not None:
|
117
|
+
setv(to_object, ['uri'], getv(from_object, ['video', 'uri']))
|
118
118
|
|
119
|
-
if getv(from_object, ['encodedVideo']) is not None:
|
119
|
+
if getv(from_object, ['video', 'encodedVideo']) is not None:
|
120
120
|
setv(
|
121
121
|
to_object,
|
122
122
|
['video_bytes'],
|
123
|
-
t.t_bytes(api_client, getv(from_object, ['encodedVideo'])),
|
123
|
+
t.t_bytes(api_client, getv(from_object, ['video', 'encodedVideo'])),
|
124
124
|
)
|
125
125
|
|
126
126
|
if getv(from_object, ['encoding']) is not None:
|
@@ -189,13 +189,13 @@ def _GenerateVideosResponse_from_mldev(
|
|
189
189
|
parent_object: Optional[dict] = None,
|
190
190
|
) -> dict:
|
191
191
|
to_object: dict[str, Any] = {}
|
192
|
-
if getv(from_object, ['
|
192
|
+
if getv(from_object, ['generatedSamples']) is not None:
|
193
193
|
setv(
|
194
194
|
to_object,
|
195
195
|
['generated_videos'],
|
196
196
|
[
|
197
197
|
_GeneratedVideo_from_mldev(api_client, item, to_object)
|
198
|
-
for item in getv(from_object, ['
|
198
|
+
for item in getv(from_object, ['generatedSamples'])
|
199
199
|
],
|
200
200
|
)
|
201
201
|
|
@@ -359,7 +359,7 @@ class Operations(_api_module.BaseModule):
|
|
359
359
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
360
360
|
if isinstance(config, dict):
|
361
361
|
http_options = config.get('http_options', None)
|
362
|
-
elif hasattr(config, 'http_options'):
|
362
|
+
elif hasattr(config, 'http_options') and config is not None:
|
363
363
|
http_options = config.http_options
|
364
364
|
|
365
365
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -421,7 +421,7 @@ class Operations(_api_module.BaseModule):
|
|
421
421
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
422
422
|
if isinstance(config, dict):
|
423
423
|
http_options = config.get('http_options', None)
|
424
|
-
elif hasattr(config, 'http_options'):
|
424
|
+
elif hasattr(config, 'http_options') and config is not None:
|
425
425
|
http_options = config.http_options
|
426
426
|
|
427
427
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -519,7 +519,7 @@ class AsyncOperations(_api_module.BaseModule):
|
|
519
519
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
520
520
|
if isinstance(config, dict):
|
521
521
|
http_options = config.get('http_options', None)
|
522
|
-
elif hasattr(config, 'http_options'):
|
522
|
+
elif hasattr(config, 'http_options') and config is not None:
|
523
523
|
http_options = config.http_options
|
524
524
|
|
525
525
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -581,7 +581,7 @@ class AsyncOperations(_api_module.BaseModule):
|
|
581
581
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
582
582
|
if isinstance(config, dict):
|
583
583
|
http_options = config.get('http_options', None)
|
584
|
-
elif hasattr(config, 'http_options'):
|
584
|
+
elif hasattr(config, 'http_options') and config is not None:
|
585
585
|
http_options = config.http_options
|
586
586
|
|
587
587
|
request_dict = _common.convert_to_dict(request_dict)
|
google/genai/pagers.py
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
# pylint: disable=protected-access
|
19
19
|
|
20
20
|
import copy
|
21
|
-
from typing import Any, Awaitable, Callable, Generic, Iterator, Literal, TypeVar
|
21
|
+
from typing import Any, AsyncIterator,Awaitable, Callable, Generic, Iterator, Literal, TypeVar
|
22
22
|
|
23
23
|
T = TypeVar('T')
|
24
24
|
|
@@ -30,7 +30,7 @@ PagedItem = Literal[
|
|
30
30
|
class _BasePager(Generic[T]):
|
31
31
|
"""Base pager class for iterating through paginated results."""
|
32
32
|
|
33
|
-
def
|
33
|
+
def _init_page(
|
34
34
|
self,
|
35
35
|
name: PagedItem,
|
36
36
|
request: Callable[..., Any],
|
@@ -54,6 +54,15 @@ class _BasePager(Generic[T]):
|
|
54
54
|
|
55
55
|
self._page_size = request_config.get('page_size', len(self._page))
|
56
56
|
|
57
|
+
def __init__(
|
58
|
+
self,
|
59
|
+
name: PagedItem,
|
60
|
+
request: Callable[..., Any],
|
61
|
+
response: Any,
|
62
|
+
config: Any,
|
63
|
+
):
|
64
|
+
self._init_page(name, request, response, config)
|
65
|
+
|
57
66
|
@property
|
58
67
|
def page(self) -> list[T]:
|
59
68
|
"""Returns the current page, which is a list of items.
|
@@ -72,7 +81,7 @@ class _BasePager(Generic[T]):
|
|
72
81
|
return self._page
|
73
82
|
|
74
83
|
@property
|
75
|
-
def name(self) ->
|
84
|
+
def name(self) -> PagedItem:
|
76
85
|
"""Returns the type of paged item (for example, ``batch_jobs``).
|
77
86
|
|
78
87
|
Usage:
|
@@ -139,7 +148,7 @@ class _BasePager(Generic[T]):
|
|
139
148
|
Args:
|
140
149
|
response: The response object from the API request.
|
141
150
|
"""
|
142
|
-
self.
|
151
|
+
self._init_page(self.name, self._request, response, self.config)
|
143
152
|
|
144
153
|
|
145
154
|
class Pager(_BasePager[T]):
|
@@ -197,7 +206,7 @@ class AsyncPager(_BasePager[T]):
|
|
197
206
|
):
|
198
207
|
super().__init__(name, request, response, config)
|
199
208
|
|
200
|
-
def __aiter__(self) -> T:
|
209
|
+
def __aiter__(self) -> AsyncIterator[T]:
|
201
210
|
"""Returns an async iterator over the items."""
|
202
211
|
self._idx = 0
|
203
212
|
return self
|
google/genai/tunings.py
CHANGED
@@ -757,7 +757,7 @@ class Tunings(_api_module.BaseModule):
|
|
757
757
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
758
758
|
if isinstance(config, dict):
|
759
759
|
http_options = config.get('http_options', None)
|
760
|
-
elif hasattr(config, 'http_options'):
|
760
|
+
elif hasattr(config, 'http_options') and config is not None:
|
761
761
|
http_options = config.http_options
|
762
762
|
|
763
763
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -823,7 +823,7 @@ class Tunings(_api_module.BaseModule):
|
|
823
823
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
824
824
|
if isinstance(config, dict):
|
825
825
|
http_options = config.get('http_options', None)
|
826
|
-
elif hasattr(config, 'http_options'):
|
826
|
+
elif hasattr(config, 'http_options') and config is not None:
|
827
827
|
http_options = config.http_options
|
828
828
|
|
829
829
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -894,7 +894,7 @@ class Tunings(_api_module.BaseModule):
|
|
894
894
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
895
895
|
if isinstance(config, dict):
|
896
896
|
http_options = config.get('http_options', None)
|
897
|
-
elif hasattr(config, 'http_options'):
|
897
|
+
elif hasattr(config, 'http_options') and config is not None:
|
898
898
|
http_options = config.http_options
|
899
899
|
|
900
900
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -961,7 +961,7 @@ class Tunings(_api_module.BaseModule):
|
|
961
961
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
962
962
|
if isinstance(config, dict):
|
963
963
|
http_options = config.get('http_options', None)
|
964
|
-
elif hasattr(config, 'http_options'):
|
964
|
+
elif hasattr(config, 'http_options') and config is not None:
|
965
965
|
http_options = config.http_options
|
966
966
|
|
967
967
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -1096,7 +1096,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1096
1096
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
1097
1097
|
if isinstance(config, dict):
|
1098
1098
|
http_options = config.get('http_options', None)
|
1099
|
-
elif hasattr(config, 'http_options'):
|
1099
|
+
elif hasattr(config, 'http_options') and config is not None:
|
1100
1100
|
http_options = config.http_options
|
1101
1101
|
|
1102
1102
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -1162,7 +1162,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1162
1162
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
1163
1163
|
if isinstance(config, dict):
|
1164
1164
|
http_options = config.get('http_options', None)
|
1165
|
-
elif hasattr(config, 'http_options'):
|
1165
|
+
elif hasattr(config, 'http_options') and config is not None:
|
1166
1166
|
http_options = config.http_options
|
1167
1167
|
|
1168
1168
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -1233,7 +1233,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1233
1233
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
1234
1234
|
if isinstance(config, dict):
|
1235
1235
|
http_options = config.get('http_options', None)
|
1236
|
-
elif hasattr(config, 'http_options'):
|
1236
|
+
elif hasattr(config, 'http_options') and config is not None:
|
1237
1237
|
http_options = config.http_options
|
1238
1238
|
|
1239
1239
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -1300,7 +1300,7 @@ class AsyncTunings(_api_module.BaseModule):
|
|
1300
1300
|
http_options: Optional[types.HttpOptionsOrDict] = None
|
1301
1301
|
if isinstance(config, dict):
|
1302
1302
|
http_options = config.get('http_options', None)
|
1303
|
-
elif hasattr(config, 'http_options'):
|
1303
|
+
elif hasattr(config, 'http_options') and config is not None:
|
1304
1304
|
http_options = config.http_options
|
1305
1305
|
|
1306
1306
|
request_dict = _common.convert_to_dict(request_dict)
|
@@ -1404,7 +1404,7 @@ class _IpythonUtils:
|
|
1404
1404
|
return bool(_IpythonUtils._get_ipython_shell_name())
|
1405
1405
|
|
1406
1406
|
@staticmethod
|
1407
|
-
def _get_styles() ->
|
1407
|
+
def _get_styles() -> str:
|
1408
1408
|
"""Returns the HTML style markup to support custom buttons."""
|
1409
1409
|
return """
|
1410
1410
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|