google-genai 1.25.0__py3-none-any.whl → 1.26.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/types.py CHANGED
@@ -15,6 +15,7 @@
15
15
 
16
16
  # Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17
17
 
18
+ from abc import ABC, abstractmethod
18
19
  import datetime
19
20
  from enum import Enum, EnumMeta
20
21
  import inspect
@@ -26,7 +27,7 @@ import typing
26
27
  from typing import Any, Callable, Literal, Optional, Sequence, Union, _UnionGenericAlias # type: ignore
27
28
  import pydantic
28
29
  from pydantic import Field
29
- from typing_extensions import TypedDict
30
+ from typing_extensions import Self, TypedDict
30
31
  from . import _common
31
32
 
32
33
  if sys.version_info >= (3, 10):
@@ -6381,6 +6382,11 @@ class EditImageConfig(_common.BaseModel):
6381
6382
  only).
6382
6383
  """,
6383
6384
  )
6385
+ add_watermark: Optional[bool] = Field(
6386
+ default=None,
6387
+ description="""Whether to add a watermark to the generated images.
6388
+ """,
6389
+ )
6384
6390
  edit_mode: Optional[EditMode] = Field(
6385
6391
  default=None,
6386
6392
  description="""Describes the editing mode for the request.""",
@@ -6457,6 +6463,10 @@ class EditImageConfigDict(TypedDict, total=False):
6457
6463
  only).
6458
6464
  """
6459
6465
 
6466
+ add_watermark: Optional[bool]
6467
+ """Whether to add a watermark to the generated images.
6468
+ """
6469
+
6460
6470
  edit_mode: Optional[EditMode]
6461
6471
  """Describes the editing mode for the request."""
6462
6472
 
@@ -7613,7 +7623,7 @@ class GenerateVideosConfig(_common.BaseModel):
7613
7623
  )
7614
7624
  resolution: Optional[str] = Field(
7615
7625
  default=None,
7616
- description="""The resolution for the generated video. 1280x720, 1920x1080 are supported.""",
7626
+ description="""The resolution for the generated video. 720p and 1080p are supported.""",
7617
7627
  )
7618
7628
  person_generation: Optional[str] = Field(
7619
7629
  default=None,
@@ -7669,7 +7679,7 @@ class GenerateVideosConfigDict(TypedDict, total=False):
7669
7679
  """The aspect ratio for the generated video. 16:9 (landscape) and 9:16 (portrait) are supported."""
7670
7680
 
7671
7681
  resolution: Optional[str]
7672
- """The resolution for the generated video. 1280x720, 1920x1080 are supported."""
7682
+ """The resolution for the generated video. 720p and 1080p are supported."""
7673
7683
 
7674
7684
  person_generation: Optional[str]
7675
7685
  """Whether allow to generate person videos, and restrict to specific ages. Supported values are: dont_allow, allow_adult."""
@@ -7785,26 +7795,8 @@ class GenerateVideosResponse(_common.BaseModel):
7785
7795
  )
7786
7796
 
7787
7797
 
7788
- class GenerateVideosResponseDict(TypedDict, total=False):
7789
- """Response with generated videos."""
7790
-
7791
- generated_videos: Optional[list[GeneratedVideoDict]]
7792
- """List of the generated videos"""
7793
-
7794
- rai_media_filtered_count: Optional[int]
7795
- """Returns if any videos were filtered due to RAI policies."""
7796
-
7797
- rai_media_filtered_reasons: Optional[list[str]]
7798
- """Returns rai failure reasons if any."""
7799
-
7800
-
7801
- GenerateVideosResponseOrDict = Union[
7802
- GenerateVideosResponse, GenerateVideosResponseDict
7803
- ]
7804
-
7805
-
7806
- class GenerateVideosOperation(_common.BaseModel):
7807
- """A video generation operation."""
7798
+ class Operation(ABC):
7799
+ """A long-running operation."""
7808
7800
 
7809
7801
  name: Optional[str] = Field(
7810
7802
  default=None,
@@ -7822,38 +7814,101 @@ class GenerateVideosOperation(_common.BaseModel):
7822
7814
  default=None,
7823
7815
  description="""The error result of the operation in case of failure or cancellation.""",
7824
7816
  )
7817
+
7818
+ @classmethod
7819
+ @abstractmethod
7820
+ def from_api_response(
7821
+ cls, api_response: Any, is_vertex_ai: bool = False
7822
+ ) -> Self:
7823
+ """Creates an Operation from an API response."""
7824
+ pass
7825
+
7826
+
7827
+ class GenerateVideosOperation(_common.BaseModel, Operation):
7828
+ """A video generation operation."""
7829
+
7825
7830
  response: Optional[GenerateVideosResponse] = Field(
7826
7831
  default=None, description="""The generated videos."""
7827
7832
  )
7833
+
7828
7834
  result: Optional[GenerateVideosResponse] = Field(
7829
7835
  default=None, description="""The generated videos."""
7830
7836
  )
7831
7837
 
7838
+ @classmethod
7839
+ def from_api_response(
7840
+ cls, api_response: Any, is_vertex_ai: bool = False
7841
+ ) -> Self:
7842
+ """Instantiates a GenerateVideosOperation from an API response."""
7843
+ new_operation = cls()
7844
+ new_operation.name = api_response.get('name', None)
7845
+ new_operation.metadata = api_response.get('metadata', None)
7846
+ new_operation.done = api_response.get('done', None)
7847
+ new_operation.error = api_response.get('error', None)
7848
+
7849
+ if is_vertex_ai:
7850
+ if api_response.get('response', None) is not None:
7851
+ new_operation.response = GenerateVideosResponse(
7852
+ generated_videos=[
7853
+ GeneratedVideo(
7854
+ video=Video(
7855
+ uri=video.get('gcsUri', None),
7856
+ video_bytes=video.get('bytesBase64Encoded', None),
7857
+ mime_type=video.get('mimeType', None),
7858
+ )
7859
+ )
7860
+ for video in api_response.get('response', {}).get('videos', [])
7861
+ ],
7862
+ rai_media_filtered_count=api_response.get('response', {}).get(
7863
+ 'raiMediaFilteredCount', None
7864
+ ),
7865
+ rai_media_filtered_reasons=api_response.get('response', {}).get(
7866
+ 'raiMediaFilteredReasons', None
7867
+ ),
7868
+ )
7869
+ else:
7870
+ if api_response.get('response', None) is not None:
7871
+ new_operation.response = GenerateVideosResponse(
7872
+ generated_videos=[
7873
+ GeneratedVideo(
7874
+ video=Video(
7875
+ uri=video.get('video', {}).get('uri', None),
7876
+ video_bytes=video.get('video', {}).get(
7877
+ 'encodedVideo', None
7878
+ ),
7879
+ mime_type=video.get('encoding', None),
7880
+ )
7881
+ )
7882
+ for video in api_response.get('response', {})
7883
+ .get('generateVideoResponse', {})
7884
+ .get('generatedSamples', [])
7885
+ ],
7886
+ rai_media_filtered_count=api_response.get('response', {})
7887
+ .get('generateVideoResponse', {})
7888
+ .get('raiMediaFilteredCount', None),
7889
+ rai_media_filtered_reasons=api_response.get('response', {})
7890
+ .get('generateVideoResponse', {})
7891
+ .get('raiMediaFilteredReasons', None),
7892
+ )
7893
+ new_operation.result = new_operation.response
7894
+ return new_operation
7832
7895
 
7833
- class GenerateVideosOperationDict(TypedDict, total=False):
7834
- """A video generation operation."""
7835
-
7836
- name: Optional[str]
7837
- """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}`."""
7838
-
7839
- metadata: Optional[dict[str, Any]]
7840
- """Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any."""
7841
7896
 
7842
- done: Optional[bool]
7843
- """If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available."""
7897
+ class GenerateVideosResponseDict(TypedDict, total=False):
7898
+ """Response with generated videos."""
7844
7899
 
7845
- error: Optional[dict[str, Any]]
7846
- """The error result of the operation in case of failure or cancellation."""
7900
+ generated_videos: Optional[list[GeneratedVideoDict]]
7901
+ """List of the generated videos"""
7847
7902
 
7848
- response: Optional[GenerateVideosResponseDict]
7849
- """The generated videos."""
7903
+ rai_media_filtered_count: Optional[int]
7904
+ """Returns if any videos were filtered due to RAI policies."""
7850
7905
 
7851
- result: Optional[GenerateVideosResponseDict]
7852
- """The generated videos."""
7906
+ rai_media_filtered_reasons: Optional[list[str]]
7907
+ """Returns rai failure reasons if any."""
7853
7908
 
7854
7909
 
7855
- GenerateVideosOperationOrDict = Union[
7856
- GenerateVideosOperation, GenerateVideosOperationDict
7910
+ GenerateVideosResponseOrDict = Union[
7911
+ GenerateVideosResponse, GenerateVideosResponseDict
7857
7912
  ]
7858
7913
 
7859
7914
 
@@ -9141,7 +9196,7 @@ _CreateTuningJobParametersOrDict = Union[
9141
9196
  ]
9142
9197
 
9143
9198
 
9144
- class Operation(_common.BaseModel):
9199
+ class TuningOperation(_common.BaseModel):
9145
9200
  """A long-running operation."""
9146
9201
 
9147
9202
  name: Optional[str] = Field(
@@ -9162,7 +9217,7 @@ class Operation(_common.BaseModel):
9162
9217
  )
9163
9218
 
9164
9219
 
9165
- class OperationDict(TypedDict, total=False):
9220
+ class TuningOperationDict(TypedDict, total=False):
9166
9221
  """A long-running operation."""
9167
9222
 
9168
9223
  name: Optional[str]
@@ -9178,7 +9233,7 @@ class OperationDict(TypedDict, total=False):
9178
9233
  """The error result of the operation in case of failure or cancellation."""
9179
9234
 
9180
9235
 
9181
- OperationOrDict = Union[Operation, OperationDict]
9236
+ TuningOperationOrDict = Union[TuningOperation, TuningOperationDict]
9182
9237
 
9183
9238
 
9184
9239
  class CreateCachedContentConfig(_common.BaseModel):
@@ -10166,6 +10221,14 @@ class BatchJobDestinationDict(TypedDict, total=False):
10166
10221
  BatchJobDestinationOrDict = Union[BatchJobDestination, BatchJobDestinationDict]
10167
10222
 
10168
10223
 
10224
+ BatchJobDestinationUnion = Union[BatchJobDestination, str]
10225
+
10226
+
10227
+ BatchJobDestinationUnionDict = Union[
10228
+ BatchJobDestinationUnion, BatchJobDestinationDict
10229
+ ]
10230
+
10231
+
10169
10232
  class CreateBatchJobConfig(_common.BaseModel):
10170
10233
  """Config for optional parameters."""
10171
10234
 
@@ -10177,7 +10240,7 @@ class CreateBatchJobConfig(_common.BaseModel):
10177
10240
  description="""The user-defined name of this BatchJob.
10178
10241
  """,
10179
10242
  )
10180
- dest: Optional[str] = Field(
10243
+ dest: Optional[BatchJobDestinationUnion] = Field(
10181
10244
  default=None,
10182
10245
  description="""GCS or BigQuery URI prefix for the output predictions. Example:
10183
10246
  "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
@@ -10195,7 +10258,7 @@ class CreateBatchJobConfigDict(TypedDict, total=False):
10195
10258
  """The user-defined name of this BatchJob.
10196
10259
  """
10197
10260
 
10198
- dest: Optional[str]
10261
+ dest: Optional[BatchJobDestinationUnionDict]
10199
10262
  """GCS or BigQuery URI prefix for the output predictions. Example:
10200
10263
  "gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
10201
10264
  """
google/genai/version.py CHANGED
@@ -13,4 +13,4 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
- __version__ = '1.25.0' # x-release-please-version
16
+ __version__ = '1.26.0' # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-genai
3
- Version: 1.25.0
3
+ Version: 1.26.0
4
4
  Summary: GenAI Python SDK
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -609,16 +609,16 @@ from google.genai import types
609
609
  function = types.FunctionDeclaration(
610
610
  name='get_current_weather',
611
611
  description='Get the current weather in a given location',
612
- parameters=types.Schema(
613
- type='OBJECT',
614
- properties={
615
- 'location': types.Schema(
616
- type='STRING',
617
- description='The city and state, e.g. San Francisco, CA',
618
- ),
612
+ parameters_json_schema={
613
+ 'type': 'object',
614
+ 'properties': {
615
+ 'location': {
616
+ 'type': 'string',
617
+ 'description': 'The city and state, e.g. San Francisco, CA',
618
+ }
619
619
  },
620
- required=['location'],
621
- ),
620
+ 'required': ['location'],
621
+ },
622
622
  )
623
623
 
624
624
  tool = types.Tool(function_declarations=[function])
@@ -799,6 +799,40 @@ However you define your schema, don't duplicate it in your input prompt,
799
799
  including by giving examples of expected JSON output. If you do, the generated
800
800
  output might be lower in quality.
801
801
 
802
+ #### JSON Schema support
803
+ Schemas can be provided as standard JSON schema.
804
+ ```python
805
+ user_profile = {
806
+ 'properties': {
807
+ 'age': {
808
+ 'anyOf': [
809
+ {'maximum': 20, 'minimum': 0, 'type': 'integer'},
810
+ {'type': 'null'},
811
+ ],
812
+ 'title': 'Age',
813
+ },
814
+ 'username': {
815
+ 'description': "User's unique name",
816
+ 'title': 'Username',
817
+ 'type': 'string',
818
+ },
819
+ },
820
+ 'required': ['username', 'age'],
821
+ 'title': 'User Schema',
822
+ 'type': 'object',
823
+ }
824
+
825
+ response = client.models.generate_content(
826
+ model='gemini-2.0-flash',
827
+ contents='Give me information of the United States.',
828
+ config={
829
+ 'response_mime_type': 'application/json',
830
+ 'response_json_schema': userProfile
831
+ },
832
+ )
833
+ print(response.parsed)
834
+ ```
835
+
802
836
  #### Pydantic Model Schema support
803
837
 
804
838
  Schemas can be provided as Pydantic Models.
@@ -5,31 +5,31 @@ google/genai/_api_module.py,sha256=lj8eUWx8_LBGBz-49qz6_ywWm3GYp3d8Bg5JoOHbtbI,9
5
5
  google/genai/_automatic_function_calling_util.py,sha256=IJkPq2fT9pYxYm5Pbu5-e0nBoZKoZla7yT4_txWRKLs,10324
6
6
  google/genai/_base_url.py,sha256=E5H4dew14Y16qfnB3XRnjSCi19cJVlkaMNoM_8ip-PM,1597
7
7
  google/genai/_common.py,sha256=sJpzeoEJ6dZSPPfHb2Dsar-F5KmpwLjFqNSkxxxVfS8,19876
8
- google/genai/_extra_utils.py,sha256=GoIh_SxB5nf_0sjErYkjm8wdg93sfemLKrU_5QhlcBo,20562
9
- google/genai/_live_converters.py,sha256=mkxudlXXXAxuK6eWMj_-jVLQs9eOr4EX0GYCBvhIZAw,108962
8
+ google/genai/_extra_utils.py,sha256=jWhJIdaFoVsrvExl6L7of3Bu8miSKvVidx4pbQ6EO2A,20571
9
+ google/genai/_live_converters.py,sha256=pIcEfsAxjV1zeWmxMNigDD7ETHiuutp-a2y0HQThdmU,100162
10
10
  google/genai/_mcp_utils.py,sha256=khECx-DMuHemKzOQQ3msWp7FivPeEOnl3n1lvWc_b5o,3833
11
11
  google/genai/_replay_api_client.py,sha256=2ndavmUMySvjLIdYEvjPZIOPfc-IA5rbWQgEwWuWpfc,21567
12
12
  google/genai/_test_api_client.py,sha256=4ruFIy5_1qcbKqqIBu3HSQbpSOBrxiecBtDZaTGFR1s,4797
13
- google/genai/_tokens_converters.py,sha256=jQlwRZU4mlIBv6i8Lu62e6u9dvgNtOnko5WEYnjkU_A,49159
14
- google/genai/_transformers.py,sha256=aNWqCQid4ISorbE8nj_ONfrkbQiD75vBFkYCYbXxzHQ,37033
15
- google/genai/batches.py,sha256=qnyWQ1RfAdSVQgV7vGor9BIWmRwUilJ0wfqOvxUwpq8,172745
16
- google/genai/caches.py,sha256=q8N3YIpgJYWrLWSy-zUZ6w9CPRjH113E8ff4MyykYA8,66169
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
17
  google/genai/chats.py,sha256=0QdOUeWEYDQgAWBy1f7a3z3yY9S8tXSowUzNrzazzj4,16651
18
18
  google/genai/client.py,sha256=wXnfZBSv9p-yKtX_gabUrfBXoYHuqHhzK_VgwRttMgY,10777
19
19
  google/genai/errors.py,sha256=IdSymOuUJDprfPRBhBtFDkc_XX81UvgNbWrOLR8L2GU,5582
20
- google/genai/files.py,sha256=MCcHRXiMFKjbnt78yVPejszEgGz_MHRXfJyDi5-07Gs,39655
21
- google/genai/live.py,sha256=zkKlSAi378DiAL9iRug8c8zOfqG1BK45u1ttfxrrZqU,39393
20
+ google/genai/files.py,sha256=mz3sZ6F90Kh5ftqq0uv8gcqJfRuwfoZGBFsmDmpAt9k,39809
21
+ google/genai/live.py,sha256=WvOPBFDwD2eyUx89XCW6oudKtlK7960RqQuk5-SY1Ac,39482
22
22
  google/genai/live_music.py,sha256=3GG9nsto8Vhkohcs-4CPMS4DFp1ZtMuLYzHfvEPYAeg,6971
23
- google/genai/models.py,sha256=DQx31b43CxVg2YCWHVGGKBzcuB-AfBApmPm9zPVLq6o,239567
24
- google/genai/operations.py,sha256=99zs__fTWsyQu7rMGmBI1_4tuAJxLR0g3yp7ymsUsBA,19609
23
+ google/genai/models.py,sha256=0QkjP8oXmWcOvyFZFZZc4LMsEOqYdoS5hwAkhQtDF70,234958
24
+ google/genai/operations.py,sha256=3eudPaItN6_JJKMWNT9lLIJLUGyAQfFK1xken7Rv8vQ,12814
25
25
  google/genai/pagers.py,sha256=nyVYxp92rS-UaewO_oBgP593knofeLU6yOn6RolNoGQ,6797
26
26
  google/genai/py.typed,sha256=RsMFoLwBkAvY05t6izop4UHZtqOPLiKp3GkIEizzmQY,40
27
27
  google/genai/tokens.py,sha256=QGW1jI0Y5wXqiaad0-N6Utgh9sK4TK0todHf5h0GLeI,12490
28
- google/genai/tunings.py,sha256=fSiD4RQZI8YsFaPbBoXOIoSDA0BIuJwGg2Ac_uy5_kM,49596
29
- google/genai/types.py,sha256=z5NTdkK2-UNZ54VK7fFTmvf1tCJhf_aSQ0d6C-c70mU,470375
30
- google/genai/version.py,sha256=Bxlj38TRVWAtzVotucCfIgyEBiHiLWfid2FNcMmGuP4,627
31
- google_genai-1.25.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
32
- google_genai-1.25.0.dist-info/METADATA,sha256=X94rtkQYckaADmyC8ULKYLSm2gq3m4shZAYT_tHx3Yk,41566
33
- google_genai-1.25.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- google_genai-1.25.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
35
- google_genai-1.25.0.dist-info/RECORD,,
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,,