google-genai 1.26.0__py3-none-any.whl → 1.28.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/tunings.py CHANGED
@@ -423,6 +423,11 @@ def _TuningJob_from_mldev(
423
423
  parent_object: Optional[dict[str, Any]] = None,
424
424
  ) -> dict[str, Any]:
425
425
  to_object: dict[str, Any] = {}
426
+ if getv(from_object, ['sdkHttpResponse']) is not None:
427
+ setv(
428
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
429
+ )
430
+
426
431
  if getv(from_object, ['name']) is not None:
427
432
  setv(to_object, ['name'], getv(from_object, ['name']))
428
433
 
@@ -506,6 +511,11 @@ def _ListTuningJobsResponse_from_mldev(
506
511
  parent_object: Optional[dict[str, Any]] = None,
507
512
  ) -> dict[str, Any]:
508
513
  to_object: dict[str, Any] = {}
514
+ if getv(from_object, ['sdkHttpResponse']) is not None:
515
+ setv(
516
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
517
+ )
518
+
509
519
  if getv(from_object, ['nextPageToken']) is not None:
510
520
  setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
511
521
 
@@ -527,6 +537,11 @@ def _TuningOperation_from_mldev(
527
537
  parent_object: Optional[dict[str, Any]] = None,
528
538
  ) -> dict[str, Any]:
529
539
  to_object: dict[str, Any] = {}
540
+ if getv(from_object, ['sdkHttpResponse']) is not None:
541
+ setv(
542
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
543
+ )
544
+
530
545
  if getv(from_object, ['name']) is not None:
531
546
  setv(to_object, ['name'], getv(from_object, ['name']))
532
547
 
@@ -591,6 +606,11 @@ def _TuningJob_from_vertex(
591
606
  parent_object: Optional[dict[str, Any]] = None,
592
607
  ) -> dict[str, Any]:
593
608
  to_object: dict[str, Any] = {}
609
+ if getv(from_object, ['sdkHttpResponse']) is not None:
610
+ setv(
611
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
612
+ )
613
+
594
614
  if getv(from_object, ['name']) is not None:
595
615
  setv(to_object, ['name'], getv(from_object, ['name']))
596
616
 
@@ -691,6 +711,11 @@ def _ListTuningJobsResponse_from_vertex(
691
711
  parent_object: Optional[dict[str, Any]] = None,
692
712
  ) -> dict[str, Any]:
693
713
  to_object: dict[str, Any] = {}
714
+ if getv(from_object, ['sdkHttpResponse']) is not None:
715
+ setv(
716
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
717
+ )
718
+
694
719
  if getv(from_object, ['nextPageToken']) is not None:
695
720
  setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
696
721
 
@@ -774,7 +799,9 @@ class Tunings(_api_module.BaseModule):
774
799
  return_value = types.TuningJob._from_response(
775
800
  response=response_dict, kwargs=parameter_model.model_dump()
776
801
  )
777
-
802
+ return_value.sdk_http_response = types.HttpResponse(
803
+ headers=response.headers
804
+ )
778
805
  self._api_client._verify_response(return_value)
779
806
  return return_value
780
807
 
@@ -839,7 +866,9 @@ class Tunings(_api_module.BaseModule):
839
866
  return_value = types.ListTuningJobsResponse._from_response(
840
867
  response=response_dict, kwargs=parameter_model.model_dump()
841
868
  )
842
-
869
+ return_value.sdk_http_response = types.HttpResponse(
870
+ headers=response.headers
871
+ )
843
872
  self._api_client._verify_response(return_value)
844
873
  return return_value
845
874
 
@@ -906,7 +935,9 @@ class Tunings(_api_module.BaseModule):
906
935
  return_value = types.TuningJob._from_response(
907
936
  response=response_dict, kwargs=parameter_model.model_dump()
908
937
  )
909
-
938
+ return_value.sdk_http_response = types.HttpResponse(
939
+ headers=response.headers
940
+ )
910
941
  self._api_client._verify_response(return_value)
911
942
  return return_value
912
943
 
@@ -975,7 +1006,9 @@ class Tunings(_api_module.BaseModule):
975
1006
  return_value = types.TuningOperation._from_response(
976
1007
  response=response_dict, kwargs=parameter_model.model_dump()
977
1008
  )
978
-
1009
+ return_value.sdk_http_response = types.HttpResponse(
1010
+ headers=response.headers
1011
+ )
979
1012
  self._api_client._verify_response(return_value)
980
1013
  return return_value
981
1014
 
@@ -1116,7 +1149,9 @@ class AsyncTunings(_api_module.BaseModule):
1116
1149
  return_value = types.TuningJob._from_response(
1117
1150
  response=response_dict, kwargs=parameter_model.model_dump()
1118
1151
  )
1119
-
1152
+ return_value.sdk_http_response = types.HttpResponse(
1153
+ headers=response.headers
1154
+ )
1120
1155
  self._api_client._verify_response(return_value)
1121
1156
  return return_value
1122
1157
 
@@ -1183,7 +1218,9 @@ class AsyncTunings(_api_module.BaseModule):
1183
1218
  return_value = types.ListTuningJobsResponse._from_response(
1184
1219
  response=response_dict, kwargs=parameter_model.model_dump()
1185
1220
  )
1186
-
1221
+ return_value.sdk_http_response = types.HttpResponse(
1222
+ headers=response.headers
1223
+ )
1187
1224
  self._api_client._verify_response(return_value)
1188
1225
  return return_value
1189
1226
 
@@ -1250,7 +1287,9 @@ class AsyncTunings(_api_module.BaseModule):
1250
1287
  return_value = types.TuningJob._from_response(
1251
1288
  response=response_dict, kwargs=parameter_model.model_dump()
1252
1289
  )
1253
-
1290
+ return_value.sdk_http_response = types.HttpResponse(
1291
+ headers=response.headers
1292
+ )
1254
1293
  self._api_client._verify_response(return_value)
1255
1294
  return return_value
1256
1295
 
@@ -1319,7 +1358,9 @@ class AsyncTunings(_api_module.BaseModule):
1319
1358
  return_value = types.TuningOperation._from_response(
1320
1359
  response=response_dict, kwargs=parameter_model.model_dump()
1321
1360
  )
1322
-
1361
+ return_value.sdk_http_response = types.HttpResponse(
1362
+ headers=response.headers
1363
+ )
1323
1364
  self._api_client._verify_response(return_value)
1324
1365
  return return_value
1325
1366
 
google/genai/types.py CHANGED
@@ -1270,7 +1270,10 @@ class HttpOptions(_common.BaseModel):
1270
1270
  )
1271
1271
  extra_body: Optional[dict[str, Any]] = Field(
1272
1272
  default=None,
1273
- description="""Extra parameters to add to the request body.""",
1273
+ description="""Extra parameters to add to the request body.
1274
+ The structure must match the backend API's request structure.
1275
+ - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
1276
+ - GeminiAPI backend API docs: https://ai.google.dev/api/rest""",
1274
1277
  )
1275
1278
  retry_options: Optional[HttpRetryOptions] = Field(
1276
1279
  default=None, description="""HTTP retry options for the request."""
@@ -1299,7 +1302,10 @@ class HttpOptionsDict(TypedDict, total=False):
1299
1302
  """Args passed to the async HTTP client."""
1300
1303
 
1301
1304
  extra_body: Optional[dict[str, Any]]
1302
- """Extra parameters to add to the request body."""
1305
+ """Extra parameters to add to the request body.
1306
+ The structure must match the backend API's request structure.
1307
+ - VertexAI backend API docs: https://cloud.google.com/vertex-ai/docs/reference/rest
1308
+ - GeminiAPI backend API docs: https://ai.google.dev/api/rest"""
1303
1309
 
1304
1310
  retry_options: Optional[HttpRetryOptionsDict]
1305
1311
  """HTTP retry options for the request."""
@@ -5600,6 +5606,9 @@ EmbedContentMetadataOrDict = Union[
5600
5606
  class EmbedContentResponse(_common.BaseModel):
5601
5607
  """Response for the embed_content method."""
5602
5608
 
5609
+ sdk_http_response: Optional[HttpResponse] = Field(
5610
+ default=None, description="""Used to retain the full HTTP response."""
5611
+ )
5603
5612
  embeddings: Optional[list[ContentEmbedding]] = Field(
5604
5613
  default=None,
5605
5614
  description="""The embeddings for each request, in the same order as provided in
@@ -5616,6 +5625,9 @@ class EmbedContentResponse(_common.BaseModel):
5616
5625
  class EmbedContentResponseDict(TypedDict, total=False):
5617
5626
  """Response for the embed_content method."""
5618
5627
 
5628
+ sdk_http_response: Optional[HttpResponseDict]
5629
+ """Used to retain the full HTTP response."""
5630
+
5619
5631
  embeddings: Optional[list[ContentEmbeddingDict]]
5620
5632
  """The embeddings for each request, in the same order as provided in
5621
5633
  the batch request.
@@ -5714,6 +5726,12 @@ class GenerateImagesConfig(_common.BaseModel):
5714
5726
  description="""Whether to add a watermark to the generated images.
5715
5727
  """,
5716
5728
  )
5729
+ image_size: Optional[str] = Field(
5730
+ default=None,
5731
+ description="""The size of the largest dimension of the generated image.
5732
+ Supported sizes are 1K and 2K (not supported for Imagen 3 models).
5733
+ """,
5734
+ )
5717
5735
  enhance_prompt: Optional[bool] = Field(
5718
5736
  default=None,
5719
5737
  description="""Whether to use the prompt rewriting logic.
@@ -5790,6 +5808,11 @@ class GenerateImagesConfigDict(TypedDict, total=False):
5790
5808
  """Whether to add a watermark to the generated images.
5791
5809
  """
5792
5810
 
5811
+ image_size: Optional[str]
5812
+ """The size of the largest dimension of the generated image.
5813
+ Supported sizes are 1K and 2K (not supported for Imagen 3 models).
5814
+ """
5815
+
5793
5816
  enhance_prompt: Optional[bool]
5794
5817
  """Whether to use the prompt rewriting logic.
5795
5818
  """
@@ -6094,6 +6117,9 @@ GeneratedImageOrDict = Union[GeneratedImage, GeneratedImageDict]
6094
6117
  class GenerateImagesResponse(_common.BaseModel):
6095
6118
  """The output images response."""
6096
6119
 
6120
+ sdk_http_response: Optional[HttpResponse] = Field(
6121
+ default=None, description="""Used to retain the full HTTP response."""
6122
+ )
6097
6123
  generated_images: Optional[list[GeneratedImage]] = Field(
6098
6124
  default=None,
6099
6125
  description="""List of generated images.
@@ -6106,10 +6132,24 @@ class GenerateImagesResponse(_common.BaseModel):
6106
6132
  """,
6107
6133
  )
6108
6134
 
6135
+ @property
6136
+ def images(self) -> list[Optional[Image]]:
6137
+ """Returns the list of all generated images.
6138
+
6139
+ A convenience method for accessing the images. Some attributes of the
6140
+ generated image are only available through the ``GeneratedImage`` object.
6141
+ """
6142
+ if not self.generated_images:
6143
+ return []
6144
+ return [generated_image.image for generated_image in self.generated_images]
6145
+
6109
6146
 
6110
6147
  class GenerateImagesResponseDict(TypedDict, total=False):
6111
6148
  """The output images response."""
6112
6149
 
6150
+ sdk_http_response: Optional[HttpResponseDict]
6151
+ """Used to retain the full HTTP response."""
6152
+
6113
6153
  generated_images: Optional[list[GeneratedImageDict]]
6114
6154
  """List of generated images.
6115
6155
  """
@@ -6520,6 +6560,9 @@ _EditImageParametersOrDict = Union[
6520
6560
  class EditImageResponse(_common.BaseModel):
6521
6561
  """Response for the request to edit an image."""
6522
6562
 
6563
+ sdk_http_response: Optional[HttpResponse] = Field(
6564
+ default=None, description="""Used to retain the full HTTP response."""
6565
+ )
6523
6566
  generated_images: Optional[list[GeneratedImage]] = Field(
6524
6567
  default=None, description="""Generated images."""
6525
6568
  )
@@ -6528,6 +6571,9 @@ class EditImageResponse(_common.BaseModel):
6528
6571
  class EditImageResponseDict(TypedDict, total=False):
6529
6572
  """Response for the request to edit an image."""
6530
6573
 
6574
+ sdk_http_response: Optional[HttpResponseDict]
6575
+ """Used to retain the full HTTP response."""
6576
+
6531
6577
  generated_images: Optional[list[GeneratedImageDict]]
6532
6578
  """Generated images."""
6533
6579
 
@@ -6661,6 +6707,9 @@ _UpscaleImageAPIParametersOrDict = Union[
6661
6707
 
6662
6708
  class UpscaleImageResponse(_common.BaseModel):
6663
6709
 
6710
+ sdk_http_response: Optional[HttpResponse] = Field(
6711
+ default=None, description="""Used to retain the full HTTP response."""
6712
+ )
6664
6713
  generated_images: Optional[list[GeneratedImage]] = Field(
6665
6714
  default=None, description="""Generated images."""
6666
6715
  )
@@ -6668,6 +6717,9 @@ class UpscaleImageResponse(_common.BaseModel):
6668
6717
 
6669
6718
  class UpscaleImageResponseDict(TypedDict, total=False):
6670
6719
 
6720
+ sdk_http_response: Optional[HttpResponseDict]
6721
+ """Used to retain the full HTTP response."""
6722
+
6671
6723
  generated_images: Optional[list[GeneratedImageDict]]
6672
6724
  """Generated images."""
6673
6725
 
@@ -6967,12 +7019,18 @@ _ListModelsParametersOrDict = Union[
6967
7019
 
6968
7020
  class ListModelsResponse(_common.BaseModel):
6969
7021
 
7022
+ sdk_http_response: Optional[HttpResponse] = Field(
7023
+ default=None, description="""Used to retain the full HTTP response."""
7024
+ )
6970
7025
  next_page_token: Optional[str] = Field(default=None, description="""""")
6971
7026
  models: Optional[list[Model]] = Field(default=None, description="""""")
6972
7027
 
6973
7028
 
6974
7029
  class ListModelsResponseDict(TypedDict, total=False):
6975
7030
 
7031
+ sdk_http_response: Optional[HttpResponseDict]
7032
+ """Used to retain the full HTTP response."""
7033
+
6976
7034
  next_page_token: Optional[str]
6977
7035
  """"""
6978
7036
 
@@ -7360,6 +7418,9 @@ _CountTokensParametersOrDict = Union[
7360
7418
  class CountTokensResponse(_common.BaseModel):
7361
7419
  """Response for counting tokens."""
7362
7420
 
7421
+ sdk_http_response: Optional[HttpResponse] = Field(
7422
+ default=None, description="""Used to retain the full HTTP response."""
7423
+ )
7363
7424
  total_tokens: Optional[int] = Field(
7364
7425
  default=None, description="""Total number of tokens."""
7365
7426
  )
@@ -7372,6 +7433,9 @@ class CountTokensResponse(_common.BaseModel):
7372
7433
  class CountTokensResponseDict(TypedDict, total=False):
7373
7434
  """Response for counting tokens."""
7374
7435
 
7436
+ sdk_http_response: Optional[HttpResponseDict]
7437
+ """Used to retain the full HTTP response."""
7438
+
7375
7439
  total_tokens: Optional[int]
7376
7440
  """Total number of tokens."""
7377
7441
 
@@ -7472,6 +7536,9 @@ TokensInfoOrDict = Union[TokensInfo, TokensInfoDict]
7472
7536
  class ComputeTokensResponse(_common.BaseModel):
7473
7537
  """Response for computing tokens."""
7474
7538
 
7539
+ sdk_http_response: Optional[HttpResponse] = Field(
7540
+ default=None, description="""Used to retain the full HTTP response."""
7541
+ )
7475
7542
  tokens_info: Optional[list[TokensInfo]] = Field(
7476
7543
  default=None,
7477
7544
  description="""Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.""",
@@ -7481,6 +7548,9 @@ class ComputeTokensResponse(_common.BaseModel):
7481
7548
  class ComputeTokensResponseDict(TypedDict, total=False):
7482
7549
  """Response for computing tokens."""
7483
7550
 
7551
+ sdk_http_response: Optional[HttpResponseDict]
7552
+ """Used to retain the full HTTP response."""
7553
+
7484
7554
  tokens_info: Optional[list[TokensInfoDict]]
7485
7555
  """Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances."""
7486
7556
 
@@ -8752,6 +8822,9 @@ DistillationSpecOrDict = Union[DistillationSpec, DistillationSpecDict]
8752
8822
  class TuningJob(_common.BaseModel):
8753
8823
  """A tuning job."""
8754
8824
 
8825
+ sdk_http_response: Optional[HttpResponse] = Field(
8826
+ default=None, description="""Used to retain the full HTTP response."""
8827
+ )
8755
8828
  name: Optional[str] = Field(
8756
8829
  default=None,
8757
8830
  description="""Output only. Identifier. Resource name of a TuningJob. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`""",
@@ -8851,6 +8924,9 @@ class TuningJob(_common.BaseModel):
8851
8924
  class TuningJobDict(TypedDict, total=False):
8852
8925
  """A tuning job."""
8853
8926
 
8927
+ sdk_http_response: Optional[HttpResponseDict]
8928
+ """Used to retain the full HTTP response."""
8929
+
8854
8930
  name: Optional[str]
8855
8931
  """Output only. Identifier. Resource name of a TuningJob. Format: `projects/{project}/locations/{location}/tuningJobs/{tuning_job}`"""
8856
8932
 
@@ -8976,6 +9052,9 @@ _ListTuningJobsParametersOrDict = Union[
8976
9052
  class ListTuningJobsResponse(_common.BaseModel):
8977
9053
  """Response for the list tuning jobs method."""
8978
9054
 
9055
+ sdk_http_response: Optional[HttpResponse] = Field(
9056
+ default=None, description="""Used to retain the full HTTP response."""
9057
+ )
8979
9058
  next_page_token: Optional[str] = Field(
8980
9059
  default=None,
8981
9060
  description="""A token to retrieve the next page of results. Pass to ListTuningJobsRequest.page_token to obtain that page.""",
@@ -8988,6 +9067,9 @@ class ListTuningJobsResponse(_common.BaseModel):
8988
9067
  class ListTuningJobsResponseDict(TypedDict, total=False):
8989
9068
  """Response for the list tuning jobs method."""
8990
9069
 
9070
+ sdk_http_response: Optional[HttpResponseDict]
9071
+ """Used to retain the full HTTP response."""
9072
+
8991
9073
  next_page_token: Optional[str]
8992
9074
  """A token to retrieve the next page of results. Pass to ListTuningJobsRequest.page_token to obtain that page."""
8993
9075
 
@@ -9199,6 +9281,9 @@ _CreateTuningJobParametersOrDict = Union[
9199
9281
  class TuningOperation(_common.BaseModel):
9200
9282
  """A long-running operation."""
9201
9283
 
9284
+ sdk_http_response: Optional[HttpResponse] = Field(
9285
+ default=None, description="""Used to retain the full HTTP response."""
9286
+ )
9202
9287
  name: Optional[str] = Field(
9203
9288
  default=None,
9204
9289
  description="""The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.""",
@@ -9220,6 +9305,9 @@ class TuningOperation(_common.BaseModel):
9220
9305
  class TuningOperationDict(TypedDict, total=False):
9221
9306
  """A long-running operation."""
9222
9307
 
9308
+ sdk_http_response: Optional[HttpResponseDict]
9309
+ """Used to retain the full HTTP response."""
9310
+
9223
9311
  name: Optional[str]
9224
9312
  """The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`."""
9225
9313
 
@@ -9710,6 +9798,9 @@ _ListCachedContentsParametersOrDict = Union[
9710
9798
 
9711
9799
  class ListCachedContentsResponse(_common.BaseModel):
9712
9800
 
9801
+ sdk_http_response: Optional[HttpResponse] = Field(
9802
+ default=None, description="""Used to retain the full HTTP response."""
9803
+ )
9713
9804
  next_page_token: Optional[str] = Field(default=None, description="""""")
9714
9805
  cached_contents: Optional[list[CachedContent]] = Field(
9715
9806
  default=None,
@@ -9720,6 +9811,9 @@ class ListCachedContentsResponse(_common.BaseModel):
9720
9811
 
9721
9812
  class ListCachedContentsResponseDict(TypedDict, total=False):
9722
9813
 
9814
+ sdk_http_response: Optional[HttpResponseDict]
9815
+ """Used to retain the full HTTP response."""
9816
+
9723
9817
  next_page_token: Optional[str]
9724
9818
  """"""
9725
9819
 
@@ -9783,6 +9877,9 @@ _ListFilesParametersOrDict = Union[
9783
9877
  class ListFilesResponse(_common.BaseModel):
9784
9878
  """Response for the list files method."""
9785
9879
 
9880
+ sdk_http_response: Optional[HttpResponse] = Field(
9881
+ default=None, description="""Used to retain the full HTTP response."""
9882
+ )
9786
9883
  next_page_token: Optional[str] = Field(
9787
9884
  default=None, description="""A token to retrieve next page of results."""
9788
9885
  )
@@ -9794,6 +9891,9 @@ class ListFilesResponse(_common.BaseModel):
9794
9891
  class ListFilesResponseDict(TypedDict, total=False):
9795
9892
  """Response for the list files method."""
9796
9893
 
9894
+ sdk_http_response: Optional[HttpResponseDict]
9895
+ """Used to retain the full HTTP response."""
9896
+
9797
9897
  next_page_token: Optional[str]
9798
9898
  """A token to retrieve next page of results."""
9799
9899
 
@@ -10584,6 +10684,9 @@ _ListBatchJobsParametersOrDict = Union[
10584
10684
  class ListBatchJobsResponse(_common.BaseModel):
10585
10685
  """Config for batches.list return value."""
10586
10686
 
10687
+ sdk_http_response: Optional[HttpResponse] = Field(
10688
+ default=None, description="""Used to retain the full HTTP response."""
10689
+ )
10587
10690
  next_page_token: Optional[str] = Field(default=None, description="""""")
10588
10691
  batch_jobs: Optional[list[BatchJob]] = Field(default=None, description="""""")
10589
10692
 
@@ -10591,6 +10694,9 @@ class ListBatchJobsResponse(_common.BaseModel):
10591
10694
  class ListBatchJobsResponseDict(TypedDict, total=False):
10592
10695
  """Config for batches.list return value."""
10593
10696
 
10697
+ sdk_http_response: Optional[HttpResponseDict]
10698
+ """Used to retain the full HTTP response."""
10699
+
10594
10700
  next_page_token: Optional[str]
10595
10701
  """"""
10596
10702
 
google/genai/version.py CHANGED
@@ -13,4 +13,4 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
- __version__ = '1.26.0' # x-release-please-version
16
+ __version__ = '1.28.0' # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-genai
3
- Version: 1.26.0
3
+ Version: 1.28.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -1404,35 +1404,21 @@ print(response.text)
1404
1404
  ## Tunings
1405
1405
 
1406
1406
  `client.tunings` contains tuning job APIs and supports supervised fine
1407
- tuning through `tune`. See the 'Create a client' section above to initialize a
1408
- client.
1407
+ tuning through `tune`. Only supported in Vertex AI. See the 'Create a client'
1408
+ section above to initialize a client.
1409
1409
 
1410
1410
  ### Tune
1411
1411
 
1412
1412
  - Vertex AI supports tuning from GCS source or from a Vertex Multimodal Dataset
1413
- - Gemini Developer API supports tuning from inline examples
1414
1413
 
1415
1414
  ```python
1416
1415
  from google.genai import types
1417
1416
 
1418
- if client.vertexai:
1419
- model = 'gemini-2.0-flash-001'
1420
- training_dataset = types.TuningDataset(
1421
- # or gcs_uri=my_vertex_multimodal_dataset
1422
- gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
1423
- )
1424
- else:
1425
- model = 'models/gemini-2.0-flash-001'
1426
- # or gcs_uri=my_vertex_multimodal_dataset.resource_name
1427
- training_dataset = types.TuningDataset(
1428
- examples=[
1429
- types.TuningExample(
1430
- text_input=f'Input text {i}',
1431
- output=f'Output text {i}',
1432
- )
1433
- for i in range(5)
1434
- ],
1435
- )
1417
+ model = 'gemini-2.0-flash-001'
1418
+ training_dataset = types.TuningDataset(
1419
+ # or gcs_uri=my_vertex_multimodal_dataset
1420
+ gcs_uri='gs://cloud-samples-data/ai-platform/generative_ai/gemini-1_5/text/sft_train_data.jsonl',
1421
+ )
1436
1422
  ```
1437
1423
 
1438
1424
  ```python
@@ -1458,14 +1444,15 @@ print(tuning_job)
1458
1444
  ```python
1459
1445
  import time
1460
1446
 
1461
- running_states = set(
1447
+ completed_states = set(
1462
1448
  [
1463
- 'JOB_STATE_PENDING',
1464
- 'JOB_STATE_RUNNING',
1449
+ 'JOB_STATE_SUCCEEDED',
1450
+ 'JOB_STATE_FAILED',
1451
+ 'JOB_STATE_CANCELLED',
1465
1452
  ]
1466
1453
  )
1467
1454
 
1468
- while tuning_job.state in running_states:
1455
+ while tuning_job.state not in completed_states:
1469
1456
  print(tuning_job.state)
1470
1457
  tuning_job = client.tunings.get(name=tuning_job.name)
1471
1458
  time.sleep(10)
@@ -1576,16 +1563,63 @@ initialize a client.
1576
1563
 
1577
1564
  ### Create
1578
1565
 
1566
+ Vertex AI:
1567
+
1579
1568
  ```python
1580
1569
  # Specify model and source file only, destination and job display name will be auto-populated
1581
1570
  job = client.batches.create(
1582
1571
  model='gemini-2.0-flash-001',
1583
- src='bq://my-project.my-dataset.my-table',
1572
+ src='bq://my-project.my-dataset.my-table', # or "gs://path/to/input/data"
1584
1573
  )
1585
1574
 
1586
1575
  job
1587
1576
  ```
1588
1577
 
1578
+ Gemini Developer API:
1579
+
1580
+ ```python
1581
+ # Create a batch job with inlined requests
1582
+ batch_job = client.batches.create(
1583
+ model="gemini-2.0-flash",
1584
+ src=[{
1585
+ "contents": [{
1586
+ "parts": [{
1587
+ "text": "Hello!",
1588
+ }],
1589
+ "role": "user",
1590
+ }],
1591
+ "config:": {"response_modalities": ["text"]},
1592
+ }],
1593
+ )
1594
+
1595
+ job
1596
+ ```
1597
+
1598
+ In order to create a batch job with file name. Need to upload a jsonl file.
1599
+ For example myrequests.json:
1600
+
1601
+ ```
1602
+ {"key":"request_1", "request": {"contents": [{"parts": [{"text":
1603
+ "Explain how AI works in a few words"}]}], "generation_config": {"response_modalities": ["TEXT"]}}}
1604
+ {"key":"request_2", "request": {"contents": [{"parts": [{"text": "Explain how Crypto works in a few words"}]}]}}
1605
+ ```
1606
+ Then upload the file.
1607
+
1608
+ ```python
1609
+ # Upload the file
1610
+ file = client.files.upload(
1611
+ file='myrequest.json',
1612
+ config=types.UploadFileConfig(display_name='test_json')
1613
+ )
1614
+
1615
+ # Create a batch job with file name
1616
+ batch_job = client.batches.create(
1617
+ model="gemini-2.0-flash",
1618
+ src="files/file_name",
1619
+ )
1620
+ ```
1621
+
1622
+
1589
1623
  ```python
1590
1624
  # Get a job by name
1591
1625
  job = client.batches.get(name=job.name)
@@ -0,0 +1,35 @@
1
+ google/genai/__init__.py,sha256=SKz_9WQKA3R4OpJIDJlgssVfizLNDG2tuWtOD9pxrPE,729
2
+ google/genai/_adapters.py,sha256=Kok38miNYJff2n--l0zEK_hbq0y2rWOH7k75J7SMYbQ,1744
3
+ google/genai/_api_client.py,sha256=xleLwNglnLnRUVOZeKrdSyBjcZNIqjx2DX9djz904gk,57552
4
+ google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,902
5
+ google/genai/_automatic_function_calling_util.py,sha256=IJkPq2fT9pYxYm5Pbu5-e0nBoZKoZla7yT4_txWRKLs,10324
6
+ google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
7
+ google/genai/_common.py,sha256=SmBlz7AQZbKbT8KE5vsvK5Iz1OaRwHF6J51KDJBbjMo,19936
8
+ google/genai/_extra_utils.py,sha256=6mxUnbwKkrAJ9zR8JP4nCKuA0F1BFqAc2t5mzdAONxk,20603
9
+ google/genai/_live_converters.py,sha256=pIcEfsAxjV1zeWmxMNigDD7ETHiuutp-a2y0HQThdmU,100162
10
+ google/genai/_mcp_utils.py,sha256=HuWJ8FUjquv40Mf_QjcL5r5yXWrS-JjINsjlOSbbyAc,3870
11
+ google/genai/_replay_api_client.py,sha256=MRUxUWCC9PoTk-NxsK3rGB8yw8cCrUa8ZeTVU3oEguw,21729
12
+ google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
13
+ google/genai/_tokens_converters.py,sha256=ClWTsgcqn91zSw_qTqLPTNSP1-_G8s-NlBCD8-DQniw,23803
14
+ google/genai/_transformers.py,sha256=l7Rf4OvaDG_91jTrdCeHLBAm1J7_pyYwJW1oQM6Q9MI,37431
15
+ google/genai/batches.py,sha256=a8X0wi8D6d7WC8873C2oVtk_NBYbd8xeI77GSkww4Nc,81094
16
+ google/genai/caches.py,sha256=isEzVYJgQVOjHf0XkFl86HOXzoYFXB-PgEVqwuo1V4s,64673
17
+ google/genai/chats.py,sha256=0QdOUeWEYDQgAWBy1f7a3z3yY9S8tXSowUzNrzazzj4,16651
18
+ google/genai/client.py,sha256=wXnfZBSv9p-yKtX_gabUrfBXoYHuqHhzK_VgwRttMgY,10777
19
+ google/genai/errors.py,sha256=Cd3M1la1VgvRh0vLgOzL9x8fgXnw96A6tj-kfsS0wi8,5586
20
+ google/genai/files.py,sha256=Z9CP2RLAZlZDE3zWXVNA2LF3x7wJTXOhNzDoSyHmr9k,40154
21
+ google/genai/live.py,sha256=R7cAtesP5-Yp685H00EpgmzNsMNjERIR8L-m5e5kEMI,39469
22
+ google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
23
+ google/genai/models.py,sha256=ci7dOuCGm8ky4m-rD7-_Ur9hzGUKWBofmlKZIA_BwLQ,242026
24
+ google/genai/operations.py,sha256=3eudPaItN6_JJKMWNT9lLIJLUGyAQfFK1xken7Rv8vQ,12814
25
+ google/genai/pagers.py,sha256=m0SfWWn1EJs2k1On3DZx371qb8g2BRm_188ExsicIRc,7098
26
+ google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
27
+ google/genai/tokens.py,sha256=PvAIGl93bLCtc3bxaBS1-NE4et_xn4XBZ1bJn9ZYxP8,12502
28
+ google/genai/tunings.py,sha256=ctSApLv-Lpjrkm2-JE8fQo332706EMXp9b9u552wNTE,49996
29
+ google/genai/types.py,sha256=rIiMTLQQiRz7frgL3uchuXUCQciJEIMBV-B_1okILck,476572
30
+ google/genai/version.py,sha256=YPf09ydfdYGYELmthoUhjWan0Yv6J2Cz6saNEHhqN-c,627
31
+ google_genai-1.28.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
+ google_genai-1.28.0.dist-info/METADATA,sha256=_G5eO1nP7bswlUTGcuh46FEbSF_vLZ7Ir6G76ANNISk,43091
33
+ google_genai-1.28.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ google_genai-1.28.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
+ google_genai-1.28.0.dist-info/RECORD,,
@@ -1,35 +0,0 @@
1
- google/genai/__init__.py,sha256=SYTxz3Ho06pP2TBlvDU0FkUJz8ytbR3MgEpS9HvVYq4,709
2
- google/genai/_adapters.py,sha256=Kok38miNYJff2n--l0zEK_hbq0y2rWOH7k75J7SMYbQ,1744
3
- google/genai/_api_client.py,sha256=X9JVR_XBnedZgkOKbBcvJjMuHupA75XXJkmlrVZqTw0,53102
4
- google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,902
5
- google/genai/_automatic_function_calling_util.py,sha256=IJkPq2fT9pYxYm5Pbu5-e0nBoZKoZla7yT4_txWRKLs,10324
6
- google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
7
- google/genai/_common.py,sha256=sJpzeoEJ6dZSPPfHb2Dsar-F5KmpwLjFqNSkxxxVfS8,19876
8
- google/genai/_extra_utils.py,sha256=jWhJIdaFoVsrvExl6L7of3Bu8miSKvVidx4pbQ6EO2A,20571
9
- google/genai/_live_converters.py,sha256=pIcEfsAxjV1zeWmxMNigDD7ETHiuutp-a2y0HQThdmU,100162
10
- google/genai/_mcp_utils.py,sha256=khECx-DMuHemKzOQQ3msWp7FivPeEOnl3n1lvWc_b5o,3833
11
- google/genai/_replay_api_client.py,sha256=2ndavmUMySvjLIdYEvjPZIOPfc-IA5rbWQgEwWuWpfc,21567
12
- google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
13
- google/genai/_tokens_converters.py,sha256=ClWTsgcqn91zSw_qTqLPTNSP1-_G8s-NlBCD8-DQniw,23803
14
- google/genai/_transformers.py,sha256=uTRSd9qrUZbJoFzLEWy3wGR_j1KqVg5cypGzQM1Mc4w,37357
15
- google/genai/batches.py,sha256=rat60rGEza3QIu4ExyUl0RAzQiyFZkcJ4excxpiq8FA,80594
16
- google/genai/caches.py,sha256=oL7vb_G1__Q1I4jdhLNNe20KJK6nRwZ7WeiQ8S1-oVg,64173
17
- google/genai/chats.py,sha256=0QdOUeWEYDQgAWBy1f7a3z3yY9S8tXSowUzNrzazzj4,16651
18
- google/genai/client.py,sha256=wXnfZBSv9p-yKtX_gabUrfBXoYHuqHhzK_VgwRttMgY,10777
19
- google/genai/errors.py,sha256=IdSymOuUJDprfPRBhBtFDkc_XX81UvgNbWrOLR8L2GU,5582
20
- google/genai/files.py,sha256=mz3sZ6F90Kh5ftqq0uv8gcqJfRuwfoZGBFsmDmpAt9k,39809
21
- google/genai/live.py,sha256=WvOPBFDwD2eyUx89XCW6oudKtlK7960RqQuk5-SY1Ac,39482
22
- google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
23
- google/genai/models.py,sha256=0QkjP8oXmWcOvyFZFZZc4LMsEOqYdoS5hwAkhQtDF70,234958
24
- google/genai/operations.py,sha256=3eudPaItN6_JJKMWNT9lLIJLUGyAQfFK1xken7Rv8vQ,12814
25
- google/genai/pagers.py,sha256=nyVYxp92rS-UaewO_oBgP593knofeLU6yOn6RolNoGQ,6797
26
- google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
27
- google/genai/tokens.py,sha256=QGW1jI0Y5wXqiaad0-N6Utgh9sK4TK0todHf5h0GLeI,12490
28
- google/genai/tunings.py,sha256=-_Fti-aX8NyDg4FxWtABUPuc5wmxNm6f_l98KXUKa1s,48461
29
- google/genai/types.py,sha256=8etqHluvZ_FQh4ZZTkJhMCbRe_41szi7YI_AVyQglE0,472335
30
- google/genai/version.py,sha256=4aazDDnUY1hmPYa17XYQCaoZRiBorYIq6V0oRcsfpYU,627
31
- google_genai-1.26.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
- google_genai-1.26.0.dist-info/METADATA,sha256=1cD530ebUHsbi0RM5576qQCC8qTphGLlx-Rd5JZINvI,42400
33
- google_genai-1.26.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- google_genai-1.26.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
- google_genai-1.26.0.dist-info/RECORD,,