google-genai 1.2.0__py3-none-any.whl → 1.4.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 +160 -59
- google/genai/_api_module.py +6 -1
- google/genai/_automatic_function_calling_util.py +12 -12
- google/genai/_common.py +14 -2
- google/genai/_extra_utils.py +14 -8
- google/genai/_replay_api_client.py +35 -3
- google/genai/_test_api_client.py +8 -8
- google/genai/_transformers.py +169 -48
- google/genai/batches.py +176 -127
- google/genai/caches.py +315 -214
- google/genai/chats.py +179 -35
- google/genai/client.py +16 -6
- google/genai/errors.py +19 -5
- google/genai/files.py +161 -115
- google/genai/live.py +137 -105
- google/genai/models.py +1553 -734
- google/genai/operations.py +635 -0
- google/genai/pagers.py +5 -5
- google/genai/tunings.py +166 -103
- google/genai/types.py +590 -142
- google/genai/version.py +1 -1
- {google_genai-1.2.0.dist-info → google_genai-1.4.0.dist-info}/METADATA +94 -12
- google_genai-1.4.0.dist-info/RECORD +27 -0
- {google_genai-1.2.0.dist-info → google_genai-1.4.0.dist-info}/WHEEL +1 -1
- google/genai/_operations.py +0 -365
- google_genai-1.2.0.dist-info/RECORD +0 -27
- {google_genai-1.2.0.dist-info → google_genai-1.4.0.dist-info}/LICENSE +0 -0
- {google_genai-1.2.0.dist-info → google_genai-1.4.0.dist-info}/top_level.txt +0 -0
google/genai/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: google-genai
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.4.0
|
4
4
|
Summary: GenAI Python SDK
|
5
5
|
Author-email: Google LLC <googleapis-packages@google.com>
|
6
6
|
License: Apache-2.0
|
@@ -21,6 +21,7 @@ Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
22
22
|
License-File: LICENSE
|
23
23
|
Requires-Dist: google-auth<3.0.0dev,>=2.14.1
|
24
|
+
Requires-Dist: httpx<1.0.0dev,>=0.28.1
|
24
25
|
Requires-Dist: pydantic<3.0.0dev,>=2.0.0
|
25
26
|
Requires-Dist: requests<3.0.0dev,>=2.28.1
|
26
27
|
Requires-Dist: websockets<15.0dev,>=13.0
|
@@ -83,7 +84,7 @@ export GOOGLE_API_KEY='your-api-key'
|
|
83
84
|
and `GOOGLE_CLOUD_LOCATION`, as shown below:
|
84
85
|
|
85
86
|
```bash
|
86
|
-
export GOOGLE_GENAI_USE_VERTEXAI=
|
87
|
+
export GOOGLE_GENAI_USE_VERTEXAI=true
|
87
88
|
export GOOGLE_CLOUD_PROJECT='your-project-id'
|
88
89
|
export GOOGLE_CLOUD_LOCATION='us-central1'
|
89
90
|
```
|
@@ -94,21 +95,29 @@ client = genai.Client()
|
|
94
95
|
|
95
96
|
### API Selection
|
96
97
|
|
98
|
+
By default, the SDK uses the beta API endpoints provided by Google to support
|
99
|
+
preview features in the APIs. The stable API endpoints can be selected by
|
100
|
+
setting the API version to `v1`.
|
101
|
+
|
97
102
|
To set the API version use `http_options`. For example, to set the API version
|
98
103
|
to `v1` for Vertex AI:
|
99
104
|
|
100
105
|
```python
|
101
106
|
client = genai.Client(
|
102
|
-
vertexai=True,
|
103
|
-
|
107
|
+
vertexai=True,
|
108
|
+
project='your-project-id',
|
109
|
+
location='us-central1',
|
110
|
+
http_options=types.HttpOptions(api_version='v1')
|
104
111
|
)
|
105
112
|
```
|
106
113
|
|
107
|
-
To set the API version to `v1alpha` for the Gemini API:
|
114
|
+
To set the API version to `v1alpha` for the Gemini Developer API:
|
108
115
|
|
109
116
|
```python
|
110
|
-
client = genai.Client(
|
111
|
-
|
117
|
+
client = genai.Client(
|
118
|
+
api_key='GEMINI_API_KEY',
|
119
|
+
http_options=types.HttpOptions(api_version='v1alpha')
|
120
|
+
)
|
112
121
|
```
|
113
122
|
|
114
123
|
## Types
|
@@ -127,7 +136,7 @@ The `client.models` modules exposes model inferencing and model getters.
|
|
127
136
|
|
128
137
|
```python
|
129
138
|
response = client.models.generate_content(
|
130
|
-
model='gemini-2.0-flash-001', contents='
|
139
|
+
model='gemini-2.0-flash-001', contents='Why is the sky blue?'
|
131
140
|
)
|
132
141
|
print(response.text)
|
133
142
|
```
|
@@ -135,7 +144,7 @@ print(response.text)
|
|
135
144
|
#### with uploaded file (Gemini API only)
|
136
145
|
download the file in console.
|
137
146
|
|
138
|
-
```
|
147
|
+
```sh
|
139
148
|
!wget -q https://storage.googleapis.com/generativeai-downloads/data/a11.txt
|
140
149
|
```
|
141
150
|
|
@@ -183,12 +192,18 @@ contents=[
|
|
183
192
|
|
184
193
|
### System Instructions and Other Configs
|
185
194
|
|
195
|
+
The output of the model can be influenced by several optional settings
|
196
|
+
available in generate_content's config parameter. For example, the
|
197
|
+
variability and length of the output can be influenced by the temperature
|
198
|
+
and max_output_tokens respectively.
|
199
|
+
|
186
200
|
```python
|
187
201
|
response = client.models.generate_content(
|
188
202
|
model='gemini-2.0-flash-001',
|
189
203
|
contents='high',
|
190
204
|
config=types.GenerateContentConfig(
|
191
205
|
system_instruction='I say high, you say low',
|
206
|
+
max_output_tokens=3,
|
192
207
|
temperature=0.3,
|
193
208
|
),
|
194
209
|
)
|
@@ -275,7 +290,7 @@ print(response.text)
|
|
275
290
|
#### Automatic Python function Support
|
276
291
|
|
277
292
|
You can pass a Python function directly and it will be automatically
|
278
|
-
called and responded.
|
293
|
+
called and responded by default.
|
279
294
|
|
280
295
|
```python
|
281
296
|
def get_current_weather(location: str) -> str:
|
@@ -295,6 +310,30 @@ response = client.models.generate_content(
|
|
295
310
|
|
296
311
|
print(response.text)
|
297
312
|
```
|
313
|
+
#### Disabling automatic function calling
|
314
|
+
If you pass in a python function as a tool directly, and do not want
|
315
|
+
automatic function calling, you can disable automatic function calling
|
316
|
+
as follows:
|
317
|
+
|
318
|
+
```python
|
319
|
+
response = client.models.generate_content(
|
320
|
+
model='gemini-2.0-flash-001',
|
321
|
+
contents='What is the weather like in Boston?',
|
322
|
+
config=types.GenerateContentConfig(
|
323
|
+
tools=[get_current_weather],
|
324
|
+
automatic_function_calling=types.AutomaticFunctionCallingConfig(
|
325
|
+
disable=True
|
326
|
+
),
|
327
|
+
),
|
328
|
+
)
|
329
|
+
```
|
330
|
+
|
331
|
+
With automatic function calling disabled, you will get a list of function call
|
332
|
+
parts in the response:
|
333
|
+
|
334
|
+
```python
|
335
|
+
function_calls: Optional[List[types.FunctionCall]] = response.function_calls
|
336
|
+
```
|
298
337
|
|
299
338
|
#### Manually declare and invoke a function for function calling
|
300
339
|
|
@@ -692,7 +731,6 @@ response1 = client.models.generate_images(
|
|
692
731
|
model='imagen-3.0-generate-002',
|
693
732
|
prompt='An umbrella in the foreground, and a rainy night sky in the background',
|
694
733
|
config=types.GenerateImagesConfig(
|
695
|
-
negative_prompt='human',
|
696
734
|
number_of_images=1,
|
697
735
|
include_rai_reason=True,
|
698
736
|
output_mime_type='image/jpeg',
|
@@ -750,7 +788,6 @@ response3 = client.models.edit_image(
|
|
750
788
|
config=types.EditImageConfig(
|
751
789
|
edit_mode='EDIT_MODE_INPAINT_INSERTION',
|
752
790
|
number_of_images=1,
|
753
|
-
negative_prompt='human',
|
754
791
|
include_rai_reason=True,
|
755
792
|
output_mime_type='image/jpeg',
|
756
793
|
),
|
@@ -758,6 +795,34 @@ response3 = client.models.edit_image(
|
|
758
795
|
response3.generated_images[0].image.show()
|
759
796
|
```
|
760
797
|
|
798
|
+
### Veo
|
799
|
+
|
800
|
+
#### Generate Videos
|
801
|
+
|
802
|
+
Support for generate videos in Vertex and Gemini Developer API is behind an allowlist
|
803
|
+
|
804
|
+
```python
|
805
|
+
# Create operation
|
806
|
+
operation = client.models.generate_videos(
|
807
|
+
model='veo-2.0-generate-001',
|
808
|
+
prompt='A neon hologram of a cat driving at top speed',
|
809
|
+
config=types.GenerateVideosConfig(
|
810
|
+
number_of_videos=1,
|
811
|
+
fps=24,
|
812
|
+
duration_seconds=5,
|
813
|
+
enhance_prompt=True,
|
814
|
+
),
|
815
|
+
)
|
816
|
+
|
817
|
+
# Poll operation
|
818
|
+
while not operation.done:
|
819
|
+
time.sleep(20)
|
820
|
+
operation = client.operations.get(operation)
|
821
|
+
|
822
|
+
video = operation.result.generated_videos[0].video
|
823
|
+
video.show()
|
824
|
+
```
|
825
|
+
|
761
826
|
## Chats
|
762
827
|
|
763
828
|
Create a chat session to start a multi-turn conversations with the model.
|
@@ -1128,3 +1193,20 @@ delete_job = client.batches.delete(name=job.name)
|
|
1128
1193
|
|
1129
1194
|
delete_job
|
1130
1195
|
```
|
1196
|
+
|
1197
|
+
## Error Handling
|
1198
|
+
|
1199
|
+
To handle errors raised by the model service, the SDK provides this [APIError](https://github.com/googleapis/python-genai/blob/main/google/genai/errors.py) class.
|
1200
|
+
|
1201
|
+
```python
|
1202
|
+
from google.genai import errors
|
1203
|
+
|
1204
|
+
try:
|
1205
|
+
client.models.generate_content(
|
1206
|
+
model="invalid-model-name",
|
1207
|
+
contents="What is your name?",
|
1208
|
+
)
|
1209
|
+
except errors.APIError as e:
|
1210
|
+
print(e.code) # 404
|
1211
|
+
print(e.message)
|
1212
|
+
```
|
@@ -0,0 +1,27 @@
|
|
1
|
+
google/genai/__init__.py,sha256=IYw-PcsdgjSpS1mU_ZcYkTfPocsJ4aVmrDxP7vX7c6Y,709
|
2
|
+
google/genai/_api_client.py,sha256=_dbVVtxTzO9ZiTgp3gLSc8C6_198Z8Maay9fUa-mi4M,27078
|
3
|
+
google/genai/_api_module.py,sha256=66FsFq9N8PdTegDyx3am3NHpI0Bw7HBmifUMCrZsx_Q,902
|
4
|
+
google/genai/_automatic_function_calling_util.py,sha256=OcmWb6RLYCMRxiEZu4Q1B9aVXg_Q1qqZvMlVaAwdKWI,11062
|
5
|
+
google/genai/_common.py,sha256=uPDZ_HdZvWz7teUln36nCcRYbHbYTiT5HAmTuB_eCqA,9983
|
6
|
+
google/genai/_extra_utils.py,sha256=UrmiGxOkXXBIThwu8A0QAkKZiv39whmlqGSXoP0oHDk,11807
|
7
|
+
google/genai/_replay_api_client.py,sha256=rPu73PCijydo7cGdDS0B75Us3exopPBiXmRZmGSytzI,16199
|
8
|
+
google/genai/_test_api_client.py,sha256=XNOWq8AkYbqInv1aljNGlFXsv8slQIWTYy_hdcCetD0,4797
|
9
|
+
google/genai/_transformers.py,sha256=mEowhaTeH7l2pUevr7YB6DphN_D2-iPiyKnF6d41-bo,28340
|
10
|
+
google/genai/batches.py,sha256=QgZlVDSNzOvtTUWnMR5f7fAALOLDyi5X022P0fkMvuc,41183
|
11
|
+
google/genai/caches.py,sha256=7n0_7SeHa3nohJ0DFsOrIghE8AaVTLVLpYyiRemKf_I,57576
|
12
|
+
google/genai/chats.py,sha256=ds5iF4hqvyHbHE4OlP1b5s93SwD0hlMNpWxT7db2E48,13493
|
13
|
+
google/genai/client.py,sha256=uhX1MhEHepqe6biU-ix_d4wsv5xG8NevT7gFEva0XEM,9785
|
14
|
+
google/genai/errors.py,sha256=BMEANEl_EK1ZIIZsO1FxgX1szvsdaEIaqhu4NpnBLow,4213
|
15
|
+
google/genai/files.py,sha256=-IdlddbpwNK5ToA00vtOij_DMU2ugEZRQkBp3x7cCoM,44668
|
16
|
+
google/genai/live.py,sha256=z_Y7LSZcPVkfInjLT9J8LWNIXD5E3e6TPDXZeadOcn0,24710
|
17
|
+
google/genai/models.py,sha256=ra6j8-_PVy0LqTBHpK80pHwws9aPiY-5uTHQ_3t86RI,206985
|
18
|
+
google/genai/operations.py,sha256=6zxvDBIJAH38Ga23Wf6msoEGzJWhfOscGnbHY_tdCrE,19451
|
19
|
+
google/genai/pagers.py,sha256=xC0LEgR8E4z9XNZUnZnNwSsAUCJPlMFUpJ7eXr4nuDM,6645
|
20
|
+
google/genai/tunings.py,sha256=Prt3bI5fKUoDWtz6A6pxSWQwP0_ecGXa1rPOvfzGKSM,47568
|
21
|
+
google/genai/types.py,sha256=z8tX1THcR2dTMKZYwsOZWR_OGBHvdpkmCNFBSft55zE,297091
|
22
|
+
google/genai/version.py,sha256=mOyGG-hAwdvxg1_wBKMm2uMprTFFYHVKz6j0htJ9Irs,626
|
23
|
+
google_genai-1.4.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
24
|
+
google_genai-1.4.0.dist-info/METADATA,sha256=y4Jij7zMfosWDeq44MoSPBuZQ4x3xctqOnqha4IMqcA,29152
|
25
|
+
google_genai-1.4.0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
26
|
+
google_genai-1.4.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
27
|
+
google_genai-1.4.0.dist-info/RECORD,,
|
google/genai/_operations.py
DELETED
@@ -1,365 +0,0 @@
|
|
1
|
-
# Copyright 2024 Google LLC
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#
|
15
|
-
|
16
|
-
# Code generated by the Google Gen AI SDK generator DO NOT EDIT.
|
17
|
-
|
18
|
-
from typing import Optional, Union
|
19
|
-
from urllib.parse import urlencode
|
20
|
-
from . import _api_module
|
21
|
-
from . import _common
|
22
|
-
from . import types
|
23
|
-
from ._api_client import ApiClient
|
24
|
-
from ._common import get_value_by_path as getv
|
25
|
-
from ._common import set_value_by_path as setv
|
26
|
-
|
27
|
-
|
28
|
-
def _GetOperationParameters_to_mldev(
|
29
|
-
api_client: ApiClient,
|
30
|
-
from_object: Union[dict, object],
|
31
|
-
parent_object: dict = None,
|
32
|
-
) -> dict:
|
33
|
-
to_object = {}
|
34
|
-
if getv(from_object, ['operation_name']) is not None:
|
35
|
-
setv(
|
36
|
-
to_object,
|
37
|
-
['_url', 'operationName'],
|
38
|
-
getv(from_object, ['operation_name']),
|
39
|
-
)
|
40
|
-
|
41
|
-
if getv(from_object, ['config']) is not None:
|
42
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
43
|
-
|
44
|
-
return to_object
|
45
|
-
|
46
|
-
|
47
|
-
def _GetOperationParameters_to_vertex(
|
48
|
-
api_client: ApiClient,
|
49
|
-
from_object: Union[dict, object],
|
50
|
-
parent_object: dict = None,
|
51
|
-
) -> dict:
|
52
|
-
to_object = {}
|
53
|
-
if getv(from_object, ['operation_name']) is not None:
|
54
|
-
setv(
|
55
|
-
to_object,
|
56
|
-
['_url', 'operationName'],
|
57
|
-
getv(from_object, ['operation_name']),
|
58
|
-
)
|
59
|
-
|
60
|
-
if getv(from_object, ['config']) is not None:
|
61
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
62
|
-
|
63
|
-
return to_object
|
64
|
-
|
65
|
-
|
66
|
-
def _FetchPredictOperationParameters_to_mldev(
|
67
|
-
api_client: ApiClient,
|
68
|
-
from_object: Union[dict, object],
|
69
|
-
parent_object: dict = None,
|
70
|
-
) -> dict:
|
71
|
-
to_object = {}
|
72
|
-
if getv(from_object, ['operation_name']) is not None:
|
73
|
-
raise ValueError('operation_name parameter is not supported in Gemini API.')
|
74
|
-
|
75
|
-
if getv(from_object, ['resource_name']) is not None:
|
76
|
-
raise ValueError('resource_name parameter is not supported in Gemini API.')
|
77
|
-
|
78
|
-
if getv(from_object, ['config']) is not None:
|
79
|
-
raise ValueError('config parameter is not supported in Gemini API.')
|
80
|
-
|
81
|
-
return to_object
|
82
|
-
|
83
|
-
|
84
|
-
def _FetchPredictOperationParameters_to_vertex(
|
85
|
-
api_client: ApiClient,
|
86
|
-
from_object: Union[dict, object],
|
87
|
-
parent_object: dict = None,
|
88
|
-
) -> dict:
|
89
|
-
to_object = {}
|
90
|
-
if getv(from_object, ['operation_name']) is not None:
|
91
|
-
setv(to_object, ['operationName'], getv(from_object, ['operation_name']))
|
92
|
-
|
93
|
-
if getv(from_object, ['resource_name']) is not None:
|
94
|
-
setv(
|
95
|
-
to_object,
|
96
|
-
['_url', 'resourceName'],
|
97
|
-
getv(from_object, ['resource_name']),
|
98
|
-
)
|
99
|
-
|
100
|
-
if getv(from_object, ['config']) is not None:
|
101
|
-
setv(to_object, ['config'], getv(from_object, ['config']))
|
102
|
-
|
103
|
-
return to_object
|
104
|
-
|
105
|
-
|
106
|
-
def _Operation_from_mldev(
|
107
|
-
api_client: ApiClient,
|
108
|
-
from_object: Union[dict, object],
|
109
|
-
parent_object: dict = None,
|
110
|
-
) -> dict:
|
111
|
-
to_object = {}
|
112
|
-
if getv(from_object, ['name']) is not None:
|
113
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
114
|
-
|
115
|
-
if getv(from_object, ['metadata']) is not None:
|
116
|
-
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
117
|
-
|
118
|
-
if getv(from_object, ['done']) is not None:
|
119
|
-
setv(to_object, ['done'], getv(from_object, ['done']))
|
120
|
-
|
121
|
-
if getv(from_object, ['error']) is not None:
|
122
|
-
setv(to_object, ['error'], getv(from_object, ['error']))
|
123
|
-
|
124
|
-
if getv(from_object, ['response']) is not None:
|
125
|
-
setv(to_object, ['response'], getv(from_object, ['response']))
|
126
|
-
|
127
|
-
return to_object
|
128
|
-
|
129
|
-
|
130
|
-
def _Operation_from_vertex(
|
131
|
-
api_client: ApiClient,
|
132
|
-
from_object: Union[dict, object],
|
133
|
-
parent_object: dict = None,
|
134
|
-
) -> dict:
|
135
|
-
to_object = {}
|
136
|
-
if getv(from_object, ['name']) is not None:
|
137
|
-
setv(to_object, ['name'], getv(from_object, ['name']))
|
138
|
-
|
139
|
-
if getv(from_object, ['metadata']) is not None:
|
140
|
-
setv(to_object, ['metadata'], getv(from_object, ['metadata']))
|
141
|
-
|
142
|
-
if getv(from_object, ['done']) is not None:
|
143
|
-
setv(to_object, ['done'], getv(from_object, ['done']))
|
144
|
-
|
145
|
-
if getv(from_object, ['error']) is not None:
|
146
|
-
setv(to_object, ['error'], getv(from_object, ['error']))
|
147
|
-
|
148
|
-
if getv(from_object, ['response']) is not None:
|
149
|
-
setv(to_object, ['response'], getv(from_object, ['response']))
|
150
|
-
|
151
|
-
return to_object
|
152
|
-
|
153
|
-
|
154
|
-
class _operations(_api_module.BaseModule):
|
155
|
-
|
156
|
-
def _get_operation(
|
157
|
-
self,
|
158
|
-
*,
|
159
|
-
operation_name: str,
|
160
|
-
config: Optional[types.GetOperationConfigOrDict] = None,
|
161
|
-
) -> types.Operation:
|
162
|
-
parameter_model = types._GetOperationParameters(
|
163
|
-
operation_name=operation_name,
|
164
|
-
config=config,
|
165
|
-
)
|
166
|
-
|
167
|
-
if self._api_client.vertexai:
|
168
|
-
request_dict = _GetOperationParameters_to_vertex(
|
169
|
-
self._api_client, parameter_model
|
170
|
-
)
|
171
|
-
path = '{operationName}'.format_map(request_dict.get('_url'))
|
172
|
-
else:
|
173
|
-
request_dict = _GetOperationParameters_to_mldev(
|
174
|
-
self._api_client, parameter_model
|
175
|
-
)
|
176
|
-
path = '{operationName}'.format_map(request_dict.get('_url'))
|
177
|
-
query_params = request_dict.get('_query')
|
178
|
-
if query_params:
|
179
|
-
path = f'{path}?{urlencode(query_params)}'
|
180
|
-
# TODO: remove the hack that pops config.
|
181
|
-
request_dict.pop('config', None)
|
182
|
-
|
183
|
-
http_options = None
|
184
|
-
if isinstance(config, dict):
|
185
|
-
http_options = config.get('http_options', None)
|
186
|
-
elif hasattr(config, 'http_options'):
|
187
|
-
http_options = config.http_options
|
188
|
-
|
189
|
-
request_dict = _common.convert_to_dict(request_dict)
|
190
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
191
|
-
|
192
|
-
response_dict = self._api_client.request(
|
193
|
-
'get', path, request_dict, http_options
|
194
|
-
)
|
195
|
-
|
196
|
-
if self._api_client.vertexai:
|
197
|
-
response_dict = _Operation_from_vertex(self._api_client, response_dict)
|
198
|
-
else:
|
199
|
-
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
200
|
-
|
201
|
-
return_value = types.Operation._from_response(
|
202
|
-
response=response_dict, kwargs=parameter_model
|
203
|
-
)
|
204
|
-
self._api_client._verify_response(return_value)
|
205
|
-
return return_value
|
206
|
-
|
207
|
-
def _fetch_predict_operation(
|
208
|
-
self,
|
209
|
-
*,
|
210
|
-
operation_name: str,
|
211
|
-
resource_name: str,
|
212
|
-
config: Optional[types.FetchPredictOperationConfigOrDict] = None,
|
213
|
-
) -> types.Operation:
|
214
|
-
parameter_model = types._FetchPredictOperationParameters(
|
215
|
-
operation_name=operation_name,
|
216
|
-
resource_name=resource_name,
|
217
|
-
config=config,
|
218
|
-
)
|
219
|
-
|
220
|
-
if not self._api_client.vertexai:
|
221
|
-
raise ValueError('This method is only supported in the Vertex AI client.')
|
222
|
-
else:
|
223
|
-
request_dict = _FetchPredictOperationParameters_to_vertex(
|
224
|
-
self._api_client, parameter_model
|
225
|
-
)
|
226
|
-
path = '{resourceName}:fetchPredictOperation'.format_map(
|
227
|
-
request_dict.get('_url')
|
228
|
-
)
|
229
|
-
|
230
|
-
query_params = request_dict.get('_query')
|
231
|
-
if query_params:
|
232
|
-
path = f'{path}?{urlencode(query_params)}'
|
233
|
-
# TODO: remove the hack that pops config.
|
234
|
-
request_dict.pop('config', None)
|
235
|
-
|
236
|
-
http_options = None
|
237
|
-
if isinstance(config, dict):
|
238
|
-
http_options = config.get('http_options', None)
|
239
|
-
elif hasattr(config, 'http_options'):
|
240
|
-
http_options = config.http_options
|
241
|
-
|
242
|
-
request_dict = _common.convert_to_dict(request_dict)
|
243
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
244
|
-
|
245
|
-
response_dict = self._api_client.request(
|
246
|
-
'post', path, request_dict, http_options
|
247
|
-
)
|
248
|
-
|
249
|
-
if self._api_client.vertexai:
|
250
|
-
response_dict = _Operation_from_vertex(self._api_client, response_dict)
|
251
|
-
else:
|
252
|
-
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
253
|
-
|
254
|
-
return_value = types.Operation._from_response(
|
255
|
-
response=response_dict, kwargs=parameter_model
|
256
|
-
)
|
257
|
-
self._api_client._verify_response(return_value)
|
258
|
-
return return_value
|
259
|
-
|
260
|
-
|
261
|
-
class Async_operations(_api_module.BaseModule):
|
262
|
-
|
263
|
-
async def _get_operation(
|
264
|
-
self,
|
265
|
-
*,
|
266
|
-
operation_name: str,
|
267
|
-
config: Optional[types.GetOperationConfigOrDict] = None,
|
268
|
-
) -> types.Operation:
|
269
|
-
parameter_model = types._GetOperationParameters(
|
270
|
-
operation_name=operation_name,
|
271
|
-
config=config,
|
272
|
-
)
|
273
|
-
|
274
|
-
if self._api_client.vertexai:
|
275
|
-
request_dict = _GetOperationParameters_to_vertex(
|
276
|
-
self._api_client, parameter_model
|
277
|
-
)
|
278
|
-
path = '{operationName}'.format_map(request_dict.get('_url'))
|
279
|
-
else:
|
280
|
-
request_dict = _GetOperationParameters_to_mldev(
|
281
|
-
self._api_client, parameter_model
|
282
|
-
)
|
283
|
-
path = '{operationName}'.format_map(request_dict.get('_url'))
|
284
|
-
query_params = request_dict.get('_query')
|
285
|
-
if query_params:
|
286
|
-
path = f'{path}?{urlencode(query_params)}'
|
287
|
-
# TODO: remove the hack that pops config.
|
288
|
-
request_dict.pop('config', None)
|
289
|
-
|
290
|
-
http_options = None
|
291
|
-
if isinstance(config, dict):
|
292
|
-
http_options = config.get('http_options', None)
|
293
|
-
elif hasattr(config, 'http_options'):
|
294
|
-
http_options = config.http_options
|
295
|
-
|
296
|
-
request_dict = _common.convert_to_dict(request_dict)
|
297
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
298
|
-
|
299
|
-
response_dict = await self._api_client.async_request(
|
300
|
-
'get', path, request_dict, http_options
|
301
|
-
)
|
302
|
-
|
303
|
-
if self._api_client.vertexai:
|
304
|
-
response_dict = _Operation_from_vertex(self._api_client, response_dict)
|
305
|
-
else:
|
306
|
-
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
307
|
-
|
308
|
-
return_value = types.Operation._from_response(
|
309
|
-
response=response_dict, kwargs=parameter_model
|
310
|
-
)
|
311
|
-
self._api_client._verify_response(return_value)
|
312
|
-
return return_value
|
313
|
-
|
314
|
-
async def _fetch_predict_operation(
|
315
|
-
self,
|
316
|
-
*,
|
317
|
-
operation_name: str,
|
318
|
-
resource_name: str,
|
319
|
-
config: Optional[types.FetchPredictOperationConfigOrDict] = None,
|
320
|
-
) -> types.Operation:
|
321
|
-
parameter_model = types._FetchPredictOperationParameters(
|
322
|
-
operation_name=operation_name,
|
323
|
-
resource_name=resource_name,
|
324
|
-
config=config,
|
325
|
-
)
|
326
|
-
|
327
|
-
if not self._api_client.vertexai:
|
328
|
-
raise ValueError('This method is only supported in the Vertex AI client.')
|
329
|
-
else:
|
330
|
-
request_dict = _FetchPredictOperationParameters_to_vertex(
|
331
|
-
self._api_client, parameter_model
|
332
|
-
)
|
333
|
-
path = '{resourceName}:fetchPredictOperation'.format_map(
|
334
|
-
request_dict.get('_url')
|
335
|
-
)
|
336
|
-
|
337
|
-
query_params = request_dict.get('_query')
|
338
|
-
if query_params:
|
339
|
-
path = f'{path}?{urlencode(query_params)}'
|
340
|
-
# TODO: remove the hack that pops config.
|
341
|
-
request_dict.pop('config', None)
|
342
|
-
|
343
|
-
http_options = None
|
344
|
-
if isinstance(config, dict):
|
345
|
-
http_options = config.get('http_options', None)
|
346
|
-
elif hasattr(config, 'http_options'):
|
347
|
-
http_options = config.http_options
|
348
|
-
|
349
|
-
request_dict = _common.convert_to_dict(request_dict)
|
350
|
-
request_dict = _common.encode_unserializable_types(request_dict)
|
351
|
-
|
352
|
-
response_dict = await self._api_client.async_request(
|
353
|
-
'post', path, request_dict, http_options
|
354
|
-
)
|
355
|
-
|
356
|
-
if self._api_client.vertexai:
|
357
|
-
response_dict = _Operation_from_vertex(self._api_client, response_dict)
|
358
|
-
else:
|
359
|
-
response_dict = _Operation_from_mldev(self._api_client, response_dict)
|
360
|
-
|
361
|
-
return_value = types.Operation._from_response(
|
362
|
-
response=response_dict, kwargs=parameter_model
|
363
|
-
)
|
364
|
-
self._api_client._verify_response(return_value)
|
365
|
-
return return_value
|
@@ -1,27 +0,0 @@
|
|
1
|
-
google/genai/__init__.py,sha256=IYw-PcsdgjSpS1mU_ZcYkTfPocsJ4aVmrDxP7vX7c6Y,709
|
2
|
-
google/genai/_api_client.py,sha256=uQ-nYVKD81mPvXj7_CAIfhAgv2_aJlFCXQ0llSNal8s,22747
|
3
|
-
google/genai/_api_module.py,sha256=9bxmtcSTpT8Ht6VwJyw7fQqiR0jJXz7350dWGl-bC5E,780
|
4
|
-
google/genai/_automatic_function_calling_util.py,sha256=Hs7vvLRCRxL-YbNRnwx_qulY9sspwE6xP7A3-cjoIB8,10834
|
5
|
-
google/genai/_common.py,sha256=HrGkshBrfkt5bARjtJ8-dSLJSKEptM1JnqDG5AGm2Rw,9565
|
6
|
-
google/genai/_extra_utils.py,sha256=vpZs7mrAwZ1mJrbsmSdqrDepLe4hyPgjNYENV56lv2Y,11508
|
7
|
-
google/genai/_operations.py,sha256=KaDgwqG5g6Odd1P6ftvIUT9gF3ov08drm01jE1CjB_s,11490
|
8
|
-
google/genai/_replay_api_client.py,sha256=f_znGdDKXUOEN8lkRBzVZ6LDSGwrWHzy9N-Sk6pUU4E,14963
|
9
|
-
google/genai/_test_api_client.py,sha256=2PvDcW3h01U4UOSoj7TUo6TwdBHSEN_lO2tXjBoh5Fw,4765
|
10
|
-
google/genai/_transformers.py,sha256=iZ1EFNEJE3Nh3ZnccUQmdRupWLDJonaEreilhvenK-w,24331
|
11
|
-
google/genai/batches.py,sha256=jv8pW_g_cZee6ol5ER5bQRUkXsj4IUcZC5cMo-YAnt0,38033
|
12
|
-
google/genai/caches.py,sha256=lTlGSSeCLhh9kq6k4kzjVomHp0gqlON_LUOgnWbfNc0,53169
|
13
|
-
google/genai/chats.py,sha256=6gKf81vtLqUAR2TeaI0kZfxrEPEHbfwxHB5hI9zSz9A,8552
|
14
|
-
google/genai/client.py,sha256=YvOt-jPWynf4exAh5rfl2i-YxQCrw5Z9zWQNSwtE6xE,9451
|
15
|
-
google/genai/errors.py,sha256=dea3cQecyGFMoV5oIvUfKeMY904HzlcT4oiPWQzDCZo,3746
|
16
|
-
google/genai/files.py,sha256=U3qaa31AX7dKcZh6RkZSAkrDO7FVitukMW67wxL70kQ,42074
|
17
|
-
google/genai/live.py,sha256=xDu1wV8iQ5lI2i4_AmtOQOuiiPXBt6WykV_rXfjb0Sc,23467
|
18
|
-
google/genai/models.py,sha256=guW4WbKmfMT97TW3l4-kJHi7VyncpReceESL-Qi3gTI,178167
|
19
|
-
google/genai/pagers.py,sha256=hSHd-gLvEzYWwK85i8EcFNWUMKtszUs7Nw2r3L7d6_U,6686
|
20
|
-
google/genai/tunings.py,sha256=sZYVy8gJmvMLxYGLVDhASVPNP58ngNVIQb3CWJVTs48,44678
|
21
|
-
google/genai/types.py,sha256=8-gnTJ26SR_d2Gp_QkN2UrfKSCY-dS3LfK0TrCIf9WQ,281176
|
22
|
-
google/genai/version.py,sha256=LyKJKSTJTPOw5Ja9WHJkQfQM6sTw2mTPv4HOr8RUwyk,626
|
23
|
-
google_genai-1.2.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
24
|
-
google_genai-1.2.0.dist-info/METADATA,sha256=4y5cU1W6Xsq2fgBN7n-q1xqpJAyW3YSQR2bOT6sAYqk,26940
|
25
|
-
google_genai-1.2.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
26
|
-
google_genai-1.2.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
27
|
-
google_genai-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|