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
google/genai/types.py CHANGED
@@ -108,6 +108,20 @@ else:
108
108
  HttpxClient = None
109
109
  HttpxAsyncClient = None
110
110
 
111
+ _is_aiohttp_imported = False
112
+ if typing.TYPE_CHECKING:
113
+ from aiohttp import ClientSession
114
+
115
+ _is_aiohttp_imported = True
116
+ else:
117
+ ClientSession: typing.Type = Any
118
+ try:
119
+ from aiohttp import ClientSession
120
+
121
+ _is_aiohttp_imported = True
122
+ except ImportError:
123
+ ClientSession = None
124
+
111
125
  logger = logging.getLogger('google_genai.types')
112
126
  _from_json_schema_warning_logged = False
113
127
  _json_schema_warning_logged = False
@@ -182,15 +196,6 @@ class Type(_common.CaseInSensitiveEnum):
182
196
  """Null type"""
183
197
 
184
198
 
185
- class Mode(_common.CaseInSensitiveEnum):
186
- """The mode of the predictor to be used in dynamic retrieval."""
187
-
188
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
189
- """Always trigger retrieval."""
190
- MODE_DYNAMIC = 'MODE_DYNAMIC'
191
- """Run retrieval only when system decides it is necessary."""
192
-
193
-
194
199
  class ApiSpec(_common.CaseInSensitiveEnum):
195
200
  """The API spec that the external API implements.
196
201
 
@@ -261,6 +266,45 @@ class PhishBlockThreshold(_common.CaseInSensitiveEnum):
261
266
  """Blocks Extremely high confidence URL that is risky."""
262
267
 
263
268
 
269
+ class Behavior(_common.CaseInSensitiveEnum):
270
+ """Specifies the function Behavior.
271
+
272
+ Currently only supported by the BidiGenerateContent method. This enum is not
273
+ supported in Vertex AI.
274
+ """
275
+
276
+ UNSPECIFIED = 'UNSPECIFIED'
277
+ """This value is unused."""
278
+ BLOCKING = 'BLOCKING'
279
+ """If set, the system will wait to receive the function response before continuing the conversation."""
280
+ NON_BLOCKING = 'NON_BLOCKING'
281
+ """If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model."""
282
+
283
+
284
+ class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
285
+ """The mode of the predictor to be used in dynamic retrieval."""
286
+
287
+ MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
288
+ """Always trigger retrieval."""
289
+ MODE_DYNAMIC = 'MODE_DYNAMIC'
290
+ """Run retrieval only when system decides it is necessary."""
291
+
292
+
293
+ class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
294
+ """Function calling mode."""
295
+
296
+ MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
297
+ """Unspecified function calling mode. This value should not be used."""
298
+ AUTO = 'AUTO'
299
+ """Default model behavior, model decides to predict either function calls or natural language response."""
300
+ ANY = 'ANY'
301
+ """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""
302
+ NONE = 'NONE'
303
+ """Model will not predict any function calls. Model behavior is same as when not passing any function declarations."""
304
+ VALIDATED = 'VALIDATED'
305
+ """Model is constrained to predict either function calls or natural language response. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""
306
+
307
+
264
308
  class ThinkingLevel(_common.CaseInSensitiveEnum):
265
309
  """The number of thoughts tokens that the model should generate."""
266
310
 
@@ -618,26 +662,6 @@ class FeatureSelectionPreference(_common.CaseInSensitiveEnum):
618
662
  PRIORITIZE_COST = 'PRIORITIZE_COST'
619
663
 
620
664
 
621
- class Behavior(_common.CaseInSensitiveEnum):
622
- """Defines the function behavior. Defaults to `BLOCKING`."""
623
-
624
- UNSPECIFIED = 'UNSPECIFIED'
625
- """This value is unused."""
626
- BLOCKING = 'BLOCKING'
627
- """If set, the system will wait to receive the function response before continuing the conversation."""
628
- NON_BLOCKING = 'NON_BLOCKING'
629
- """If set, the system will not wait to receive the function response. Instead, it will attempt to handle function responses as they become available while maintaining the conversation between the user and the model."""
630
-
631
-
632
- class DynamicRetrievalConfigMode(_common.CaseInSensitiveEnum):
633
- """Config for the dynamic retrieval config mode."""
634
-
635
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
636
- """Always trigger retrieval."""
637
- MODE_DYNAMIC = 'MODE_DYNAMIC'
638
- """Run retrieval only when system decides it is necessary."""
639
-
640
-
641
665
  class Environment(_common.CaseInSensitiveEnum):
642
666
  """The environment being operated."""
643
667
 
@@ -647,21 +671,6 @@ class Environment(_common.CaseInSensitiveEnum):
647
671
  """Operates in a web browser."""
648
672
 
649
673
 
650
- class FunctionCallingConfigMode(_common.CaseInSensitiveEnum):
651
- """Config for the function calling config mode."""
652
-
653
- MODE_UNSPECIFIED = 'MODE_UNSPECIFIED'
654
- """The function calling config mode is unspecified. Should not be used."""
655
- AUTO = 'AUTO'
656
- """Default model behavior, model decides to predict either function calls or natural language response."""
657
- ANY = 'ANY'
658
- """Model is constrained to always predicting function calls only. If "allowed_function_names" are set, the predicted function calls will be limited to any one of "allowed_function_names", else the predicted function calls will be any one of the provided "function_declarations"."""
659
- NONE = 'NONE'
660
- """Model will not predict any function calls. Model behavior is same as when not passing any function declarations."""
661
- VALIDATED = 'VALIDATED'
662
- """Model decides to predict either a function call or a natural language response, but will validate function calls with constrained decoding. If "allowed_function_names" are set, the predicted function call will be limited to any one of "allowed_function_names", else the predicted function call will be any one of the provided "function_declarations"."""
663
-
664
-
665
674
  class SafetyFilterLevel(_common.CaseInSensitiveEnum):
666
675
  """Enum that controls the safety filter level for objectionable content."""
667
676
 
@@ -830,6 +839,7 @@ class FileSource(_common.CaseInSensitiveEnum):
830
839
  SOURCE_UNSPECIFIED = 'SOURCE_UNSPECIFIED'
831
840
  UPLOADED = 'UPLOADED'
832
841
  GENERATED = 'GENERATED'
842
+ REGISTERED = 'REGISTERED'
833
843
 
834
844
 
835
845
  class TurnCompleteReason(_common.CaseInSensitiveEnum):
@@ -873,6 +883,17 @@ class VadSignalType(_common.CaseInSensitiveEnum):
873
883
  """End of sentence signal."""
874
884
 
875
885
 
886
+ class VoiceActivityType(_common.CaseInSensitiveEnum):
887
+ """The type of the voice activity signal."""
888
+
889
+ TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'
890
+ """The default is VOICE_ACTIVITY_TYPE_UNSPECIFIED."""
891
+ ACTIVITY_START = 'ACTIVITY_START'
892
+ """Start of sentence signal."""
893
+ ACTIVITY_END = 'ACTIVITY_END'
894
+ """End of sentence signal."""
895
+
896
+
876
897
  class StartSensitivity(_common.CaseInSensitiveEnum):
877
898
  """Start of speech sensitivity."""
878
899
 
@@ -1929,6 +1950,10 @@ class HttpOptions(_common.BaseModel):
1929
1950
  default=None,
1930
1951
  description="""A custom httpx async client to be used for the request.""",
1931
1952
  )
1953
+ aiohttp_client: Optional['ClientSession'] = Field(
1954
+ default=None,
1955
+ description="""A custom aiohttp client session to be used for the request.""",
1956
+ )
1932
1957
 
1933
1958
 
1934
1959
  class HttpOptionsDict(TypedDict, total=False):
@@ -2805,404 +2830,95 @@ ModelSelectionConfigOrDict = Union[
2805
2830
  ]
2806
2831
 
2807
2832
 
2808
- class FunctionDeclaration(_common.BaseModel):
2809
- """Defines a function that the model can generate JSON inputs for.
2810
-
2811
- The inputs are based on `OpenAPI 3.0 specifications
2812
- <https://spec.openapis.org/oas/v3.0.3>`_.
2813
- """
2833
+ class ComputerUse(_common.BaseModel):
2834
+ """Tool to support computer use."""
2814
2835
 
2815
- behavior: Optional[Behavior] = Field(
2816
- default=None, description="""Defines the function behavior."""
2836
+ environment: Optional[Environment] = Field(
2837
+ default=None, description="""Required. The environment being operated."""
2817
2838
  )
2818
- description: Optional[str] = Field(
2839
+ excluded_predefined_functions: Optional[list[str]] = Field(
2819
2840
  default=None,
2820
- description="""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""",
2841
+ description="""By default, predefined functions are included in the final model call.
2842
+ Some of them can be explicitly excluded from being automatically included.
2843
+ This can serve two purposes:
2844
+ 1. Using a more restricted / different action space.
2845
+ 2. Improving the definitions / instructions of predefined functions.""",
2821
2846
  )
2822
- name: Optional[str] = Field(
2847
+
2848
+
2849
+ class ComputerUseDict(TypedDict, total=False):
2850
+ """Tool to support computer use."""
2851
+
2852
+ environment: Optional[Environment]
2853
+ """Required. The environment being operated."""
2854
+
2855
+ excluded_predefined_functions: Optional[list[str]]
2856
+ """By default, predefined functions are included in the final model call.
2857
+ Some of them can be explicitly excluded from being automatically included.
2858
+ This can serve two purposes:
2859
+ 1. Using a more restricted / different action space.
2860
+ 2. Improving the definitions / instructions of predefined functions."""
2861
+
2862
+
2863
+ ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]
2864
+
2865
+
2866
+ class FileSearch(_common.BaseModel):
2867
+ """Tool to retrieve knowledge from the File Search Stores."""
2868
+
2869
+ file_search_store_names: Optional[list[str]] = Field(
2823
2870
  default=None,
2824
- description="""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64.""",
2871
+ description="""The names of the file_search_stores to retrieve from.
2872
+ Example: `fileSearchStores/my-file-search-store-123`""",
2825
2873
  )
2826
- parameters: Optional[Schema] = Field(
2874
+ top_k: Optional[int] = Field(
2827
2875
  default=None,
2828
- description="""Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1""",
2876
+ description="""The number of file search retrieval chunks to retrieve.""",
2829
2877
  )
2830
- parameters_json_schema: Optional[Any] = Field(
2878
+ metadata_filter: Optional[str] = Field(
2831
2879
  default=None,
2832
- description="""Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.""",
2880
+ description="""Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.""",
2833
2881
  )
2834
- response: Optional[Schema] = Field(
2882
+
2883
+
2884
+ class FileSearchDict(TypedDict, total=False):
2885
+ """Tool to retrieve knowledge from the File Search Stores."""
2886
+
2887
+ file_search_store_names: Optional[list[str]]
2888
+ """The names of the file_search_stores to retrieve from.
2889
+ Example: `fileSearchStores/my-file-search-store-123`"""
2890
+
2891
+ top_k: Optional[int]
2892
+ """The number of file search retrieval chunks to retrieve."""
2893
+
2894
+ metadata_filter: Optional[str]
2895
+ """Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."""
2896
+
2897
+
2898
+ FileSearchOrDict = Union[FileSearch, FileSearchDict]
2899
+
2900
+
2901
+ class ApiAuthApiKeyConfig(_common.BaseModel):
2902
+ """The API secret. This data type is not supported in Gemini API."""
2903
+
2904
+ api_key_secret_version: Optional[str] = Field(
2835
2905
  default=None,
2836
- description="""Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""",
2906
+ description="""Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}""",
2837
2907
  )
2838
- response_json_schema: Optional[Any] = Field(
2908
+ api_key_string: Optional[str] = Field(
2839
2909
  default=None,
2840
- description="""Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.""",
2910
+ description="""The API key string. Either this or `api_key_secret_version` must be set.""",
2841
2911
  )
2842
2912
 
2843
- @classmethod
2844
- def from_callable_with_api_option(
2845
- cls,
2846
- *,
2847
- callable: Callable[..., Any],
2848
- api_option: Literal['VERTEX_AI', 'GEMINI_API'] = 'GEMINI_API',
2849
- behavior: Optional[Behavior] = None,
2850
- ) -> 'FunctionDeclaration':
2851
- """Converts a Callable to a FunctionDeclaration based on the API option.
2852
2913
 
2853
- Supported API option is 'VERTEX_AI' or 'GEMINI_API'. If api_option is unset,
2854
- it will default to 'GEMINI_API'. If unsupported api_option is provided, it
2855
- will raise ValueError.
2856
- """
2857
- supported_api_options = ['VERTEX_AI', 'GEMINI_API']
2858
- if api_option not in supported_api_options:
2859
- raise ValueError(
2860
- f'Unsupported api_option value: {api_option}. Supported api_option'
2861
- f' value is one of: {supported_api_options}.'
2862
- )
2863
- from . import _automatic_function_calling_util
2914
+ class ApiAuthApiKeyConfigDict(TypedDict, total=False):
2915
+ """The API secret. This data type is not supported in Gemini API."""
2864
2916
 
2865
- parameters_properties = {}
2866
- parameters_json_schema = {}
2867
- annotation_under_future = typing.get_type_hints(callable)
2868
- try:
2869
- for name, param in inspect.signature(callable).parameters.items():
2870
- if param.kind in (
2871
- inspect.Parameter.POSITIONAL_OR_KEYWORD,
2872
- inspect.Parameter.KEYWORD_ONLY,
2873
- inspect.Parameter.POSITIONAL_ONLY,
2874
- ):
2875
- param = _automatic_function_calling_util._handle_params_as_deferred_annotations(
2876
- param, annotation_under_future, name
2877
- )
2878
- schema = (
2879
- _automatic_function_calling_util._parse_schema_from_parameter(
2880
- api_option, param, callable.__name__
2881
- )
2882
- )
2883
- parameters_properties[name] = schema
2884
- except ValueError:
2885
- parameters_properties = {}
2886
- for name, param in inspect.signature(callable).parameters.items():
2887
- if param.kind in (
2888
- inspect.Parameter.POSITIONAL_OR_KEYWORD,
2889
- inspect.Parameter.KEYWORD_ONLY,
2890
- inspect.Parameter.POSITIONAL_ONLY,
2891
- ):
2892
- try:
2893
- param = _automatic_function_calling_util._handle_params_as_deferred_annotations(
2894
- param, annotation_under_future, name
2895
- )
2896
- param_schema_adapter = pydantic.TypeAdapter(
2897
- param.annotation,
2898
- config=pydantic.ConfigDict(arbitrary_types_allowed=True),
2899
- )
2900
- json_schema_dict = param_schema_adapter.json_schema()
2901
- json_schema_dict = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(
2902
- json_schema_dict
2903
- )
2904
- if 'prefixItems' in json_schema_dict:
2905
- parameters_json_schema[name] = json_schema_dict
2906
- continue
2917
+ api_key_secret_version: Optional[str]
2918
+ """Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}"""
2907
2919
 
2908
- union_args = typing.get_args(param.annotation)
2909
- has_primitive = any(
2910
- _automatic_function_calling_util._is_builtin_primitive_or_compound(
2911
- arg
2912
- )
2913
- for arg in union_args
2914
- )
2915
- if (
2916
- '$ref' in json_schema_dict or '$defs' in json_schema_dict
2917
- ) and has_primitive:
2918
- # This is a complex schema with a primitive (e.g., str | MyModel)
2919
- # that is better represented by raw JSON schema.
2920
- parameters_json_schema[name] = json_schema_dict
2921
- continue
2922
-
2923
- schema = Schema.from_json_schema(
2924
- json_schema=JSONSchema(**json_schema_dict),
2925
- api_option=api_option,
2926
- )
2927
- if param.default is not inspect.Parameter.empty:
2928
- schema.default = param.default
2929
- parameters_properties[name] = schema
2930
- except Exception as e:
2931
- _automatic_function_calling_util._raise_for_unsupported_param(
2932
- param, callable.__name__, e
2933
- )
2934
-
2935
- declaration = FunctionDeclaration(
2936
- name=callable.__name__,
2937
- description=inspect.cleandoc(callable.__doc__)
2938
- if callable.__doc__
2939
- else callable.__doc__,
2940
- behavior=behavior,
2941
- )
2942
- if parameters_properties:
2943
- declaration.parameters = Schema(
2944
- type='OBJECT',
2945
- properties=parameters_properties,
2946
- )
2947
- declaration.parameters.required = (
2948
- _automatic_function_calling_util._get_required_fields(
2949
- declaration.parameters
2950
- )
2951
- )
2952
- elif parameters_json_schema:
2953
- declaration.parameters_json_schema = parameters_json_schema
2954
- # TODO: b/421991354 - Remove this check once the bug is fixed.
2955
- if api_option == 'GEMINI_API':
2956
- return declaration
2957
-
2958
- return_annotation = inspect.signature(callable).return_annotation
2959
- if return_annotation is inspect._empty:
2960
- return declaration
2961
-
2962
- return_value = inspect.Parameter(
2963
- 'return_value',
2964
- inspect.Parameter.POSITIONAL_OR_KEYWORD,
2965
- annotation=return_annotation,
2966
- )
2967
-
2968
- # This snippet catches the case when type hints are stored as strings
2969
- if isinstance(return_value.annotation, str):
2970
- return_value = return_value.replace(
2971
- annotation=annotation_under_future['return']
2972
- )
2973
- response_schema: Optional[Schema] = None
2974
- response_json_schema: Optional[Union[dict[str, Any], Schema]] = {}
2975
- try:
2976
- response_schema = (
2977
- _automatic_function_calling_util._parse_schema_from_parameter(
2978
- api_option,
2979
- return_value,
2980
- callable.__name__,
2981
- )
2982
- )
2983
- if response_schema.any_of is not None:
2984
- # To handle any_of, we need to use responseJsonSchema
2985
- response_json_schema = response_schema
2986
- response_schema = None
2987
- except ValueError:
2988
- try:
2989
- return_value_schema_adapter = pydantic.TypeAdapter(
2990
- return_value.annotation,
2991
- config=pydantic.ConfigDict(arbitrary_types_allowed=True),
2992
- )
2993
- response_json_schema = return_value_schema_adapter.json_schema()
2994
- response_json_schema = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(
2995
- response_json_schema
2996
- )
2997
- except Exception as e:
2998
- _automatic_function_calling_util._raise_for_unsupported_param(
2999
- return_value, callable.__name__, e
3000
- )
3001
-
3002
- if response_schema:
3003
- declaration.response = response_schema
3004
- elif response_json_schema:
3005
- declaration.response_json_schema = response_json_schema
3006
- return declaration
3007
-
3008
- @classmethod
3009
- def from_callable(
3010
- cls,
3011
- *,
3012
- client: 'BaseApiClient',
3013
- callable: Callable[..., Any],
3014
- behavior: Optional[Behavior] = None,
3015
- ) -> 'FunctionDeclaration':
3016
- """Converts a Callable to a FunctionDeclaration based on the client.
3017
-
3018
- Note: For best results prefer
3019
- [Google-style
3020
- docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods)
3021
- when describing arguments. This function does **not** parse argument
3022
- descriptions into the property description slots of the resulting structure.
3023
- Instead it sends the whole docstring in the top-level function description.
3024
- Google-style docstring are closest to what the model is trained on.
3025
- """
3026
- if client.vertexai:
3027
- return cls.from_callable_with_api_option(
3028
- callable=callable, api_option='VERTEX_AI', behavior=behavior
3029
- )
3030
- else:
3031
- return cls.from_callable_with_api_option(
3032
- callable=callable, api_option='GEMINI_API', behavior=behavior
3033
- )
3034
-
3035
-
3036
- class FunctionDeclarationDict(TypedDict, total=False):
3037
- """Defines a function that the model can generate JSON inputs for.
3038
-
3039
- The inputs are based on `OpenAPI 3.0 specifications
3040
- <https://spec.openapis.org/oas/v3.0.3>`_.
3041
- """
3042
-
3043
- behavior: Optional[Behavior]
3044
- """Defines the function behavior."""
3045
-
3046
- description: Optional[str]
3047
- """Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function."""
3048
-
3049
- name: Optional[str]
3050
- """Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64."""
3051
-
3052
- parameters: Optional[SchemaDict]
3053
- """Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1"""
3054
-
3055
- parameters_json_schema: Optional[Any]
3056
- """Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`."""
3057
-
3058
- response: Optional[SchemaDict]
3059
- """Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function."""
3060
-
3061
- response_json_schema: Optional[Any]
3062
- """Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`."""
3063
-
3064
-
3065
- FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]
3066
-
3067
-
3068
- class DynamicRetrievalConfig(_common.BaseModel):
3069
- """Describes the options to customize dynamic retrieval."""
3070
-
3071
- mode: Optional[DynamicRetrievalConfigMode] = Field(
3072
- default=None,
3073
- description="""The mode of the predictor to be used in dynamic retrieval.""",
3074
- )
3075
- dynamic_threshold: Optional[float] = Field(
3076
- default=None,
3077
- description="""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.""",
3078
- )
3079
-
3080
-
3081
- class DynamicRetrievalConfigDict(TypedDict, total=False):
3082
- """Describes the options to customize dynamic retrieval."""
3083
-
3084
- mode: Optional[DynamicRetrievalConfigMode]
3085
- """The mode of the predictor to be used in dynamic retrieval."""
3086
-
3087
- dynamic_threshold: Optional[float]
3088
- """Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used."""
3089
-
3090
-
3091
- DynamicRetrievalConfigOrDict = Union[
3092
- DynamicRetrievalConfig, DynamicRetrievalConfigDict
3093
- ]
3094
-
3095
-
3096
- class GoogleSearchRetrieval(_common.BaseModel):
3097
- """Tool to retrieve public web data for grounding, powered by Google."""
3098
-
3099
- dynamic_retrieval_config: Optional[DynamicRetrievalConfig] = Field(
3100
- default=None,
3101
- description="""Specifies the dynamic retrieval configuration for the given source.""",
3102
- )
3103
-
3104
-
3105
- class GoogleSearchRetrievalDict(TypedDict, total=False):
3106
- """Tool to retrieve public web data for grounding, powered by Google."""
3107
-
3108
- dynamic_retrieval_config: Optional[DynamicRetrievalConfigDict]
3109
- """Specifies the dynamic retrieval configuration for the given source."""
3110
-
3111
-
3112
- GoogleSearchRetrievalOrDict = Union[
3113
- GoogleSearchRetrieval, GoogleSearchRetrievalDict
3114
- ]
3115
-
3116
-
3117
- class ComputerUse(_common.BaseModel):
3118
- """Tool to support computer use."""
3119
-
3120
- environment: Optional[Environment] = Field(
3121
- default=None, description="""Required. The environment being operated."""
3122
- )
3123
- excluded_predefined_functions: Optional[list[str]] = Field(
3124
- default=None,
3125
- description="""By default, predefined functions are included in the final model call.
3126
- Some of them can be explicitly excluded from being automatically included.
3127
- This can serve two purposes:
3128
- 1. Using a more restricted / different action space.
3129
- 2. Improving the definitions / instructions of predefined functions.""",
3130
- )
3131
-
3132
-
3133
- class ComputerUseDict(TypedDict, total=False):
3134
- """Tool to support computer use."""
3135
-
3136
- environment: Optional[Environment]
3137
- """Required. The environment being operated."""
3138
-
3139
- excluded_predefined_functions: Optional[list[str]]
3140
- """By default, predefined functions are included in the final model call.
3141
- Some of them can be explicitly excluded from being automatically included.
3142
- This can serve two purposes:
3143
- 1. Using a more restricted / different action space.
3144
- 2. Improving the definitions / instructions of predefined functions."""
3145
-
3146
-
3147
- ComputerUseOrDict = Union[ComputerUse, ComputerUseDict]
3148
-
3149
-
3150
- class FileSearch(_common.BaseModel):
3151
- """Tool to retrieve knowledge from the File Search Stores."""
3152
-
3153
- file_search_store_names: Optional[list[str]] = Field(
3154
- default=None,
3155
- description="""The names of the file_search_stores to retrieve from.
3156
- Example: `fileSearchStores/my-file-search-store-123`""",
3157
- )
3158
- top_k: Optional[int] = Field(
3159
- default=None,
3160
- description="""The number of file search retrieval chunks to retrieve.""",
3161
- )
3162
- metadata_filter: Optional[str] = Field(
3163
- default=None,
3164
- description="""Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression.""",
3165
- )
3166
-
3167
-
3168
- class FileSearchDict(TypedDict, total=False):
3169
- """Tool to retrieve knowledge from the File Search Stores."""
3170
-
3171
- file_search_store_names: Optional[list[str]]
3172
- """The names of the file_search_stores to retrieve from.
3173
- Example: `fileSearchStores/my-file-search-store-123`"""
3174
-
3175
- top_k: Optional[int]
3176
- """The number of file search retrieval chunks to retrieve."""
3177
-
3178
- metadata_filter: Optional[str]
3179
- """Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."""
3180
-
3181
-
3182
- FileSearchOrDict = Union[FileSearch, FileSearchDict]
3183
-
3184
-
3185
- class ApiAuthApiKeyConfig(_common.BaseModel):
3186
- """The API secret. This data type is not supported in Gemini API."""
3187
-
3188
- api_key_secret_version: Optional[str] = Field(
3189
- default=None,
3190
- description="""Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}""",
3191
- )
3192
- api_key_string: Optional[str] = Field(
3193
- default=None,
3194
- description="""The API key string. Either this or `api_key_secret_version` must be set.""",
3195
- )
3196
-
3197
-
3198
- class ApiAuthApiKeyConfigDict(TypedDict, total=False):
3199
- """The API secret. This data type is not supported in Gemini API."""
3200
-
3201
- api_key_secret_version: Optional[str]
3202
- """Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}"""
3203
-
3204
- api_key_string: Optional[str]
3205
- """The API key string. Either this or `api_key_secret_version` must be set."""
2920
+ api_key_string: Optional[str]
2921
+ """The API key string. Either this or `api_key_secret_version` must be set."""
3206
2922
 
3207
2923
 
3208
2924
  ApiAuthApiKeyConfigOrDict = Union[ApiAuthApiKeyConfig, ApiAuthApiKeyConfigDict]
@@ -4024,20 +3740,283 @@ class EnterpriseWebSearch(_common.BaseModel):
4024
3740
  )
4025
3741
 
4026
3742
 
4027
- class EnterpriseWebSearchDict(TypedDict, total=False):
4028
- """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.
3743
+ class EnterpriseWebSearchDict(TypedDict, total=False):
3744
+ """Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.
3745
+
3746
+ This data type is not supported in Gemini API.
3747
+ """
3748
+
3749
+ exclude_domains: Optional[list[str]]
3750
+ """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains."""
3751
+
3752
+ blocking_confidence: Optional[PhishBlockThreshold]
3753
+ """Optional. Sites with confidence level chosen & above this value will be blocked from the search results."""
3754
+
3755
+
3756
+ EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]
3757
+
3758
+
3759
+ class FunctionDeclaration(_common.BaseModel):
3760
+ """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
3761
+
3762
+ Included in this declaration are the function name, description, parameters
3763
+ and response type. This FunctionDeclaration is a representation of a block of
3764
+ code that can be used as a `Tool` by the model and executed by the client.
3765
+ """
3766
+
3767
+ description: Optional[str] = Field(
3768
+ default=None,
3769
+ description="""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""",
3770
+ )
3771
+ name: Optional[str] = Field(
3772
+ default=None,
3773
+ description="""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64.""",
3774
+ )
3775
+ parameters: Optional[Schema] = Field(
3776
+ default=None,
3777
+ description="""Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1""",
3778
+ )
3779
+ parameters_json_schema: Optional[Any] = Field(
3780
+ default=None,
3781
+ description="""Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`.""",
3782
+ )
3783
+ response: Optional[Schema] = Field(
3784
+ default=None,
3785
+ description="""Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""",
3786
+ )
3787
+ response_json_schema: Optional[Any] = Field(
3788
+ default=None,
3789
+ description="""Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`.""",
3790
+ )
3791
+ behavior: Optional[Behavior] = Field(
3792
+ default=None,
3793
+ description="""Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This field is not supported in Vertex AI.""",
3794
+ )
3795
+
3796
+ @classmethod
3797
+ def from_callable_with_api_option(
3798
+ cls,
3799
+ *,
3800
+ callable: Callable[..., Any],
3801
+ api_option: Literal['VERTEX_AI', 'GEMINI_API'] = 'GEMINI_API',
3802
+ behavior: Optional[Behavior] = None,
3803
+ ) -> 'FunctionDeclaration':
3804
+ """Converts a Callable to a FunctionDeclaration based on the API option.
3805
+
3806
+ Supported API option is 'VERTEX_AI' or 'GEMINI_API'. If api_option is unset,
3807
+ it will default to 'GEMINI_API'. If unsupported api_option is provided, it
3808
+ will raise ValueError.
3809
+ """
3810
+ supported_api_options = ['VERTEX_AI', 'GEMINI_API']
3811
+ if api_option not in supported_api_options:
3812
+ raise ValueError(
3813
+ f'Unsupported api_option value: {api_option}. Supported api_option'
3814
+ f' value is one of: {supported_api_options}.'
3815
+ )
3816
+ from . import _automatic_function_calling_util
3817
+
3818
+ parameters_properties = {}
3819
+ parameters_json_schema = {}
3820
+ annotation_under_future = typing.get_type_hints(callable)
3821
+ try:
3822
+ for name, param in inspect.signature(callable).parameters.items():
3823
+ if param.kind in (
3824
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
3825
+ inspect.Parameter.KEYWORD_ONLY,
3826
+ inspect.Parameter.POSITIONAL_ONLY,
3827
+ ):
3828
+ param = _automatic_function_calling_util._handle_params_as_deferred_annotations(
3829
+ param, annotation_under_future, name
3830
+ )
3831
+ schema = (
3832
+ _automatic_function_calling_util._parse_schema_from_parameter(
3833
+ api_option, param, callable.__name__
3834
+ )
3835
+ )
3836
+ parameters_properties[name] = schema
3837
+ except ValueError:
3838
+ parameters_properties = {}
3839
+ for name, param in inspect.signature(callable).parameters.items():
3840
+ if param.kind in (
3841
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
3842
+ inspect.Parameter.KEYWORD_ONLY,
3843
+ inspect.Parameter.POSITIONAL_ONLY,
3844
+ ):
3845
+ try:
3846
+ param = _automatic_function_calling_util._handle_params_as_deferred_annotations(
3847
+ param, annotation_under_future, name
3848
+ )
3849
+ param_schema_adapter = pydantic.TypeAdapter(
3850
+ param.annotation,
3851
+ config=pydantic.ConfigDict(arbitrary_types_allowed=True),
3852
+ )
3853
+ json_schema_dict = param_schema_adapter.json_schema()
3854
+ json_schema_dict = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(
3855
+ json_schema_dict
3856
+ )
3857
+ if 'prefixItems' in json_schema_dict:
3858
+ parameters_json_schema[name] = json_schema_dict
3859
+ continue
3860
+
3861
+ union_args = typing.get_args(param.annotation)
3862
+ has_primitive = any(
3863
+ _automatic_function_calling_util._is_builtin_primitive_or_compound(
3864
+ arg
3865
+ )
3866
+ for arg in union_args
3867
+ )
3868
+ if (
3869
+ '$ref' in json_schema_dict or '$defs' in json_schema_dict
3870
+ ) and has_primitive:
3871
+ # This is a complex schema with a primitive (e.g., str | MyModel)
3872
+ # that is better represented by raw JSON schema.
3873
+ parameters_json_schema[name] = json_schema_dict
3874
+ continue
3875
+
3876
+ schema = Schema.from_json_schema(
3877
+ json_schema=JSONSchema(**json_schema_dict),
3878
+ api_option=api_option,
3879
+ )
3880
+ if param.default is not inspect.Parameter.empty:
3881
+ schema.default = param.default
3882
+ parameters_properties[name] = schema
3883
+ except Exception as e:
3884
+ _automatic_function_calling_util._raise_for_unsupported_param(
3885
+ param, callable.__name__, e
3886
+ )
3887
+
3888
+ declaration = FunctionDeclaration(
3889
+ name=callable.__name__,
3890
+ description=inspect.cleandoc(callable.__doc__)
3891
+ if callable.__doc__
3892
+ else callable.__doc__,
3893
+ behavior=behavior,
3894
+ )
3895
+ if parameters_properties:
3896
+ declaration.parameters = Schema(
3897
+ type='OBJECT',
3898
+ properties=parameters_properties,
3899
+ )
3900
+ declaration.parameters.required = (
3901
+ _automatic_function_calling_util._get_required_fields(
3902
+ declaration.parameters
3903
+ )
3904
+ )
3905
+ elif parameters_json_schema:
3906
+ declaration.parameters_json_schema = parameters_json_schema
3907
+ # TODO: b/421991354 - Remove this check once the bug is fixed.
3908
+ if api_option == 'GEMINI_API':
3909
+ return declaration
3910
+
3911
+ return_annotation = inspect.signature(callable).return_annotation
3912
+ if return_annotation is inspect._empty:
3913
+ return declaration
3914
+
3915
+ return_value = inspect.Parameter(
3916
+ 'return_value',
3917
+ inspect.Parameter.POSITIONAL_OR_KEYWORD,
3918
+ annotation=return_annotation,
3919
+ )
3920
+
3921
+ # This snippet catches the case when type hints are stored as strings
3922
+ if isinstance(return_value.annotation, str):
3923
+ return_value = return_value.replace(
3924
+ annotation=annotation_under_future['return']
3925
+ )
3926
+ response_schema: Optional[Schema] = None
3927
+ response_json_schema: Optional[Union[dict[str, Any], Schema]] = {}
3928
+ try:
3929
+ response_schema = (
3930
+ _automatic_function_calling_util._parse_schema_from_parameter(
3931
+ api_option,
3932
+ return_value,
3933
+ callable.__name__,
3934
+ )
3935
+ )
3936
+ if response_schema.any_of is not None:
3937
+ # To handle any_of, we need to use responseJsonSchema
3938
+ response_json_schema = response_schema
3939
+ response_schema = None
3940
+ except ValueError:
3941
+ try:
3942
+ return_value_schema_adapter = pydantic.TypeAdapter(
3943
+ return_value.annotation,
3944
+ config=pydantic.ConfigDict(arbitrary_types_allowed=True),
3945
+ )
3946
+ response_json_schema = return_value_schema_adapter.json_schema()
3947
+ response_json_schema = _automatic_function_calling_util._add_unevaluated_items_to_fixed_len_tuple_schema(
3948
+ response_json_schema
3949
+ )
3950
+ except Exception as e:
3951
+ _automatic_function_calling_util._raise_for_unsupported_param(
3952
+ return_value, callable.__name__, e
3953
+ )
3954
+
3955
+ if response_schema:
3956
+ declaration.response = response_schema
3957
+ elif response_json_schema:
3958
+ declaration.response_json_schema = response_json_schema
3959
+ return declaration
3960
+
3961
+ @classmethod
3962
+ def from_callable(
3963
+ cls,
3964
+ *,
3965
+ client: 'BaseApiClient',
3966
+ callable: Callable[..., Any],
3967
+ behavior: Optional[Behavior] = None,
3968
+ ) -> 'FunctionDeclaration':
3969
+ """Converts a Callable to a FunctionDeclaration based on the client.
3970
+
3971
+ Note: For best results prefer
3972
+ [Google-style
3973
+ docstring](https://google.github.io/styleguide/pyguide.html#383-functions-and-methods)
3974
+ when describing arguments. This function does **not** parse argument
3975
+ descriptions into the property description slots of the resulting structure.
3976
+ Instead it sends the whole docstring in the top-level function description.
3977
+ Google-style docstring are closest to what the model is trained on.
3978
+ """
3979
+ if client.vertexai:
3980
+ return cls.from_callable_with_api_option(
3981
+ callable=callable, api_option='VERTEX_AI', behavior=behavior
3982
+ )
3983
+ else:
3984
+ return cls.from_callable_with_api_option(
3985
+ callable=callable, api_option='GEMINI_API', behavior=behavior
3986
+ )
3987
+
3988
+
3989
+ class FunctionDeclarationDict(TypedDict, total=False):
3990
+ """Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
4029
3991
 
4030
- This data type is not supported in Gemini API.
3992
+ Included in this declaration are the function name, description, parameters
3993
+ and response type. This FunctionDeclaration is a representation of a block of
3994
+ code that can be used as a `Tool` by the model and executed by the client.
4031
3995
  """
4032
3996
 
4033
- exclude_domains: Optional[list[str]]
4034
- """Optional. List of domains to be excluded from the search results. The default limit is 2000 domains."""
3997
+ description: Optional[str]
3998
+ """Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function."""
4035
3999
 
4036
- blocking_confidence: Optional[PhishBlockThreshold]
4037
- """Optional. Sites with confidence level chosen & above this value will be blocked from the search results."""
4000
+ name: Optional[str]
4001
+ """Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64."""
4038
4002
 
4003
+ parameters: Optional[SchemaDict]
4004
+ """Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1"""
4039
4005
 
4040
- EnterpriseWebSearchOrDict = Union[EnterpriseWebSearch, EnterpriseWebSearchDict]
4006
+ parameters_json_schema: Optional[Any]
4007
+ """Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: ``` { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": ["name", "age"], "propertyOrdering": ["name", "age"] } ``` This field is mutually exclusive with `parameters`."""
4008
+
4009
+ response: Optional[SchemaDict]
4010
+ """Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function."""
4011
+
4012
+ response_json_schema: Optional[Any]
4013
+ """Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with `response`."""
4014
+
4015
+ behavior: Optional[Behavior]
4016
+ """Optional. Specifies the function Behavior. Currently only supported by the BidiGenerateContent method. This field is not supported in Vertex AI."""
4017
+
4018
+
4019
+ FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]
4041
4020
 
4042
4021
 
4043
4022
  class GoogleMaps(_common.BaseModel):
@@ -4141,6 +4120,55 @@ class GoogleSearchDict(TypedDict, total=False):
4141
4120
  GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict]
4142
4121
 
4143
4122
 
4123
+ class DynamicRetrievalConfig(_common.BaseModel):
4124
+ """Describes the options to customize dynamic retrieval."""
4125
+
4126
+ dynamic_threshold: Optional[float] = Field(
4127
+ default=None,
4128
+ description="""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.""",
4129
+ )
4130
+ mode: Optional[DynamicRetrievalConfigMode] = Field(
4131
+ default=None,
4132
+ description="""The mode of the predictor to be used in dynamic retrieval.""",
4133
+ )
4134
+
4135
+
4136
+ class DynamicRetrievalConfigDict(TypedDict, total=False):
4137
+ """Describes the options to customize dynamic retrieval."""
4138
+
4139
+ dynamic_threshold: Optional[float]
4140
+ """Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used."""
4141
+
4142
+ mode: Optional[DynamicRetrievalConfigMode]
4143
+ """The mode of the predictor to be used in dynamic retrieval."""
4144
+
4145
+
4146
+ DynamicRetrievalConfigOrDict = Union[
4147
+ DynamicRetrievalConfig, DynamicRetrievalConfigDict
4148
+ ]
4149
+
4150
+
4151
+ class GoogleSearchRetrieval(_common.BaseModel):
4152
+ """Tool to retrieve public web data for grounding, powered by Google."""
4153
+
4154
+ dynamic_retrieval_config: Optional[DynamicRetrievalConfig] = Field(
4155
+ default=None,
4156
+ description="""Specifies the dynamic retrieval configuration for the given source.""",
4157
+ )
4158
+
4159
+
4160
+ class GoogleSearchRetrievalDict(TypedDict, total=False):
4161
+ """Tool to retrieve public web data for grounding, powered by Google."""
4162
+
4163
+ dynamic_retrieval_config: Optional[DynamicRetrievalConfigDict]
4164
+ """Specifies the dynamic retrieval configuration for the given source."""
4165
+
4166
+
4167
+ GoogleSearchRetrievalOrDict = Union[
4168
+ GoogleSearchRetrieval, GoogleSearchRetrievalDict
4169
+ ]
4170
+
4171
+
4144
4172
  class UrlContext(_common.BaseModel):
4145
4173
  """Tool to support URL context."""
4146
4174
 
@@ -4159,18 +4187,10 @@ UrlContextOrDict = Union[UrlContext, UrlContextDict]
4159
4187
  class Tool(_common.BaseModel):
4160
4188
  """Tool details of a tool that the model may use to generate a response."""
4161
4189
 
4162
- function_declarations: Optional[list[FunctionDeclaration]] = Field(
4163
- default=None,
4164
- description="""List of function declarations that the tool supports.""",
4165
- )
4166
4190
  retrieval: Optional[Retrieval] = Field(
4167
4191
  default=None,
4168
4192
  description="""Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API.""",
4169
4193
  )
4170
- google_search_retrieval: Optional[GoogleSearchRetrieval] = Field(
4171
- default=None,
4172
- description="""Optional. Specialized retrieval tool that is powered by Google Search.""",
4173
- )
4174
4194
  computer_use: Optional[ComputerUse] = Field(
4175
4195
  default=None,
4176
4196
  description="""Optional. Tool to support the model interacting directly with the
@@ -4189,6 +4209,10 @@ class Tool(_common.BaseModel):
4189
4209
  default=None,
4190
4210
  description="""Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API.""",
4191
4211
  )
4212
+ function_declarations: Optional[list[FunctionDeclaration]] = Field(
4213
+ default=None,
4214
+ description="""Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided.""",
4215
+ )
4192
4216
  google_maps: Optional[GoogleMaps] = Field(
4193
4217
  default=None,
4194
4218
  description="""Optional. GoogleMaps tool type. Tool to support Google Maps in Model.""",
@@ -4197,6 +4221,10 @@ class Tool(_common.BaseModel):
4197
4221
  default=None,
4198
4222
  description="""Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google.""",
4199
4223
  )
4224
+ google_search_retrieval: Optional[GoogleSearchRetrieval] = Field(
4225
+ default=None,
4226
+ description="""Optional. Specialized retrieval tool that is powered by Google Search.""",
4227
+ )
4200
4228
  url_context: Optional[UrlContext] = Field(
4201
4229
  default=None,
4202
4230
  description="""Optional. Tool to support URL context retrieval.""",
@@ -4206,15 +4234,9 @@ class Tool(_common.BaseModel):
4206
4234
  class ToolDict(TypedDict, total=False):
4207
4235
  """Tool details of a tool that the model may use to generate a response."""
4208
4236
 
4209
- function_declarations: Optional[list[FunctionDeclarationDict]]
4210
- """List of function declarations that the tool supports."""
4211
-
4212
4237
  retrieval: Optional[RetrievalDict]
4213
4238
  """Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. This field is not supported in Gemini API."""
4214
4239
 
4215
- google_search_retrieval: Optional[GoogleSearchRetrievalDict]
4216
- """Optional. Specialized retrieval tool that is powered by Google Search."""
4217
-
4218
4240
  computer_use: Optional[ComputerUseDict]
4219
4241
  """Optional. Tool to support the model interacting directly with the
4220
4242
  computer. If enabled, it automatically populates computer-use specific
@@ -4229,12 +4251,18 @@ class ToolDict(TypedDict, total=False):
4229
4251
  enterprise_web_search: Optional[EnterpriseWebSearchDict]
4230
4252
  """Optional. Tool to support searching public web data, powered by Vertex AI Search and Sec4 compliance. This field is not supported in Gemini API."""
4231
4253
 
4254
+ function_declarations: Optional[list[FunctionDeclarationDict]]
4255
+ """Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 512 function declarations can be provided."""
4256
+
4232
4257
  google_maps: Optional[GoogleMapsDict]
4233
4258
  """Optional. GoogleMaps tool type. Tool to support Google Maps in Model."""
4234
4259
 
4235
4260
  google_search: Optional[GoogleSearchDict]
4236
4261
  """Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google."""
4237
4262
 
4263
+ google_search_retrieval: Optional[GoogleSearchRetrievalDict]
4264
+ """Optional. Specialized retrieval tool that is powered by Google Search."""
4265
+
4238
4266
  url_context: Optional[UrlContextDict]
4239
4267
  """Optional. Tool to support URL context retrieval."""
4240
4268
 
@@ -4258,40 +4286,6 @@ SchemaUnion = Union[
4258
4286
  SchemaUnionDict = Union[SchemaUnion, SchemaDict]
4259
4287
 
4260
4288
 
4261
- class FunctionCallingConfig(_common.BaseModel):
4262
- """Function calling config."""
4263
-
4264
- mode: Optional[FunctionCallingConfigMode] = Field(
4265
- default=None, description="""Optional. Function calling mode."""
4266
- )
4267
- allowed_function_names: Optional[list[str]] = Field(
4268
- default=None,
4269
- description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided.""",
4270
- )
4271
- stream_function_call_arguments: Optional[bool] = Field(
4272
- default=None,
4273
- description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field. This field is not supported in Gemini API.""",
4274
- )
4275
-
4276
-
4277
- class FunctionCallingConfigDict(TypedDict, total=False):
4278
- """Function calling config."""
4279
-
4280
- mode: Optional[FunctionCallingConfigMode]
4281
- """Optional. Function calling mode."""
4282
-
4283
- allowed_function_names: Optional[list[str]]
4284
- """Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided."""
4285
-
4286
- stream_function_call_arguments: Optional[bool]
4287
- """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field. This field is not supported in Gemini API."""
4288
-
4289
-
4290
- FunctionCallingConfigOrDict = Union[
4291
- FunctionCallingConfig, FunctionCallingConfigDict
4292
- ]
4293
-
4294
-
4295
4289
  class LatLng(_common.BaseModel):
4296
4290
  """An object that represents a latitude/longitude pair.
4297
4291
 
@@ -4354,18 +4348,52 @@ class RetrievalConfigDict(TypedDict, total=False):
4354
4348
  RetrievalConfigOrDict = Union[RetrievalConfig, RetrievalConfigDict]
4355
4349
 
4356
4350
 
4351
+ class FunctionCallingConfig(_common.BaseModel):
4352
+ """Function calling config."""
4353
+
4354
+ allowed_function_names: Optional[list[str]] = Field(
4355
+ default=None,
4356
+ description="""Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided.""",
4357
+ )
4358
+ mode: Optional[FunctionCallingConfigMode] = Field(
4359
+ default=None, description="""Optional. Function calling mode."""
4360
+ )
4361
+ stream_function_call_arguments: Optional[bool] = Field(
4362
+ default=None,
4363
+ description="""Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field. This field is not supported in Gemini API.""",
4364
+ )
4365
+
4366
+
4367
+ class FunctionCallingConfigDict(TypedDict, total=False):
4368
+ """Function calling config."""
4369
+
4370
+ allowed_function_names: Optional[list[str]]
4371
+ """Optional. Function names to call. Only set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided."""
4372
+
4373
+ mode: Optional[FunctionCallingConfigMode]
4374
+ """Optional. Function calling mode."""
4375
+
4376
+ stream_function_call_arguments: Optional[bool]
4377
+ """Optional. When set to true, arguments of a single function call will be streamed out in multiple parts/contents/responses. Partial parameter results will be returned in the [FunctionCall.partial_args] field. This field is not supported in Gemini API."""
4378
+
4379
+
4380
+ FunctionCallingConfigOrDict = Union[
4381
+ FunctionCallingConfig, FunctionCallingConfigDict
4382
+ ]
4383
+
4384
+
4357
4385
  class ToolConfig(_common.BaseModel):
4358
4386
  """Tool config.
4359
4387
 
4360
4388
  This config is shared for all tools provided in the request.
4361
4389
  """
4362
4390
 
4363
- function_calling_config: Optional[FunctionCallingConfig] = Field(
4364
- default=None, description="""Optional. Function calling config."""
4365
- )
4366
4391
  retrieval_config: Optional[RetrievalConfig] = Field(
4367
4392
  default=None, description="""Optional. Retrieval config."""
4368
4393
  )
4394
+ function_calling_config: Optional[FunctionCallingConfig] = Field(
4395
+ default=None, description="""Optional. Function calling config."""
4396
+ )
4369
4397
 
4370
4398
 
4371
4399
  class ToolConfigDict(TypedDict, total=False):
@@ -4374,12 +4402,12 @@ class ToolConfigDict(TypedDict, total=False):
4374
4402
  This config is shared for all tools provided in the request.
4375
4403
  """
4376
4404
 
4377
- function_calling_config: Optional[FunctionCallingConfigDict]
4378
- """Optional. Function calling config."""
4379
-
4380
4405
  retrieval_config: Optional[RetrievalConfigDict]
4381
4406
  """Optional. Retrieval config."""
4382
4407
 
4408
+ function_calling_config: Optional[FunctionCallingConfigDict]
4409
+ """Optional. Function calling config."""
4410
+
4383
4411
 
4384
4412
  ToolConfigOrDict = Union[ToolConfig, ToolConfigDict]
4385
4413
 
@@ -4646,6 +4674,11 @@ class ImageConfig(_common.BaseModel):
4646
4674
  values are `1K`, `2K`, `4K`. If not specified, the model will use default
4647
4675
  value `1K`.""",
4648
4676
  )
4677
+ person_generation: Optional[str] = Field(
4678
+ default=None,
4679
+ description="""Controls the generation of people. Supported values are:
4680
+ ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.""",
4681
+ )
4649
4682
  output_mime_type: Optional[str] = Field(
4650
4683
  default=None,
4651
4684
  description="""MIME type of the generated image. This field is not
@@ -4670,6 +4703,10 @@ class ImageConfigDict(TypedDict, total=False):
4670
4703
  values are `1K`, `2K`, `4K`. If not specified, the model will use default
4671
4704
  value `1K`."""
4672
4705
 
4706
+ person_generation: Optional[str]
4707
+ """Controls the generation of people. Supported values are:
4708
+ ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE."""
4709
+
4673
4710
  output_mime_type: Optional[str]
4674
4711
  """MIME type of the generated image. This field is not
4675
4712
  supported in Gemini API."""
@@ -13921,6 +13958,85 @@ class DeleteFileResponseDict(TypedDict, total=False):
13921
13958
  DeleteFileResponseOrDict = Union[DeleteFileResponse, DeleteFileResponseDict]
13922
13959
 
13923
13960
 
13961
+ class RegisterFilesConfig(_common.BaseModel):
13962
+ """Used to override the default configuration."""
13963
+
13964
+ http_options: Optional[HttpOptions] = Field(
13965
+ default=None, description="""Used to override HTTP request options."""
13966
+ )
13967
+ should_return_http_response: Optional[bool] = Field(
13968
+ default=None,
13969
+ description=""" If true, the raw HTTP response will be returned in the 'sdk_http_response' field.""",
13970
+ )
13971
+
13972
+
13973
+ class RegisterFilesConfigDict(TypedDict, total=False):
13974
+ """Used to override the default configuration."""
13975
+
13976
+ http_options: Optional[HttpOptionsDict]
13977
+ """Used to override HTTP request options."""
13978
+
13979
+ should_return_http_response: Optional[bool]
13980
+ """ If true, the raw HTTP response will be returned in the 'sdk_http_response' field."""
13981
+
13982
+
13983
+ RegisterFilesConfigOrDict = Union[RegisterFilesConfig, RegisterFilesConfigDict]
13984
+
13985
+
13986
+ class _RegisterFilesParameters(_common.BaseModel):
13987
+ """Generates the parameters for the private _Register method."""
13988
+
13989
+ uris: Optional[list[str]] = Field(
13990
+ default=None,
13991
+ description="""The Google Cloud Storage URIs to register. Example: `gs://bucket/object`.""",
13992
+ )
13993
+ config: Optional[RegisterFilesConfig] = Field(
13994
+ default=None,
13995
+ description="""Used to override the default configuration.""",
13996
+ )
13997
+
13998
+
13999
+ class _RegisterFilesParametersDict(TypedDict, total=False):
14000
+ """Generates the parameters for the private _Register method."""
14001
+
14002
+ uris: Optional[list[str]]
14003
+ """The Google Cloud Storage URIs to register. Example: `gs://bucket/object`."""
14004
+
14005
+ config: Optional[RegisterFilesConfigDict]
14006
+ """Used to override the default configuration."""
14007
+
14008
+
14009
+ _RegisterFilesParametersOrDict = Union[
14010
+ _RegisterFilesParameters, _RegisterFilesParametersDict
14011
+ ]
14012
+
14013
+
14014
+ class RegisterFilesResponse(_common.BaseModel):
14015
+ """Response for the _register file method."""
14016
+
14017
+ sdk_http_response: Optional[HttpResponse] = Field(
14018
+ default=None, description="""Used to retain the full HTTP response."""
14019
+ )
14020
+ files: Optional[list[File]] = Field(
14021
+ default=None, description="""The registered files."""
14022
+ )
14023
+
14024
+
14025
+ class RegisterFilesResponseDict(TypedDict, total=False):
14026
+ """Response for the _register file method."""
14027
+
14028
+ sdk_http_response: Optional[HttpResponseDict]
14029
+ """Used to retain the full HTTP response."""
14030
+
14031
+ files: Optional[list[FileDict]]
14032
+ """The registered files."""
14033
+
14034
+
14035
+ RegisterFilesResponseOrDict = Union[
14036
+ RegisterFilesResponse, RegisterFilesResponseDict
14037
+ ]
14038
+
14039
+
13924
14040
  class InlinedRequest(_common.BaseModel):
13925
14041
  """Config for inlined request."""
13926
14042
 
@@ -16260,6 +16376,24 @@ VoiceActivityDetectionSignalOrDict = Union[
16260
16376
  ]
16261
16377
 
16262
16378
 
16379
+ class VoiceActivity(_common.BaseModel):
16380
+ """Voice activity signal."""
16381
+
16382
+ voice_activity_type: Optional[VoiceActivityType] = Field(
16383
+ default=None, description="""The type of the voice activity signal."""
16384
+ )
16385
+
16386
+
16387
+ class VoiceActivityDict(TypedDict, total=False):
16388
+ """Voice activity signal."""
16389
+
16390
+ voice_activity_type: Optional[VoiceActivityType]
16391
+ """The type of the voice activity signal."""
16392
+
16393
+
16394
+ VoiceActivityOrDict = Union[VoiceActivity, VoiceActivityDict]
16395
+
16396
+
16263
16397
  class LiveServerMessage(_common.BaseModel):
16264
16398
  """Response message for API call."""
16265
16399
 
@@ -16292,7 +16426,13 @@ class LiveServerMessage(_common.BaseModel):
16292
16426
  )
16293
16427
  )
16294
16428
  voice_activity_detection_signal: Optional[VoiceActivityDetectionSignal] = (
16295
- Field(default=None, description="""Voice activity detection signal.""")
16429
+ Field(
16430
+ default=None,
16431
+ description="""Voice activity detection signal. Allowlisted only.""",
16432
+ )
16433
+ )
16434
+ voice_activity: Optional[VoiceActivity] = Field(
16435
+ default=None, description="""Voice activity signal."""
16296
16436
  )
16297
16437
 
16298
16438
  @property
@@ -16391,7 +16531,10 @@ class LiveServerMessageDict(TypedDict, total=False):
16391
16531
  """Update of the session resumption state."""
16392
16532
 
16393
16533
  voice_activity_detection_signal: Optional[VoiceActivityDetectionSignalDict]
16394
- """Voice activity detection signal."""
16534
+ """Voice activity detection signal. Allowlisted only."""
16535
+
16536
+ voice_activity: Optional[VoiceActivityDict]
16537
+ """Voice activity signal."""
16395
16538
 
16396
16539
 
16397
16540
  LiveServerMessageOrDict = Union[LiveServerMessage, LiveServerMessageDict]