google-genai 1.31.0__py3-none-any.whl → 1.32.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.
@@ -0,0 +1,26 @@
1
+ # Copyright 2025 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
+ """Base transformers for Google GenAI SDK."""
17
+ import base64
18
+
19
+ # Some fields don't accept url safe base64 encoding.
20
+ # We shouldn't use this transformer if the backend adhere to Cloud Type
21
+ # format https://cloud.google.com/docs/discovery/type-format.
22
+ # TODO(b/389133914,b/390320301): Remove the hack after backend fix the issue.
23
+ def t_bytes(data: bytes) -> str:
24
+ if not isinstance(data, bytes):
25
+ return data
26
+ return base64.b64encode(data).decode('ascii')
@@ -0,0 +1,223 @@
1
+ # Copyright 2025 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
+ import dataclasses
17
+ import functools
18
+ import hashlib
19
+ import os
20
+ import tempfile
21
+ from typing import Optional, cast
22
+ import uuid
23
+
24
+ import requests # type: ignore
25
+ import sentencepiece as spm
26
+ from sentencepiece import sentencepiece_model_pb2
27
+
28
+
29
+ # Source of truth: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models
30
+ _GEMINI_MODELS_TO_TOKENIZER_NAMES = {
31
+ "gemini-1.0-pro": "gemma2",
32
+ "gemini-1.5-pro": "gemma2",
33
+ "gemini-1.5-flash": "gemma2",
34
+ "gemini-2.5-pro": "gemma3",
35
+ "gemini-2.5-flash": "gemma3",
36
+ "gemini-2.5-flash-lite": "gemma3",
37
+ "gemini-2.0-flash": "gemma3",
38
+ "gemini-2.0-flash-lite": "gemma3",
39
+ }
40
+ _GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES = {
41
+ "gemini-1.0-pro-001": "gemma2",
42
+ "gemini-1.0-pro-002": "gemma2",
43
+ "gemini-1.5-pro-001": "gemma2",
44
+ "gemini-1.5-flash-001": "gemma2",
45
+ "gemini-1.5-flash-002": "gemma2",
46
+ "gemini-1.5-pro-002": "gemma2",
47
+ "gemini-2.5-pro-preview-06-05": "gemma3",
48
+ "gemini-2.5-pro-preview-05-06": "gemma3",
49
+ "gemini-2.5-pro-exp-03-25": "gemma3",
50
+ "gemini-live-2.5-flash": "gemma3",
51
+ "gemini-2.5-flash-preview-05-20": "gemma3",
52
+ "gemini-2.5-flash-preview-04-17": "gemma3",
53
+ "gemini-2.5-flash-lite-preview-06-17": "gemma3",
54
+ "gemini-2.0-flash-001": "gemma3",
55
+ "gemini-2.0-flash-lite-001": "gemma3",
56
+ }
57
+
58
+
59
+ @dataclasses.dataclass(frozen=True)
60
+ class _TokenizerConfig:
61
+ model_url: str
62
+ model_hash: str
63
+
64
+
65
+ # TODO: update gemma3 tokenizer
66
+ _TOKENIZERS = {
67
+ "gemma2": _TokenizerConfig(
68
+ model_url="https://raw.githubusercontent.com/google/gemma_pytorch/33b652c465537c6158f9a472ea5700e5e770ad3f/tokenizer/tokenizer.model",
69
+ model_hash=(
70
+ "61a7b147390c64585d6c3543dd6fc636906c9af3865a5548f27f31aee1d4c8e2"
71
+ ),
72
+ ),
73
+ "gemma3": _TokenizerConfig(
74
+ model_url="https://raw.githubusercontent.com/google/gemma_pytorch/014acb7ac4563a5f77c76d7ff98f31b568c16508/tokenizer/gemma3_cleaned_262144_v2.spiece.model",
75
+ model_hash=(
76
+ "1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c"
77
+ ),
78
+ ),
79
+ }
80
+
81
+
82
+ def _load_file(file_url_path: str) -> bytes:
83
+ """Loads file bytes from the given file url path."""
84
+ resp = requests.get(file_url_path)
85
+ resp.raise_for_status()
86
+ return cast(bytes, resp.content)
87
+
88
+
89
+ def _is_valid_model(*, model_data: bytes, expected_hash: str) -> bool:
90
+ """Returns true if the content is valid by checking the hash."""
91
+ if not expected_hash:
92
+ raise ValueError("expected_hash is required")
93
+ return hashlib.sha256(model_data).hexdigest() == expected_hash
94
+
95
+
96
+ def _maybe_remove_file(file_path: str) -> None:
97
+ """Removes the file if exists."""
98
+ if not os.path.exists(file_path):
99
+ return
100
+ try:
101
+ os.remove(file_path)
102
+ except OSError:
103
+ # Don't raise if we cannot remove file.
104
+ pass
105
+
106
+
107
+ def _maybe_load_from_cache(
108
+ *, file_path: str, expected_hash: str
109
+ ) -> Optional[bytes]:
110
+ """Loads the content from the cache path."""
111
+ if not os.path.exists(file_path):
112
+ return None
113
+ with open(file_path, "rb") as f:
114
+ content = f.read()
115
+ if _is_valid_model(model_data=content, expected_hash=expected_hash):
116
+ return content
117
+
118
+ # Cached file corrupted.
119
+ _maybe_remove_file(file_path)
120
+ return None
121
+
122
+
123
+ def _maybe_save_to_cache(
124
+ *, cache_dir: str, cache_path: str, content: bytes
125
+ ) -> None:
126
+ """Saves the content to the cache path."""
127
+ try:
128
+ os.makedirs(cache_dir, exist_ok=True)
129
+ tmp_path = cache_dir + "." + str(uuid.uuid4()) + ".tmp"
130
+ with open(tmp_path, "wb") as f:
131
+ f.write(content)
132
+ os.rename(tmp_path, cache_path)
133
+ except OSError:
134
+ # Don't raise if we cannot write file.
135
+ pass
136
+
137
+
138
+ def _load_from_url(*, file_url: str, expected_hash: str) -> bytes:
139
+ """Loads model bytes from the given file url."""
140
+ content = _load_file(file_url)
141
+ if not _is_valid_model(model_data=content, expected_hash=expected_hash):
142
+ actual_hash = hashlib.sha256(content).hexdigest()
143
+ raise ValueError(
144
+ "Downloaded model file is corrupted."
145
+ f" Expected hash {expected_hash}. Got file hash {actual_hash}."
146
+ )
147
+ return content
148
+
149
+
150
+ def _load(*, file_url: str, expected_hash: str) -> bytes:
151
+ """Loads model bytes from the given file url.
152
+
153
+ 1. If the find local cached file for the given url and the cached file hash
154
+ matches the expected hash, the cached file is returned.
155
+ 2. If local cached file is not found or the hash does not match, the file is
156
+ downloaded from the given url. And write to local cache and return the
157
+ file bytes.
158
+ 3. If the file downloaded from the given url does not match the expected
159
+ hash, raise ValueError.
160
+
161
+ Args:
162
+ file_url: The url of the file to load.
163
+ expected_hash: The expected hash of the file.
164
+
165
+ Returns:
166
+ The file bytes.
167
+ """
168
+ model_dir = os.path.join(tempfile.gettempdir(), "vertexai_tokenizer_model")
169
+ filename = hashlib.sha1(file_url.encode()).hexdigest()
170
+ model_path = os.path.join(model_dir, filename)
171
+
172
+ model_data = _maybe_load_from_cache(
173
+ file_path=model_path, expected_hash=expected_hash
174
+ )
175
+ if not model_data:
176
+ model_data = _load_from_url(file_url=file_url, expected_hash=expected_hash)
177
+
178
+ _maybe_save_to_cache(
179
+ cache_dir=model_dir, cache_path=model_path, content=model_data
180
+ )
181
+ return model_data
182
+
183
+
184
+ def _load_model_proto_bytes(tokenizer_name: str) -> bytes:
185
+ """Loads model proto bytes from the given tokenizer name."""
186
+ if tokenizer_name not in _TOKENIZERS:
187
+ raise ValueError(
188
+ f"Tokenizer {tokenizer_name} is not supported."
189
+ f"Supported tokenizers: {list(_TOKENIZERS.keys())}"
190
+ )
191
+ return _load(
192
+ file_url=_TOKENIZERS[tokenizer_name].model_url,
193
+ expected_hash=_TOKENIZERS[tokenizer_name].model_hash,
194
+ )
195
+
196
+
197
+ @functools.lru_cache()
198
+ def load_model_proto(
199
+ tokenizer_name: str,
200
+ ) -> sentencepiece_model_pb2.ModelProto:
201
+ """Loads model proto from the given tokenizer name."""
202
+ model_proto = sentencepiece_model_pb2.ModelProto()
203
+ model_proto.ParseFromString(_load_model_proto_bytes(tokenizer_name))
204
+ return model_proto
205
+
206
+
207
+ def get_tokenizer_name(model_name: str) -> str:
208
+ """Gets the tokenizer name for the given model name."""
209
+ if model_name in _GEMINI_MODELS_TO_TOKENIZER_NAMES.keys():
210
+ return _GEMINI_MODELS_TO_TOKENIZER_NAMES[model_name]
211
+ if model_name in _GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES.keys():
212
+ return _GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES[model_name]
213
+ raise ValueError(
214
+ f"Model {model_name} is not supported. Supported models: {', '.join(_GEMINI_MODELS_TO_TOKENIZER_NAMES.keys())}, {', '.join(_GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES.keys())}.\n" # pylint: disable=line-too-long
215
+ )
216
+
217
+
218
+ @functools.lru_cache()
219
+ def get_sentencepiece(tokenizer_name: str) -> spm.SentencePieceProcessor:
220
+ """Loads sentencepiece tokenizer from the given tokenizer name."""
221
+ processor = spm.SentencePieceProcessor()
222
+ processor.LoadFromSerializedProto(_load_model_proto_bytes(tokenizer_name))
223
+ return processor
@@ -0,0 +1,307 @@
1
+ # Copyright 2025 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 Any, Optional, Union
19
+ from . import _base_transformers as base_t
20
+ from ._common import get_value_by_path as getv
21
+ from ._common import set_value_by_path as setv
22
+
23
+
24
+ def _FetchPredictOperationParameters_to_mldev(
25
+ from_object: Union[dict[str, Any], object],
26
+ parent_object: Optional[dict[str, Any]] = None,
27
+ ) -> dict[str, Any]:
28
+ to_object: dict[str, Any] = {}
29
+ if getv(from_object, ['operation_name']) is not None:
30
+ raise ValueError('operation_name parameter is not supported in Gemini API.')
31
+
32
+ if getv(from_object, ['resource_name']) is not None:
33
+ raise ValueError('resource_name parameter is not supported in Gemini API.')
34
+
35
+ if getv(from_object, ['config']) is not None:
36
+ raise ValueError('config parameter is not supported in Gemini API.')
37
+
38
+ return to_object
39
+
40
+
41
+ def _GetOperationParameters_to_mldev(
42
+ from_object: Union[dict[str, Any], object],
43
+ parent_object: Optional[dict[str, Any]] = None,
44
+ ) -> dict[str, Any]:
45
+ to_object: dict[str, Any] = {}
46
+ if getv(from_object, ['operation_name']) is not None:
47
+ setv(
48
+ to_object,
49
+ ['_url', 'operationName'],
50
+ getv(from_object, ['operation_name']),
51
+ )
52
+
53
+ if getv(from_object, ['config']) is not None:
54
+ setv(to_object, ['config'], getv(from_object, ['config']))
55
+
56
+ return to_object
57
+
58
+
59
+ def _FetchPredictOperationParameters_to_vertex(
60
+ from_object: Union[dict[str, Any], object],
61
+ parent_object: Optional[dict[str, Any]] = None,
62
+ ) -> dict[str, Any]:
63
+ to_object: dict[str, Any] = {}
64
+ if getv(from_object, ['operation_name']) is not None:
65
+ setv(to_object, ['operationName'], getv(from_object, ['operation_name']))
66
+
67
+ if getv(from_object, ['resource_name']) is not None:
68
+ setv(
69
+ to_object,
70
+ ['_url', 'resourceName'],
71
+ getv(from_object, ['resource_name']),
72
+ )
73
+
74
+ if getv(from_object, ['config']) is not None:
75
+ setv(to_object, ['config'], getv(from_object, ['config']))
76
+
77
+ return to_object
78
+
79
+
80
+ def _GetOperationParameters_to_vertex(
81
+ from_object: Union[dict[str, Any], object],
82
+ parent_object: Optional[dict[str, Any]] = None,
83
+ ) -> dict[str, Any]:
84
+ to_object: dict[str, Any] = {}
85
+ if getv(from_object, ['operation_name']) is not None:
86
+ setv(
87
+ to_object,
88
+ ['_url', 'operationName'],
89
+ getv(from_object, ['operation_name']),
90
+ )
91
+
92
+ if getv(from_object, ['config']) is not None:
93
+ setv(to_object, ['config'], getv(from_object, ['config']))
94
+
95
+ return to_object
96
+
97
+
98
+ def _Video_from_mldev(
99
+ from_object: Union[dict[str, Any], object],
100
+ parent_object: Optional[dict[str, Any]] = None,
101
+ ) -> dict[str, Any]:
102
+ to_object: dict[str, Any] = {}
103
+ if getv(from_object, ['video', 'uri']) is not None:
104
+ setv(to_object, ['uri'], getv(from_object, ['video', 'uri']))
105
+
106
+ if getv(from_object, ['video', 'encodedVideo']) is not None:
107
+ setv(
108
+ to_object,
109
+ ['video_bytes'],
110
+ base_t.t_bytes(getv(from_object, ['video', 'encodedVideo'])),
111
+ )
112
+
113
+ if getv(from_object, ['encoding']) is not None:
114
+ setv(to_object, ['mime_type'], getv(from_object, ['encoding']))
115
+
116
+ return to_object
117
+
118
+
119
+ def _GeneratedVideo_from_mldev(
120
+ from_object: Union[dict[str, Any], object],
121
+ parent_object: Optional[dict[str, Any]] = None,
122
+ ) -> dict[str, Any]:
123
+ to_object: dict[str, Any] = {}
124
+ if getv(from_object, ['_self']) is not None:
125
+ setv(
126
+ to_object,
127
+ ['video'],
128
+ _Video_from_mldev(getv(from_object, ['_self']), to_object),
129
+ )
130
+
131
+ return to_object
132
+
133
+
134
+ def _GenerateVideosResponse_from_mldev(
135
+ from_object: Union[dict[str, Any], object],
136
+ parent_object: Optional[dict[str, Any]] = None,
137
+ ) -> dict[str, Any]:
138
+ to_object: dict[str, Any] = {}
139
+ if getv(from_object, ['generatedSamples']) is not None:
140
+ setv(
141
+ to_object,
142
+ ['generated_videos'],
143
+ [
144
+ _GeneratedVideo_from_mldev(item, to_object)
145
+ for item in getv(from_object, ['generatedSamples'])
146
+ ],
147
+ )
148
+
149
+ if getv(from_object, ['raiMediaFilteredCount']) is not None:
150
+ setv(
151
+ to_object,
152
+ ['rai_media_filtered_count'],
153
+ getv(from_object, ['raiMediaFilteredCount']),
154
+ )
155
+
156
+ if getv(from_object, ['raiMediaFilteredReasons']) is not None:
157
+ setv(
158
+ to_object,
159
+ ['rai_media_filtered_reasons'],
160
+ getv(from_object, ['raiMediaFilteredReasons']),
161
+ )
162
+
163
+ return to_object
164
+
165
+
166
+ def _GenerateVideosOperation_from_mldev(
167
+ from_object: Union[dict[str, Any], object],
168
+ parent_object: Optional[dict[str, Any]] = None,
169
+ ) -> dict[str, Any]:
170
+ to_object: dict[str, Any] = {}
171
+ if getv(from_object, ['name']) is not None:
172
+ setv(to_object, ['name'], getv(from_object, ['name']))
173
+
174
+ if getv(from_object, ['metadata']) is not None:
175
+ setv(to_object, ['metadata'], getv(from_object, ['metadata']))
176
+
177
+ if getv(from_object, ['done']) is not None:
178
+ setv(to_object, ['done'], getv(from_object, ['done']))
179
+
180
+ if getv(from_object, ['error']) is not None:
181
+ setv(to_object, ['error'], getv(from_object, ['error']))
182
+
183
+ if getv(from_object, ['response', 'generateVideoResponse']) is not None:
184
+ setv(
185
+ to_object,
186
+ ['response'],
187
+ _GenerateVideosResponse_from_mldev(
188
+ getv(from_object, ['response', 'generateVideoResponse']), to_object
189
+ ),
190
+ )
191
+
192
+ if getv(from_object, ['response', 'generateVideoResponse']) is not None:
193
+ setv(
194
+ to_object,
195
+ ['result'],
196
+ _GenerateVideosResponse_from_mldev(
197
+ getv(from_object, ['response', 'generateVideoResponse']), to_object
198
+ ),
199
+ )
200
+
201
+ return to_object
202
+
203
+
204
+ def _Video_from_vertex(
205
+ from_object: Union[dict[str, Any], object],
206
+ parent_object: Optional[dict[str, Any]] = None,
207
+ ) -> dict[str, Any]:
208
+ to_object: dict[str, Any] = {}
209
+ if getv(from_object, ['gcsUri']) is not None:
210
+ setv(to_object, ['uri'], getv(from_object, ['gcsUri']))
211
+
212
+ if getv(from_object, ['bytesBase64Encoded']) is not None:
213
+ setv(
214
+ to_object,
215
+ ['video_bytes'],
216
+ base_t.t_bytes(getv(from_object, ['bytesBase64Encoded'])),
217
+ )
218
+
219
+ if getv(from_object, ['mimeType']) is not None:
220
+ setv(to_object, ['mime_type'], getv(from_object, ['mimeType']))
221
+
222
+ return to_object
223
+
224
+
225
+ def _GeneratedVideo_from_vertex(
226
+ from_object: Union[dict[str, Any], object],
227
+ parent_object: Optional[dict[str, Any]] = None,
228
+ ) -> dict[str, Any]:
229
+ to_object: dict[str, Any] = {}
230
+ if getv(from_object, ['_self']) is not None:
231
+ setv(
232
+ to_object,
233
+ ['video'],
234
+ _Video_from_vertex(getv(from_object, ['_self']), to_object),
235
+ )
236
+
237
+ return to_object
238
+
239
+
240
+ def _GenerateVideosResponse_from_vertex(
241
+ from_object: Union[dict[str, Any], object],
242
+ parent_object: Optional[dict[str, Any]] = None,
243
+ ) -> dict[str, Any]:
244
+ to_object: dict[str, Any] = {}
245
+ if getv(from_object, ['videos']) is not None:
246
+ setv(
247
+ to_object,
248
+ ['generated_videos'],
249
+ [
250
+ _GeneratedVideo_from_vertex(item, to_object)
251
+ for item in getv(from_object, ['videos'])
252
+ ],
253
+ )
254
+
255
+ if getv(from_object, ['raiMediaFilteredCount']) is not None:
256
+ setv(
257
+ to_object,
258
+ ['rai_media_filtered_count'],
259
+ getv(from_object, ['raiMediaFilteredCount']),
260
+ )
261
+
262
+ if getv(from_object, ['raiMediaFilteredReasons']) is not None:
263
+ setv(
264
+ to_object,
265
+ ['rai_media_filtered_reasons'],
266
+ getv(from_object, ['raiMediaFilteredReasons']),
267
+ )
268
+
269
+ return to_object
270
+
271
+
272
+ def _GenerateVideosOperation_from_vertex(
273
+ from_object: Union[dict[str, Any], object],
274
+ parent_object: Optional[dict[str, Any]] = None,
275
+ ) -> dict[str, Any]:
276
+ to_object: dict[str, Any] = {}
277
+ if getv(from_object, ['name']) is not None:
278
+ setv(to_object, ['name'], getv(from_object, ['name']))
279
+
280
+ if getv(from_object, ['metadata']) is not None:
281
+ setv(to_object, ['metadata'], getv(from_object, ['metadata']))
282
+
283
+ if getv(from_object, ['done']) is not None:
284
+ setv(to_object, ['done'], getv(from_object, ['done']))
285
+
286
+ if getv(from_object, ['error']) is not None:
287
+ setv(to_object, ['error'], getv(from_object, ['error']))
288
+
289
+ if getv(from_object, ['response']) is not None:
290
+ setv(
291
+ to_object,
292
+ ['response'],
293
+ _GenerateVideosResponse_from_vertex(
294
+ getv(from_object, ['response']), to_object
295
+ ),
296
+ )
297
+
298
+ if getv(from_object, ['response']) is not None:
299
+ setv(
300
+ to_object,
301
+ ['result'],
302
+ _GenerateVideosResponse_from_vertex(
303
+ getv(from_object, ['response']), to_object
304
+ ),
305
+ )
306
+
307
+ return to_object
@@ -1156,16 +1156,6 @@ def t_tuning_job_status(status: str) -> Union[types.JobState, str]:
1156
1156
  return status
1157
1157
 
1158
1158
 
1159
- # Some fields don't accept url safe base64 encoding.
1160
- # We shouldn't use this transformer if the backend adhere to Cloud Type
1161
- # format https://cloud.google.com/docs/discovery/type-format.
1162
- # TODO(b/389133914,b/390320301): Remove the hack after backend fix the issue.
1163
- def t_bytes(data: bytes) -> str:
1164
- if not isinstance(data, bytes):
1165
- return data
1166
- return base64.b64encode(data).decode('ascii')
1167
-
1168
-
1169
1159
  def t_content_strict(content: types.ContentOrDict) -> types.Content:
1170
1160
  if isinstance(content, dict):
1171
1161
  return types.Content.model_validate(content)
google/genai/caches.py CHANGED
@@ -1363,6 +1363,10 @@ def _DeleteCachedContentResponse_from_mldev(
1363
1363
  parent_object: Optional[dict[str, Any]] = None,
1364
1364
  ) -> dict[str, Any]:
1365
1365
  to_object: dict[str, Any] = {}
1366
+ if getv(from_object, ['sdkHttpResponse']) is not None:
1367
+ setv(
1368
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1369
+ )
1366
1370
 
1367
1371
  return to_object
1368
1372
 
@@ -1427,6 +1431,10 @@ def _DeleteCachedContentResponse_from_vertex(
1427
1431
  parent_object: Optional[dict[str, Any]] = None,
1428
1432
  ) -> dict[str, Any]:
1429
1433
  to_object: dict[str, Any] = {}
1434
+ if getv(from_object, ['sdkHttpResponse']) is not None:
1435
+ setv(
1436
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
1437
+ )
1430
1438
 
1431
1439
  return to_object
1432
1440
 
@@ -1685,7 +1693,9 @@ class Caches(_api_module.BaseModule):
1685
1693
  return_value = types.DeleteCachedContentResponse._from_response(
1686
1694
  response=response_dict, kwargs=parameter_model.model_dump()
1687
1695
  )
1688
-
1696
+ return_value.sdk_http_response = types.HttpResponse(
1697
+ headers=response.headers
1698
+ )
1689
1699
  self._api_client._verify_response(return_value)
1690
1700
  return return_value
1691
1701
 
@@ -2077,7 +2087,9 @@ class AsyncCaches(_api_module.BaseModule):
2077
2087
  return_value = types.DeleteCachedContentResponse._from_response(
2078
2088
  response=response_dict, kwargs=parameter_model.model_dump()
2079
2089
  )
2080
-
2090
+ return_value.sdk_http_response = types.HttpResponse(
2091
+ headers=response.headers
2092
+ )
2081
2093
  self._api_client._verify_response(return_value)
2082
2094
  return return_value
2083
2095
 
google/genai/files.py CHANGED
@@ -307,6 +307,10 @@ def _DeleteFileResponse_from_mldev(
307
307
  parent_object: Optional[dict[str, Any]] = None,
308
308
  ) -> dict[str, Any]:
309
309
  to_object: dict[str, Any] = {}
310
+ if getv(from_object, ['sdkHttpResponse']) is not None:
311
+ setv(
312
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
313
+ )
310
314
 
311
315
  return to_object
312
316
 
@@ -577,7 +581,9 @@ class Files(_api_module.BaseModule):
577
581
  return_value = types.DeleteFileResponse._from_response(
578
582
  response=response_dict, kwargs=parameter_model.model_dump()
579
583
  )
580
-
584
+ return_value.sdk_http_response = types.HttpResponse(
585
+ headers=response.headers
586
+ )
581
587
  self._api_client._verify_response(return_value)
582
588
  return return_value
583
589
 
@@ -1059,7 +1065,9 @@ class AsyncFiles(_api_module.BaseModule):
1059
1065
  return_value = types.DeleteFileResponse._from_response(
1060
1066
  response=response_dict, kwargs=parameter_model.model_dump()
1061
1067
  )
1062
-
1068
+ return_value.sdk_http_response = types.HttpResponse(
1069
+ headers=response.headers
1070
+ )
1063
1071
  self._api_client._verify_response(return_value)
1064
1072
  return return_value
1065
1073