google-genai 1.56.0__py3-none-any.whl → 1.58.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.
Files changed (246) hide show
  1. google/genai/_api_client.py +49 -26
  2. google/genai/_interactions/__init__.py +3 -0
  3. google/genai/_interactions/_base_client.py +1 -1
  4. google/genai/_interactions/_client.py +57 -3
  5. google/genai/_interactions/_client_adapter.py +48 -0
  6. google/genai/_interactions/types/__init__.py +6 -0
  7. google/genai/_interactions/types/audio_content.py +2 -0
  8. google/genai/_interactions/types/audio_content_param.py +2 -0
  9. google/genai/_interactions/types/content.py +65 -0
  10. google/genai/_interactions/types/content_delta.py +10 -2
  11. google/genai/_interactions/types/content_param.py +63 -0
  12. google/genai/_interactions/types/content_start.py +5 -46
  13. google/genai/_interactions/types/content_stop.py +1 -2
  14. google/genai/_interactions/types/document_content.py +2 -0
  15. google/genai/_interactions/types/document_content_param.py +2 -0
  16. google/genai/_interactions/types/error_event.py +1 -2
  17. google/genai/_interactions/types/file_search_call_content.py +32 -0
  18. google/genai/_interactions/types/file_search_call_content_param.py +31 -0
  19. google/genai/_interactions/types/generation_config.py +4 -0
  20. google/genai/_interactions/types/generation_config_param.py +4 -0
  21. google/genai/_interactions/types/image_config.py +31 -0
  22. google/genai/_interactions/types/image_config_param.py +30 -0
  23. google/genai/_interactions/types/image_content.py +2 -0
  24. google/genai/_interactions/types/image_content_param.py +2 -0
  25. google/genai/_interactions/types/interaction.py +6 -52
  26. google/genai/_interactions/types/interaction_create_params.py +4 -22
  27. google/genai/_interactions/types/interaction_event.py +1 -2
  28. google/genai/_interactions/types/interaction_sse_event.py +5 -3
  29. google/genai/_interactions/types/interaction_status_update.py +1 -2
  30. google/genai/_interactions/types/model.py +1 -0
  31. google/genai/_interactions/types/model_param.py +1 -0
  32. google/genai/_interactions/types/turn.py +3 -44
  33. google/genai/_interactions/types/turn_param.py +4 -40
  34. google/genai/_interactions/types/usage.py +1 -1
  35. google/genai/_interactions/types/usage_param.py +1 -1
  36. google/genai/_interactions/types/video_content.py +2 -0
  37. google/genai/_interactions/types/video_content_param.py +2 -0
  38. google/genai/_live_converters.py +118 -34
  39. google/genai/_local_tokenizer_loader.py +1 -0
  40. google/genai/_tokens_converters.py +14 -14
  41. google/genai/_transformers.py +15 -21
  42. google/genai/batches.py +27 -22
  43. google/genai/caches.py +42 -42
  44. google/genai/chats.py +0 -2
  45. google/genai/client.py +61 -55
  46. google/genai/files.py +224 -0
  47. google/genai/live.py +1 -1
  48. google/genai/models.py +56 -44
  49. google/genai/tests/__init__.py +21 -0
  50. google/genai/tests/afc/__init__.py +21 -0
  51. google/genai/tests/afc/test_convert_if_exist_pydantic_model.py +309 -0
  52. google/genai/tests/afc/test_convert_number_values_for_function_call_args.py +63 -0
  53. google/genai/tests/afc/test_find_afc_incompatible_tool_indexes.py +240 -0
  54. google/genai/tests/afc/test_generate_content_stream_afc.py +530 -0
  55. google/genai/tests/afc/test_generate_content_stream_afc_thoughts.py +77 -0
  56. google/genai/tests/afc/test_get_function_map.py +176 -0
  57. google/genai/tests/afc/test_get_function_response_parts.py +277 -0
  58. google/genai/tests/afc/test_get_max_remote_calls_for_afc.py +130 -0
  59. google/genai/tests/afc/test_invoke_function_from_dict_args.py +241 -0
  60. google/genai/tests/afc/test_raise_error_for_afc_incompatible_config.py +159 -0
  61. google/genai/tests/afc/test_should_append_afc_history.py +53 -0
  62. google/genai/tests/afc/test_should_disable_afc.py +214 -0
  63. google/genai/tests/batches/__init__.py +17 -0
  64. google/genai/tests/batches/test_cancel.py +77 -0
  65. google/genai/tests/batches/test_create.py +78 -0
  66. google/genai/tests/batches/test_create_with_bigquery.py +113 -0
  67. google/genai/tests/batches/test_create_with_file.py +82 -0
  68. google/genai/tests/batches/test_create_with_gcs.py +125 -0
  69. google/genai/tests/batches/test_create_with_inlined_requests.py +255 -0
  70. google/genai/tests/batches/test_delete.py +86 -0
  71. google/genai/tests/batches/test_embedding.py +157 -0
  72. google/genai/tests/batches/test_get.py +78 -0
  73. google/genai/tests/batches/test_list.py +79 -0
  74. google/genai/tests/caches/__init__.py +17 -0
  75. google/genai/tests/caches/constants.py +29 -0
  76. google/genai/tests/caches/test_create.py +210 -0
  77. google/genai/tests/caches/test_create_custom_url.py +105 -0
  78. google/genai/tests/caches/test_delete.py +54 -0
  79. google/genai/tests/caches/test_delete_custom_url.py +52 -0
  80. google/genai/tests/caches/test_get.py +94 -0
  81. google/genai/tests/caches/test_get_custom_url.py +52 -0
  82. google/genai/tests/caches/test_list.py +68 -0
  83. google/genai/tests/caches/test_update.py +70 -0
  84. google/genai/tests/caches/test_update_custom_url.py +58 -0
  85. google/genai/tests/chats/__init__.py +1 -0
  86. google/genai/tests/chats/test_get_history.py +598 -0
  87. google/genai/tests/chats/test_send_message.py +844 -0
  88. google/genai/tests/chats/test_validate_response.py +90 -0
  89. google/genai/tests/client/__init__.py +17 -0
  90. google/genai/tests/client/test_async_stream.py +427 -0
  91. google/genai/tests/client/test_client_close.py +197 -0
  92. google/genai/tests/client/test_client_initialization.py +1687 -0
  93. google/genai/tests/client/test_client_requests.py +221 -0
  94. google/genai/tests/client/test_custom_client.py +104 -0
  95. google/genai/tests/client/test_http_options.py +178 -0
  96. google/genai/tests/client/test_replay_client_equality.py +168 -0
  97. google/genai/tests/client/test_retries.py +846 -0
  98. google/genai/tests/client/test_upload_errors.py +136 -0
  99. google/genai/tests/common/__init__.py +17 -0
  100. google/genai/tests/common/test_common.py +954 -0
  101. google/genai/tests/conftest.py +162 -0
  102. google/genai/tests/documents/__init__.py +17 -0
  103. google/genai/tests/documents/test_delete.py +51 -0
  104. google/genai/tests/documents/test_get.py +85 -0
  105. google/genai/tests/documents/test_list.py +72 -0
  106. google/genai/tests/errors/__init__.py +1 -0
  107. google/genai/tests/errors/test_api_error.py +417 -0
  108. google/genai/tests/file_search_stores/__init__.py +17 -0
  109. google/genai/tests/file_search_stores/test_create.py +66 -0
  110. google/genai/tests/file_search_stores/test_delete.py +64 -0
  111. google/genai/tests/file_search_stores/test_get.py +94 -0
  112. google/genai/tests/file_search_stores/test_import_file.py +112 -0
  113. google/genai/tests/file_search_stores/test_list.py +57 -0
  114. google/genai/tests/file_search_stores/test_upload_to_file_search_store.py +141 -0
  115. google/genai/tests/files/__init__.py +17 -0
  116. google/genai/tests/files/test_delete.py +46 -0
  117. google/genai/tests/files/test_download.py +85 -0
  118. google/genai/tests/files/test_get.py +46 -0
  119. google/genai/tests/files/test_list.py +72 -0
  120. google/genai/tests/files/test_register.py +272 -0
  121. google/genai/tests/files/test_register_table.py +70 -0
  122. google/genai/tests/files/test_upload.py +255 -0
  123. google/genai/tests/imports/test_no_optional_imports.py +28 -0
  124. google/genai/tests/interactions/test_auth.py +476 -0
  125. google/genai/tests/interactions/test_integration.py +84 -0
  126. google/genai/tests/interactions/test_paths.py +105 -0
  127. google/genai/tests/live/__init__.py +16 -0
  128. google/genai/tests/live/test_live.py +2143 -0
  129. google/genai/tests/live/test_live_music.py +362 -0
  130. google/genai/tests/live/test_live_response.py +163 -0
  131. google/genai/tests/live/test_send_client_content.py +147 -0
  132. google/genai/tests/live/test_send_realtime_input.py +268 -0
  133. google/genai/tests/live/test_send_tool_response.py +222 -0
  134. google/genai/tests/local_tokenizer/__init__.py +17 -0
  135. google/genai/tests/local_tokenizer/test_local_tokenizer.py +343 -0
  136. google/genai/tests/local_tokenizer/test_local_tokenizer_loader.py +235 -0
  137. google/genai/tests/mcp/__init__.py +17 -0
  138. google/genai/tests/mcp/test_has_mcp_tool_usage.py +89 -0
  139. google/genai/tests/mcp/test_mcp_to_gemini_tools.py +191 -0
  140. google/genai/tests/mcp/test_parse_config_for_mcp_sessions.py +201 -0
  141. google/genai/tests/mcp/test_parse_config_for_mcp_usage.py +130 -0
  142. google/genai/tests/mcp/test_set_mcp_usage_header.py +72 -0
  143. google/genai/tests/models/__init__.py +17 -0
  144. google/genai/tests/models/constants.py +8 -0
  145. google/genai/tests/models/test_compute_tokens.py +120 -0
  146. google/genai/tests/models/test_count_tokens.py +159 -0
  147. google/genai/tests/models/test_delete.py +107 -0
  148. google/genai/tests/models/test_edit_image.py +264 -0
  149. google/genai/tests/models/test_embed_content.py +94 -0
  150. google/genai/tests/models/test_function_call_streaming.py +442 -0
  151. google/genai/tests/models/test_generate_content.py +2501 -0
  152. google/genai/tests/models/test_generate_content_cached_content.py +132 -0
  153. google/genai/tests/models/test_generate_content_config_zero_value.py +103 -0
  154. google/genai/tests/models/test_generate_content_from_apikey.py +44 -0
  155. google/genai/tests/models/test_generate_content_http_options.py +40 -0
  156. google/genai/tests/models/test_generate_content_image_generation.py +143 -0
  157. google/genai/tests/models/test_generate_content_mcp.py +343 -0
  158. google/genai/tests/models/test_generate_content_media_resolution.py +97 -0
  159. google/genai/tests/models/test_generate_content_model.py +139 -0
  160. google/genai/tests/models/test_generate_content_part.py +821 -0
  161. google/genai/tests/models/test_generate_content_thought.py +76 -0
  162. google/genai/tests/models/test_generate_content_tools.py +1761 -0
  163. google/genai/tests/models/test_generate_images.py +191 -0
  164. google/genai/tests/models/test_generate_videos.py +759 -0
  165. google/genai/tests/models/test_get.py +104 -0
  166. google/genai/tests/models/test_list.py +233 -0
  167. google/genai/tests/models/test_recontext_image.py +189 -0
  168. google/genai/tests/models/test_segment_image.py +148 -0
  169. google/genai/tests/models/test_update.py +95 -0
  170. google/genai/tests/models/test_upscale_image.py +157 -0
  171. google/genai/tests/operations/__init__.py +17 -0
  172. google/genai/tests/operations/test_get.py +38 -0
  173. google/genai/tests/public_samples/__init__.py +17 -0
  174. google/genai/tests/public_samples/test_gemini_text_only.py +34 -0
  175. google/genai/tests/pytest_helper.py +246 -0
  176. google/genai/tests/shared/__init__.py +16 -0
  177. google/genai/tests/shared/batches/__init__.py +14 -0
  178. google/genai/tests/shared/batches/test_create_delete.py +57 -0
  179. google/genai/tests/shared/batches/test_create_get_cancel.py +56 -0
  180. google/genai/tests/shared/batches/test_list.py +40 -0
  181. google/genai/tests/shared/caches/__init__.py +14 -0
  182. google/genai/tests/shared/caches/test_create_get_delete.py +67 -0
  183. google/genai/tests/shared/caches/test_create_update_get.py +71 -0
  184. google/genai/tests/shared/caches/test_list.py +40 -0
  185. google/genai/tests/shared/chats/__init__.py +14 -0
  186. google/genai/tests/shared/chats/test_send_message.py +48 -0
  187. google/genai/tests/shared/chats/test_send_message_stream.py +50 -0
  188. google/genai/tests/shared/files/__init__.py +14 -0
  189. google/genai/tests/shared/files/test_list.py +41 -0
  190. google/genai/tests/shared/files/test_upload_get_delete.py +54 -0
  191. google/genai/tests/shared/models/__init__.py +14 -0
  192. google/genai/tests/shared/models/test_compute_tokens.py +41 -0
  193. google/genai/tests/shared/models/test_count_tokens.py +40 -0
  194. google/genai/tests/shared/models/test_edit_image.py +67 -0
  195. google/genai/tests/shared/models/test_embed.py +40 -0
  196. google/genai/tests/shared/models/test_generate_content.py +39 -0
  197. google/genai/tests/shared/models/test_generate_content_stream.py +54 -0
  198. google/genai/tests/shared/models/test_generate_images.py +40 -0
  199. google/genai/tests/shared/models/test_generate_videos.py +38 -0
  200. google/genai/tests/shared/models/test_list.py +37 -0
  201. google/genai/tests/shared/models/test_recontext_image.py +55 -0
  202. google/genai/tests/shared/models/test_segment_image.py +52 -0
  203. google/genai/tests/shared/models/test_upscale_image.py +52 -0
  204. google/genai/tests/shared/tunings/__init__.py +16 -0
  205. google/genai/tests/shared/tunings/test_create.py +46 -0
  206. google/genai/tests/shared/tunings/test_create_get_cancel.py +56 -0
  207. google/genai/tests/shared/tunings/test_list.py +39 -0
  208. google/genai/tests/tokens/__init__.py +16 -0
  209. google/genai/tests/tokens/test_create.py +154 -0
  210. google/genai/tests/transformers/__init__.py +17 -0
  211. google/genai/tests/transformers/test_blobs.py +84 -0
  212. google/genai/tests/transformers/test_bytes.py +15 -0
  213. google/genai/tests/transformers/test_duck_type.py +96 -0
  214. google/genai/tests/transformers/test_function_responses.py +72 -0
  215. google/genai/tests/transformers/test_schema.py +653 -0
  216. google/genai/tests/transformers/test_t_batch.py +286 -0
  217. google/genai/tests/transformers/test_t_content.py +160 -0
  218. google/genai/tests/transformers/test_t_contents.py +398 -0
  219. google/genai/tests/transformers/test_t_part.py +85 -0
  220. google/genai/tests/transformers/test_t_parts.py +87 -0
  221. google/genai/tests/transformers/test_t_tool.py +157 -0
  222. google/genai/tests/transformers/test_t_tools.py +195 -0
  223. google/genai/tests/tunings/__init__.py +16 -0
  224. google/genai/tests/tunings/test_cancel.py +39 -0
  225. google/genai/tests/tunings/test_end_to_end.py +106 -0
  226. google/genai/tests/tunings/test_get.py +67 -0
  227. google/genai/tests/tunings/test_list.py +75 -0
  228. google/genai/tests/tunings/test_tune.py +268 -0
  229. google/genai/tests/types/__init__.py +16 -0
  230. google/genai/tests/types/test_bytes_internal.py +271 -0
  231. google/genai/tests/types/test_bytes_type.py +152 -0
  232. google/genai/tests/types/test_future.py +101 -0
  233. google/genai/tests/types/test_optional_types.py +36 -0
  234. google/genai/tests/types/test_part_type.py +616 -0
  235. google/genai/tests/types/test_schema_from_json_schema.py +417 -0
  236. google/genai/tests/types/test_schema_json_schema.py +468 -0
  237. google/genai/tests/types/test_types.py +2903 -0
  238. google/genai/types.py +631 -488
  239. google/genai/version.py +1 -1
  240. {google_genai-1.56.0.dist-info → google_genai-1.58.0.dist-info}/METADATA +6 -11
  241. google_genai-1.58.0.dist-info/RECORD +358 -0
  242. google_genai-1.56.0.dist-info/RECORD +0 -162
  243. /google/genai/{_interactions/py.typed → tests/interactions/__init__.py} +0 -0
  244. {google_genai-1.56.0.dist-info → google_genai-1.58.0.dist-info}/WHEEL +0 -0
  245. {google_genai-1.56.0.dist-info → google_genai-1.58.0.dist-info}/licenses/LICENSE +0 -0
  246. {google_genai-1.56.0.dist-info → google_genai-1.58.0.dist-info}/top_level.txt +0 -0
@@ -106,9 +106,6 @@ def _FunctionDeclaration_to_vertex(
106
106
  parent_object: Optional[dict[str, Any]] = None,
107
107
  ) -> dict[str, Any]:
108
108
  to_object: dict[str, Any] = {}
109
- if getv(from_object, ['behavior']) is not None:
110
- raise ValueError('behavior parameter is not supported in Vertex AI.')
111
-
112
109
  if getv(from_object, ['description']) is not None:
113
110
  setv(to_object, ['description'], getv(from_object, ['description']))
114
111
 
@@ -135,6 +132,9 @@ def _FunctionDeclaration_to_vertex(
135
132
  getv(from_object, ['response_json_schema']),
136
133
  )
137
134
 
135
+ if getv(from_object, ['behavior']) is not None:
136
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
137
+
138
138
  return to_object
139
139
 
140
140
 
@@ -1151,6 +1151,59 @@ def _LiveSendRealtimeInputParameters_to_vertex(
1151
1151
  return to_object
1152
1152
 
1153
1153
 
1154
+ def _LiveServerMessage_from_mldev(
1155
+ from_object: Union[dict[str, Any], object],
1156
+ parent_object: Optional[dict[str, Any]] = None,
1157
+ ) -> dict[str, Any]:
1158
+ to_object: dict[str, Any] = {}
1159
+ if getv(from_object, ['setupComplete']) is not None:
1160
+ setv(to_object, ['setup_complete'], getv(from_object, ['setupComplete']))
1161
+
1162
+ if getv(from_object, ['serverContent']) is not None:
1163
+ setv(to_object, ['server_content'], getv(from_object, ['serverContent']))
1164
+
1165
+ if getv(from_object, ['toolCall']) is not None:
1166
+ setv(to_object, ['tool_call'], getv(from_object, ['toolCall']))
1167
+
1168
+ if getv(from_object, ['toolCallCancellation']) is not None:
1169
+ setv(
1170
+ to_object,
1171
+ ['tool_call_cancellation'],
1172
+ getv(from_object, ['toolCallCancellation']),
1173
+ )
1174
+
1175
+ if getv(from_object, ['usageMetadata']) is not None:
1176
+ setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
1177
+
1178
+ if getv(from_object, ['goAway']) is not None:
1179
+ setv(to_object, ['go_away'], getv(from_object, ['goAway']))
1180
+
1181
+ if getv(from_object, ['sessionResumptionUpdate']) is not None:
1182
+ setv(
1183
+ to_object,
1184
+ ['session_resumption_update'],
1185
+ getv(from_object, ['sessionResumptionUpdate']),
1186
+ )
1187
+
1188
+ if getv(from_object, ['voiceActivityDetectionSignal']) is not None:
1189
+ setv(
1190
+ to_object,
1191
+ ['voice_activity_detection_signal'],
1192
+ getv(from_object, ['voiceActivityDetectionSignal']),
1193
+ )
1194
+
1195
+ if getv(from_object, ['voiceActivity']) is not None:
1196
+ setv(
1197
+ to_object,
1198
+ ['voice_activity'],
1199
+ _VoiceActivity_from_mldev(
1200
+ getv(from_object, ['voiceActivity']), to_object
1201
+ ),
1202
+ )
1203
+
1204
+ return to_object
1205
+
1206
+
1154
1207
  def _LiveServerMessage_from_vertex(
1155
1208
  from_object: Union[dict[str, Any], object],
1156
1209
  parent_object: Optional[dict[str, Any]] = None,
@@ -1198,6 +1251,15 @@ def _LiveServerMessage_from_vertex(
1198
1251
  getv(from_object, ['voiceActivityDetectionSignal']),
1199
1252
  )
1200
1253
 
1254
+ if getv(from_object, ['voiceActivity']) is not None:
1255
+ setv(
1256
+ to_object,
1257
+ ['voice_activity'],
1258
+ _VoiceActivity_from_vertex(
1259
+ getv(from_object, ['voiceActivity']), to_object
1260
+ ),
1261
+ )
1262
+
1201
1263
  return to_object
1202
1264
 
1203
1265
 
@@ -1287,23 +1349,9 @@ def _Tool_to_mldev(
1287
1349
  parent_object: Optional[dict[str, Any]] = None,
1288
1350
  ) -> dict[str, Any]:
1289
1351
  to_object: dict[str, Any] = {}
1290
- if getv(from_object, ['function_declarations']) is not None:
1291
- setv(
1292
- to_object,
1293
- ['functionDeclarations'],
1294
- [item for item in getv(from_object, ['function_declarations'])],
1295
- )
1296
-
1297
1352
  if getv(from_object, ['retrieval']) is not None:
1298
1353
  raise ValueError('retrieval parameter is not supported in Gemini API.')
1299
1354
 
1300
- if getv(from_object, ['google_search_retrieval']) is not None:
1301
- setv(
1302
- to_object,
1303
- ['googleSearchRetrieval'],
1304
- getv(from_object, ['google_search_retrieval']),
1305
- )
1306
-
1307
1355
  if getv(from_object, ['computer_use']) is not None:
1308
1356
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1309
1357
 
@@ -1318,6 +1366,13 @@ def _Tool_to_mldev(
1318
1366
  'enterprise_web_search parameter is not supported in Gemini API.'
1319
1367
  )
1320
1368
 
1369
+ if getv(from_object, ['function_declarations']) is not None:
1370
+ setv(
1371
+ to_object,
1372
+ ['functionDeclarations'],
1373
+ [item for item in getv(from_object, ['function_declarations'])],
1374
+ )
1375
+
1321
1376
  if getv(from_object, ['google_maps']) is not None:
1322
1377
  setv(
1323
1378
  to_object,
@@ -1332,6 +1387,13 @@ def _Tool_to_mldev(
1332
1387
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1333
1388
  )
1334
1389
 
1390
+ if getv(from_object, ['google_search_retrieval']) is not None:
1391
+ setv(
1392
+ to_object,
1393
+ ['googleSearchRetrieval'],
1394
+ getv(from_object, ['google_search_retrieval']),
1395
+ )
1396
+
1335
1397
  if getv(from_object, ['url_context']) is not None:
1336
1398
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1337
1399
 
@@ -1343,26 +1405,9 @@ def _Tool_to_vertex(
1343
1405
  parent_object: Optional[dict[str, Any]] = None,
1344
1406
  ) -> dict[str, Any]:
1345
1407
  to_object: dict[str, Any] = {}
1346
- if getv(from_object, ['function_declarations']) is not None:
1347
- setv(
1348
- to_object,
1349
- ['functionDeclarations'],
1350
- [
1351
- _FunctionDeclaration_to_vertex(item, to_object)
1352
- for item in getv(from_object, ['function_declarations'])
1353
- ],
1354
- )
1355
-
1356
1408
  if getv(from_object, ['retrieval']) is not None:
1357
1409
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
1358
1410
 
1359
- if getv(from_object, ['google_search_retrieval']) is not None:
1360
- setv(
1361
- to_object,
1362
- ['googleSearchRetrieval'],
1363
- getv(from_object, ['google_search_retrieval']),
1364
- )
1365
-
1366
1411
  if getv(from_object, ['computer_use']) is not None:
1367
1412
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1368
1413
 
@@ -1379,12 +1424,29 @@ def _Tool_to_vertex(
1379
1424
  getv(from_object, ['enterprise_web_search']),
1380
1425
  )
1381
1426
 
1427
+ if getv(from_object, ['function_declarations']) is not None:
1428
+ setv(
1429
+ to_object,
1430
+ ['functionDeclarations'],
1431
+ [
1432
+ _FunctionDeclaration_to_vertex(item, to_object)
1433
+ for item in getv(from_object, ['function_declarations'])
1434
+ ],
1435
+ )
1436
+
1382
1437
  if getv(from_object, ['google_maps']) is not None:
1383
1438
  setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1384
1439
 
1385
1440
  if getv(from_object, ['google_search']) is not None:
1386
1441
  setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
1387
1442
 
1443
+ if getv(from_object, ['google_search_retrieval']) is not None:
1444
+ setv(
1445
+ to_object,
1446
+ ['googleSearchRetrieval'],
1447
+ getv(from_object, ['google_search_retrieval']),
1448
+ )
1449
+
1388
1450
  if getv(from_object, ['url_context']) is not None:
1389
1451
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1390
1452
 
@@ -1468,3 +1530,25 @@ def _UsageMetadata_from_vertex(
1468
1530
  setv(to_object, ['traffic_type'], getv(from_object, ['trafficType']))
1469
1531
 
1470
1532
  return to_object
1533
+
1534
+
1535
+ def _VoiceActivity_from_mldev(
1536
+ from_object: Union[dict[str, Any], object],
1537
+ parent_object: Optional[dict[str, Any]] = None,
1538
+ ) -> dict[str, Any]:
1539
+ to_object: dict[str, Any] = {}
1540
+ if getv(from_object, ['type']) is not None:
1541
+ setv(to_object, ['voice_activity_type'], getv(from_object, ['type']))
1542
+
1543
+ return to_object
1544
+
1545
+
1546
+ def _VoiceActivity_from_vertex(
1547
+ from_object: Union[dict[str, Any], object],
1548
+ parent_object: Optional[dict[str, Any]] = None,
1549
+ ) -> dict[str, Any]:
1550
+ to_object: dict[str, Any] = {}
1551
+ if getv(from_object, ['type']) is not None:
1552
+ setv(to_object, ['voice_activity_type'], getv(from_object, ['type']))
1553
+
1554
+ return to_object
@@ -44,6 +44,7 @@ _GEMINI_STABLE_MODELS_TO_TOKENIZER_NAMES = {
44
44
  "gemini-2.5-flash-lite-preview-06-17": "gemma3",
45
45
  "gemini-2.0-flash-001": "gemma3",
46
46
  "gemini-2.0-flash-lite-001": "gemma3",
47
+ "gemini-3-pro-preview": "gemma3",
47
48
  }
48
49
 
49
50
 
@@ -474,23 +474,9 @@ def _Tool_to_mldev(
474
474
  parent_object: Optional[dict[str, Any]] = None,
475
475
  ) -> dict[str, Any]:
476
476
  to_object: dict[str, Any] = {}
477
- if getv(from_object, ['function_declarations']) is not None:
478
- setv(
479
- to_object,
480
- ['functionDeclarations'],
481
- [item for item in getv(from_object, ['function_declarations'])],
482
- )
483
-
484
477
  if getv(from_object, ['retrieval']) is not None:
485
478
  raise ValueError('retrieval parameter is not supported in Gemini API.')
486
479
 
487
- if getv(from_object, ['google_search_retrieval']) is not None:
488
- setv(
489
- to_object,
490
- ['googleSearchRetrieval'],
491
- getv(from_object, ['google_search_retrieval']),
492
- )
493
-
494
480
  if getv(from_object, ['computer_use']) is not None:
495
481
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
496
482
 
@@ -505,6 +491,13 @@ def _Tool_to_mldev(
505
491
  'enterprise_web_search parameter is not supported in Gemini API.'
506
492
  )
507
493
 
494
+ if getv(from_object, ['function_declarations']) is not None:
495
+ setv(
496
+ to_object,
497
+ ['functionDeclarations'],
498
+ [item for item in getv(from_object, ['function_declarations'])],
499
+ )
500
+
508
501
  if getv(from_object, ['google_maps']) is not None:
509
502
  setv(
510
503
  to_object,
@@ -519,6 +512,13 @@ def _Tool_to_mldev(
519
512
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
520
513
  )
521
514
 
515
+ if getv(from_object, ['google_search_retrieval']) is not None:
516
+ setv(
517
+ to_object,
518
+ ['googleSearchRetrieval'],
519
+ getv(from_object, ['google_search_retrieval']),
520
+ )
521
+
522
522
  if getv(from_object, ['url_context']) is not None:
523
523
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
524
524
 
@@ -285,29 +285,23 @@ def t_caches_model(
285
285
  return model
286
286
 
287
287
 
288
- def pil_to_blob(img: Any) -> types.Blob:
289
- PngImagePlugin: Optional[builtin_types.ModuleType]
290
- try:
291
- import PIL.PngImagePlugin
292
-
293
- PngImagePlugin = PIL.PngImagePlugin
294
- except ImportError:
295
- PngImagePlugin = None
296
-
297
- bytesio = io.BytesIO()
288
+ def pil_to_blob(image: Any) -> types.Blob:
289
+ image_format = 'PNG'
290
+ save_params: dict[str, Any] = dict()
298
291
  if (
299
- PngImagePlugin is not None
300
- and isinstance(img, PngImagePlugin.PngImageFile)
301
- or img.mode == 'RGBA'
292
+ image.format == 'JPEG'
293
+ and getattr(image, 'filename', '')
294
+ and image.mode in ['1', 'L', 'RGB', 'RGBX', 'CMYK']
302
295
  ):
303
- img.save(bytesio, format='PNG')
304
- mime_type = 'image/png'
305
- else:
306
- img.save(bytesio, format='JPEG')
307
- mime_type = 'image/jpeg'
308
- bytesio.seek(0)
309
- data = bytesio.read()
310
- return types.Blob(mime_type=mime_type, data=data)
296
+ image_format = 'JPEG'
297
+ save_params.update(quality='keep')
298
+
299
+ image_io = io.BytesIO()
300
+ image.save(image_io, image_format, **save_params)
301
+ image_bytes = image_io.getvalue()
302
+ mime_type = f'image/{image_format.lower()}'
303
+
304
+ return types.Blob(data=image_bytes, mime_type=mime_type)
311
305
 
312
306
 
313
307
  def t_function_response(
google/genai/batches.py CHANGED
@@ -824,9 +824,6 @@ def _FunctionCallingConfig_to_mldev(
824
824
  parent_object: Optional[dict[str, Any]] = None,
825
825
  ) -> dict[str, Any]:
826
826
  to_object: dict[str, Any] = {}
827
- if getv(from_object, ['mode']) is not None:
828
- setv(to_object, ['mode'], getv(from_object, ['mode']))
829
-
830
827
  if getv(from_object, ['allowed_function_names']) is not None:
831
828
  setv(
832
829
  to_object,
@@ -834,6 +831,9 @@ def _FunctionCallingConfig_to_mldev(
834
831
  getv(from_object, ['allowed_function_names']),
835
832
  )
836
833
 
834
+ if getv(from_object, ['mode']) is not None:
835
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
836
+
837
837
  if getv(from_object, ['stream_function_call_arguments']) is not None:
838
838
  raise ValueError(
839
839
  'stream_function_call_arguments parameter is not supported in Gemini'
@@ -1131,6 +1131,11 @@ def _ImageConfig_to_mldev(
1131
1131
  if getv(from_object, ['image_size']) is not None:
1132
1132
  setv(to_object, ['imageSize'], getv(from_object, ['image_size']))
1133
1133
 
1134
+ if getv(from_object, ['person_generation']) is not None:
1135
+ raise ValueError(
1136
+ 'person_generation parameter is not supported in Gemini API.'
1137
+ )
1138
+
1134
1139
  if getv(from_object, ['output_mime_type']) is not None:
1135
1140
  raise ValueError(
1136
1141
  'output_mime_type parameter is not supported in Gemini API.'
@@ -1415,6 +1420,11 @@ def _ToolConfig_to_mldev(
1415
1420
  parent_object: Optional[dict[str, Any]] = None,
1416
1421
  ) -> dict[str, Any]:
1417
1422
  to_object: dict[str, Any] = {}
1423
+ if getv(from_object, ['retrieval_config']) is not None:
1424
+ setv(
1425
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1426
+ )
1427
+
1418
1428
  if getv(from_object, ['function_calling_config']) is not None:
1419
1429
  setv(
1420
1430
  to_object,
@@ -1424,11 +1434,6 @@ def _ToolConfig_to_mldev(
1424
1434
  ),
1425
1435
  )
1426
1436
 
1427
- if getv(from_object, ['retrieval_config']) is not None:
1428
- setv(
1429
- to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
1430
- )
1431
-
1432
1437
  return to_object
1433
1438
 
1434
1439
 
@@ -1437,23 +1442,9 @@ def _Tool_to_mldev(
1437
1442
  parent_object: Optional[dict[str, Any]] = None,
1438
1443
  ) -> dict[str, Any]:
1439
1444
  to_object: dict[str, Any] = {}
1440
- if getv(from_object, ['function_declarations']) is not None:
1441
- setv(
1442
- to_object,
1443
- ['functionDeclarations'],
1444
- [item for item in getv(from_object, ['function_declarations'])],
1445
- )
1446
-
1447
1445
  if getv(from_object, ['retrieval']) is not None:
1448
1446
  raise ValueError('retrieval parameter is not supported in Gemini API.')
1449
1447
 
1450
- if getv(from_object, ['google_search_retrieval']) is not None:
1451
- setv(
1452
- to_object,
1453
- ['googleSearchRetrieval'],
1454
- getv(from_object, ['google_search_retrieval']),
1455
- )
1456
-
1457
1448
  if getv(from_object, ['computer_use']) is not None:
1458
1449
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1459
1450
 
@@ -1468,6 +1459,13 @@ def _Tool_to_mldev(
1468
1459
  'enterprise_web_search parameter is not supported in Gemini API.'
1469
1460
  )
1470
1461
 
1462
+ if getv(from_object, ['function_declarations']) is not None:
1463
+ setv(
1464
+ to_object,
1465
+ ['functionDeclarations'],
1466
+ [item for item in getv(from_object, ['function_declarations'])],
1467
+ )
1468
+
1471
1469
  if getv(from_object, ['google_maps']) is not None:
1472
1470
  setv(
1473
1471
  to_object,
@@ -1482,6 +1480,13 @@ def _Tool_to_mldev(
1482
1480
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1483
1481
  )
1484
1482
 
1483
+ if getv(from_object, ['google_search_retrieval']) is not None:
1484
+ setv(
1485
+ to_object,
1486
+ ['googleSearchRetrieval'],
1487
+ getv(from_object, ['google_search_retrieval']),
1488
+ )
1489
+
1485
1490
  if getv(from_object, ['url_context']) is not None:
1486
1491
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1487
1492
 
google/genai/caches.py CHANGED
@@ -325,9 +325,6 @@ def _FunctionCallingConfig_to_mldev(
325
325
  parent_object: Optional[dict[str, Any]] = None,
326
326
  ) -> dict[str, Any]:
327
327
  to_object: dict[str, Any] = {}
328
- if getv(from_object, ['mode']) is not None:
329
- setv(to_object, ['mode'], getv(from_object, ['mode']))
330
-
331
328
  if getv(from_object, ['allowed_function_names']) is not None:
332
329
  setv(
333
330
  to_object,
@@ -335,6 +332,9 @@ def _FunctionCallingConfig_to_mldev(
335
332
  getv(from_object, ['allowed_function_names']),
336
333
  )
337
334
 
335
+ if getv(from_object, ['mode']) is not None:
336
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
337
+
338
338
  if getv(from_object, ['stream_function_call_arguments']) is not None:
339
339
  raise ValueError(
340
340
  'stream_function_call_arguments parameter is not supported in Gemini'
@@ -349,9 +349,6 @@ def _FunctionDeclaration_to_vertex(
349
349
  parent_object: Optional[dict[str, Any]] = None,
350
350
  ) -> dict[str, Any]:
351
351
  to_object: dict[str, Any] = {}
352
- if getv(from_object, ['behavior']) is not None:
353
- raise ValueError('behavior parameter is not supported in Vertex AI.')
354
-
355
352
  if getv(from_object, ['description']) is not None:
356
353
  setv(to_object, ['description'], getv(from_object, ['description']))
357
354
 
@@ -378,6 +375,9 @@ def _FunctionDeclaration_to_vertex(
378
375
  getv(from_object, ['response_json_schema']),
379
376
  )
380
377
 
378
+ if getv(from_object, ['behavior']) is not None:
379
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
380
+
381
381
  return to_object
382
382
 
383
383
 
@@ -634,6 +634,11 @@ def _ToolConfig_to_mldev(
634
634
  parent_object: Optional[dict[str, Any]] = None,
635
635
  ) -> dict[str, Any]:
636
636
  to_object: dict[str, Any] = {}
637
+ if getv(from_object, ['retrieval_config']) is not None:
638
+ setv(
639
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
640
+ )
641
+
637
642
  if getv(from_object, ['function_calling_config']) is not None:
638
643
  setv(
639
644
  to_object,
@@ -643,11 +648,6 @@ def _ToolConfig_to_mldev(
643
648
  ),
644
649
  )
645
650
 
646
- if getv(from_object, ['retrieval_config']) is not None:
647
- setv(
648
- to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
649
- )
650
-
651
651
  return to_object
652
652
 
653
653
 
@@ -656,23 +656,9 @@ def _Tool_to_mldev(
656
656
  parent_object: Optional[dict[str, Any]] = None,
657
657
  ) -> dict[str, Any]:
658
658
  to_object: dict[str, Any] = {}
659
- if getv(from_object, ['function_declarations']) is not None:
660
- setv(
661
- to_object,
662
- ['functionDeclarations'],
663
- [item for item in getv(from_object, ['function_declarations'])],
664
- )
665
-
666
659
  if getv(from_object, ['retrieval']) is not None:
667
660
  raise ValueError('retrieval parameter is not supported in Gemini API.')
668
661
 
669
- if getv(from_object, ['google_search_retrieval']) is not None:
670
- setv(
671
- to_object,
672
- ['googleSearchRetrieval'],
673
- getv(from_object, ['google_search_retrieval']),
674
- )
675
-
676
662
  if getv(from_object, ['computer_use']) is not None:
677
663
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
678
664
 
@@ -687,6 +673,13 @@ def _Tool_to_mldev(
687
673
  'enterprise_web_search parameter is not supported in Gemini API.'
688
674
  )
689
675
 
676
+ if getv(from_object, ['function_declarations']) is not None:
677
+ setv(
678
+ to_object,
679
+ ['functionDeclarations'],
680
+ [item for item in getv(from_object, ['function_declarations'])],
681
+ )
682
+
690
683
  if getv(from_object, ['google_maps']) is not None:
691
684
  setv(
692
685
  to_object,
@@ -701,6 +694,13 @@ def _Tool_to_mldev(
701
694
  _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
702
695
  )
703
696
 
697
+ if getv(from_object, ['google_search_retrieval']) is not None:
698
+ setv(
699
+ to_object,
700
+ ['googleSearchRetrieval'],
701
+ getv(from_object, ['google_search_retrieval']),
702
+ )
703
+
704
704
  if getv(from_object, ['url_context']) is not None:
705
705
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
706
706
 
@@ -712,26 +712,9 @@ def _Tool_to_vertex(
712
712
  parent_object: Optional[dict[str, Any]] = None,
713
713
  ) -> dict[str, Any]:
714
714
  to_object: dict[str, Any] = {}
715
- if getv(from_object, ['function_declarations']) is not None:
716
- setv(
717
- to_object,
718
- ['functionDeclarations'],
719
- [
720
- _FunctionDeclaration_to_vertex(item, to_object)
721
- for item in getv(from_object, ['function_declarations'])
722
- ],
723
- )
724
-
725
715
  if getv(from_object, ['retrieval']) is not None:
726
716
  setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
727
717
 
728
- if getv(from_object, ['google_search_retrieval']) is not None:
729
- setv(
730
- to_object,
731
- ['googleSearchRetrieval'],
732
- getv(from_object, ['google_search_retrieval']),
733
- )
734
-
735
718
  if getv(from_object, ['computer_use']) is not None:
736
719
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
737
720
 
@@ -748,12 +731,29 @@ def _Tool_to_vertex(
748
731
  getv(from_object, ['enterprise_web_search']),
749
732
  )
750
733
 
734
+ if getv(from_object, ['function_declarations']) is not None:
735
+ setv(
736
+ to_object,
737
+ ['functionDeclarations'],
738
+ [
739
+ _FunctionDeclaration_to_vertex(item, to_object)
740
+ for item in getv(from_object, ['function_declarations'])
741
+ ],
742
+ )
743
+
751
744
  if getv(from_object, ['google_maps']) is not None:
752
745
  setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
753
746
 
754
747
  if getv(from_object, ['google_search']) is not None:
755
748
  setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
756
749
 
750
+ if getv(from_object, ['google_search_retrieval']) is not None:
751
+ setv(
752
+ to_object,
753
+ ['googleSearchRetrieval'],
754
+ getv(from_object, ['google_search_retrieval']),
755
+ )
756
+
757
757
  if getv(from_object, ['url_context']) is not None:
758
758
  setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
759
759
 
google/genai/chats.py CHANGED
@@ -35,8 +35,6 @@ def _validate_content(content: Content) -> bool:
35
35
  for part in content.parts:
36
36
  if part == Part():
37
37
  return False
38
- if part.text is not None and part.text == "":
39
- return False
40
38
  return True
41
39
 
42
40