google-genai 1.55.0__py3-none-any.whl → 1.56.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 (241) hide show
  1. google/genai/_interactions/_base_client.py +8 -2
  2. google/genai/_interactions/resources/interactions.py +6 -6
  3. google/genai/_interactions/types/__init__.py +2 -0
  4. google/genai/_interactions/types/audio_content.py +0 -1
  5. google/genai/_interactions/types/audio_content_param.py +0 -1
  6. google/genai/_interactions/types/code_execution_call_content.py +0 -1
  7. google/genai/_interactions/types/code_execution_call_content_param.py +0 -1
  8. google/genai/_interactions/types/code_execution_result_content.py +0 -1
  9. google/genai/_interactions/types/code_execution_result_content_param.py +0 -1
  10. google/genai/_interactions/types/content_delta.py +7 -23
  11. google/genai/_interactions/types/deep_research_agent_config.py +0 -1
  12. google/genai/_interactions/types/deep_research_agent_config_param.py +0 -1
  13. google/genai/_interactions/types/document_content.py +3 -2
  14. google/genai/_interactions/types/document_content_param.py +3 -2
  15. google/genai/{tests/__init__.py → _interactions/types/document_mime_type.py} +5 -3
  16. google/genai/{tests/afc/__init__.py → _interactions/types/document_mime_type_param.py} +8 -4
  17. google/genai/_interactions/types/dynamic_agent_config.py +0 -1
  18. google/genai/_interactions/types/dynamic_agent_config_param.py +0 -1
  19. google/genai/_interactions/types/file_search_result_content.py +0 -1
  20. google/genai/_interactions/types/file_search_result_content_param.py +0 -1
  21. google/genai/_interactions/types/function_call_content.py +0 -1
  22. google/genai/_interactions/types/function_call_content_param.py +0 -1
  23. google/genai/_interactions/types/function_result_content.py +1 -2
  24. google/genai/_interactions/types/function_result_content_param.py +1 -2
  25. google/genai/_interactions/types/google_search_call_content.py +0 -1
  26. google/genai/_interactions/types/google_search_call_content_param.py +0 -1
  27. google/genai/_interactions/types/google_search_result_content.py +0 -1
  28. google/genai/_interactions/types/google_search_result_content_param.py +0 -1
  29. google/genai/_interactions/types/image_content.py +1 -2
  30. google/genai/_interactions/types/image_content_param.py +1 -2
  31. google/genai/_interactions/types/mcp_server_tool_call_content.py +0 -1
  32. google/genai/_interactions/types/mcp_server_tool_call_content_param.py +0 -1
  33. google/genai/_interactions/types/mcp_server_tool_result_content.py +1 -2
  34. google/genai/_interactions/types/mcp_server_tool_result_content_param.py +1 -2
  35. google/genai/_interactions/types/text_content.py +0 -1
  36. google/genai/_interactions/types/text_content_param.py +0 -1
  37. google/genai/_interactions/types/thinking_level.py +1 -1
  38. google/genai/_interactions/types/thought_content.py +0 -1
  39. google/genai/_interactions/types/thought_content_param.py +0 -1
  40. google/genai/_interactions/types/url_context_call_content.py +0 -1
  41. google/genai/_interactions/types/url_context_call_content_param.py +0 -1
  42. google/genai/_interactions/types/url_context_result_content.py +0 -1
  43. google/genai/_interactions/types/url_context_result_content_param.py +0 -1
  44. google/genai/_interactions/types/video_content.py +1 -2
  45. google/genai/_interactions/types/video_content_param.py +1 -2
  46. google/genai/_live_converters.py +2 -30
  47. google/genai/client.py +3 -1
  48. google/genai/models.py +2 -29
  49. google/genai/tunings.py +1 -27
  50. google/genai/types.py +20 -22
  51. google/genai/version.py +1 -1
  52. {google_genai-1.55.0.dist-info → google_genai-1.56.0.dist-info}/METADATA +224 -22
  53. google_genai-1.56.0.dist-info/RECORD +162 -0
  54. google/genai/tests/afc/test_convert_if_exist_pydantic_model.py +0 -309
  55. google/genai/tests/afc/test_convert_number_values_for_function_call_args.py +0 -63
  56. google/genai/tests/afc/test_find_afc_incompatible_tool_indexes.py +0 -240
  57. google/genai/tests/afc/test_generate_content_stream_afc.py +0 -530
  58. google/genai/tests/afc/test_generate_content_stream_afc_thoughts.py +0 -77
  59. google/genai/tests/afc/test_get_function_map.py +0 -176
  60. google/genai/tests/afc/test_get_function_response_parts.py +0 -277
  61. google/genai/tests/afc/test_get_max_remote_calls_for_afc.py +0 -130
  62. google/genai/tests/afc/test_invoke_function_from_dict_args.py +0 -241
  63. google/genai/tests/afc/test_raise_error_for_afc_incompatible_config.py +0 -159
  64. google/genai/tests/afc/test_should_append_afc_history.py +0 -53
  65. google/genai/tests/afc/test_should_disable_afc.py +0 -214
  66. google/genai/tests/batches/__init__.py +0 -17
  67. google/genai/tests/batches/test_cancel.py +0 -77
  68. google/genai/tests/batches/test_create.py +0 -78
  69. google/genai/tests/batches/test_create_with_bigquery.py +0 -113
  70. google/genai/tests/batches/test_create_with_file.py +0 -82
  71. google/genai/tests/batches/test_create_with_gcs.py +0 -125
  72. google/genai/tests/batches/test_create_with_inlined_requests.py +0 -255
  73. google/genai/tests/batches/test_delete.py +0 -86
  74. google/genai/tests/batches/test_embedding.py +0 -157
  75. google/genai/tests/batches/test_get.py +0 -78
  76. google/genai/tests/batches/test_list.py +0 -79
  77. google/genai/tests/caches/__init__.py +0 -17
  78. google/genai/tests/caches/constants.py +0 -29
  79. google/genai/tests/caches/test_create.py +0 -210
  80. google/genai/tests/caches/test_create_custom_url.py +0 -105
  81. google/genai/tests/caches/test_delete.py +0 -54
  82. google/genai/tests/caches/test_delete_custom_url.py +0 -52
  83. google/genai/tests/caches/test_get.py +0 -94
  84. google/genai/tests/caches/test_get_custom_url.py +0 -52
  85. google/genai/tests/caches/test_list.py +0 -68
  86. google/genai/tests/caches/test_update.py +0 -70
  87. google/genai/tests/caches/test_update_custom_url.py +0 -58
  88. google/genai/tests/chats/__init__.py +0 -1
  89. google/genai/tests/chats/test_get_history.py +0 -597
  90. google/genai/tests/chats/test_send_message.py +0 -844
  91. google/genai/tests/chats/test_validate_response.py +0 -90
  92. google/genai/tests/client/__init__.py +0 -17
  93. google/genai/tests/client/test_async_stream.py +0 -427
  94. google/genai/tests/client/test_client_close.py +0 -197
  95. google/genai/tests/client/test_client_initialization.py +0 -1687
  96. google/genai/tests/client/test_client_requests.py +0 -355
  97. google/genai/tests/client/test_custom_client.py +0 -77
  98. google/genai/tests/client/test_http_options.py +0 -178
  99. google/genai/tests/client/test_replay_client_equality.py +0 -168
  100. google/genai/tests/client/test_retries.py +0 -846
  101. google/genai/tests/client/test_upload_errors.py +0 -136
  102. google/genai/tests/common/__init__.py +0 -17
  103. google/genai/tests/common/test_common.py +0 -954
  104. google/genai/tests/conftest.py +0 -162
  105. google/genai/tests/documents/__init__.py +0 -17
  106. google/genai/tests/documents/test_delete.py +0 -51
  107. google/genai/tests/documents/test_get.py +0 -85
  108. google/genai/tests/documents/test_list.py +0 -72
  109. google/genai/tests/errors/__init__.py +0 -1
  110. google/genai/tests/errors/test_api_error.py +0 -417
  111. google/genai/tests/file_search_stores/__init__.py +0 -17
  112. google/genai/tests/file_search_stores/test_create.py +0 -66
  113. google/genai/tests/file_search_stores/test_delete.py +0 -64
  114. google/genai/tests/file_search_stores/test_get.py +0 -94
  115. google/genai/tests/file_search_stores/test_import_file.py +0 -112
  116. google/genai/tests/file_search_stores/test_list.py +0 -57
  117. google/genai/tests/file_search_stores/test_upload_to_file_search_store.py +0 -141
  118. google/genai/tests/files/__init__.py +0 -17
  119. google/genai/tests/files/test_delete.py +0 -46
  120. google/genai/tests/files/test_download.py +0 -85
  121. google/genai/tests/files/test_get.py +0 -46
  122. google/genai/tests/files/test_list.py +0 -72
  123. google/genai/tests/files/test_upload.py +0 -255
  124. google/genai/tests/imports/test_no_optional_imports.py +0 -28
  125. google/genai/tests/interactions/test_integration.py +0 -80
  126. google/genai/tests/live/__init__.py +0 -16
  127. google/genai/tests/live/test_live.py +0 -2177
  128. google/genai/tests/live/test_live_music.py +0 -362
  129. google/genai/tests/live/test_live_response.py +0 -163
  130. google/genai/tests/live/test_send_client_content.py +0 -147
  131. google/genai/tests/live/test_send_realtime_input.py +0 -268
  132. google/genai/tests/live/test_send_tool_response.py +0 -222
  133. google/genai/tests/local_tokenizer/__init__.py +0 -17
  134. google/genai/tests/local_tokenizer/test_local_tokenizer.py +0 -343
  135. google/genai/tests/local_tokenizer/test_local_tokenizer_loader.py +0 -235
  136. google/genai/tests/mcp/__init__.py +0 -17
  137. google/genai/tests/mcp/test_has_mcp_tool_usage.py +0 -89
  138. google/genai/tests/mcp/test_mcp_to_gemini_tools.py +0 -191
  139. google/genai/tests/mcp/test_parse_config_for_mcp_sessions.py +0 -201
  140. google/genai/tests/mcp/test_parse_config_for_mcp_usage.py +0 -130
  141. google/genai/tests/mcp/test_set_mcp_usage_header.py +0 -72
  142. google/genai/tests/models/__init__.py +0 -17
  143. google/genai/tests/models/constants.py +0 -8
  144. google/genai/tests/models/test_compute_tokens.py +0 -120
  145. google/genai/tests/models/test_count_tokens.py +0 -159
  146. google/genai/tests/models/test_delete.py +0 -107
  147. google/genai/tests/models/test_edit_image.py +0 -264
  148. google/genai/tests/models/test_embed_content.py +0 -94
  149. google/genai/tests/models/test_function_call_streaming.py +0 -442
  150. google/genai/tests/models/test_generate_content.py +0 -2502
  151. google/genai/tests/models/test_generate_content_cached_content.py +0 -132
  152. google/genai/tests/models/test_generate_content_config_zero_value.py +0 -103
  153. google/genai/tests/models/test_generate_content_from_apikey.py +0 -44
  154. google/genai/tests/models/test_generate_content_http_options.py +0 -40
  155. google/genai/tests/models/test_generate_content_image_generation.py +0 -143
  156. google/genai/tests/models/test_generate_content_mcp.py +0 -343
  157. google/genai/tests/models/test_generate_content_media_resolution.py +0 -97
  158. google/genai/tests/models/test_generate_content_model.py +0 -139
  159. google/genai/tests/models/test_generate_content_part.py +0 -821
  160. google/genai/tests/models/test_generate_content_thought.py +0 -76
  161. google/genai/tests/models/test_generate_content_tools.py +0 -1761
  162. google/genai/tests/models/test_generate_images.py +0 -191
  163. google/genai/tests/models/test_generate_videos.py +0 -759
  164. google/genai/tests/models/test_get.py +0 -104
  165. google/genai/tests/models/test_list.py +0 -233
  166. google/genai/tests/models/test_recontext_image.py +0 -189
  167. google/genai/tests/models/test_segment_image.py +0 -148
  168. google/genai/tests/models/test_update.py +0 -95
  169. google/genai/tests/models/test_upscale_image.py +0 -157
  170. google/genai/tests/operations/__init__.py +0 -17
  171. google/genai/tests/operations/test_get.py +0 -38
  172. google/genai/tests/public_samples/__init__.py +0 -17
  173. google/genai/tests/public_samples/test_gemini_text_only.py +0 -34
  174. google/genai/tests/pytest_helper.py +0 -229
  175. google/genai/tests/shared/__init__.py +0 -16
  176. google/genai/tests/shared/batches/__init__.py +0 -14
  177. google/genai/tests/shared/batches/test_create_delete.py +0 -57
  178. google/genai/tests/shared/batches/test_create_get_cancel.py +0 -56
  179. google/genai/tests/shared/batches/test_list.py +0 -40
  180. google/genai/tests/shared/caches/__init__.py +0 -14
  181. google/genai/tests/shared/caches/test_create_get_delete.py +0 -67
  182. google/genai/tests/shared/caches/test_create_update_get.py +0 -71
  183. google/genai/tests/shared/caches/test_list.py +0 -40
  184. google/genai/tests/shared/chats/__init__.py +0 -14
  185. google/genai/tests/shared/chats/test_send_message.py +0 -48
  186. google/genai/tests/shared/chats/test_send_message_stream.py +0 -50
  187. google/genai/tests/shared/files/__init__.py +0 -14
  188. google/genai/tests/shared/files/test_list.py +0 -41
  189. google/genai/tests/shared/files/test_upload_get_delete.py +0 -54
  190. google/genai/tests/shared/models/__init__.py +0 -14
  191. google/genai/tests/shared/models/test_compute_tokens.py +0 -41
  192. google/genai/tests/shared/models/test_count_tokens.py +0 -40
  193. google/genai/tests/shared/models/test_edit_image.py +0 -67
  194. google/genai/tests/shared/models/test_embed.py +0 -40
  195. google/genai/tests/shared/models/test_generate_content.py +0 -39
  196. google/genai/tests/shared/models/test_generate_content_stream.py +0 -54
  197. google/genai/tests/shared/models/test_generate_images.py +0 -40
  198. google/genai/tests/shared/models/test_generate_videos.py +0 -38
  199. google/genai/tests/shared/models/test_list.py +0 -37
  200. google/genai/tests/shared/models/test_recontext_image.py +0 -55
  201. google/genai/tests/shared/models/test_segment_image.py +0 -52
  202. google/genai/tests/shared/models/test_upscale_image.py +0 -52
  203. google/genai/tests/shared/tunings/__init__.py +0 -16
  204. google/genai/tests/shared/tunings/test_create.py +0 -46
  205. google/genai/tests/shared/tunings/test_create_get_cancel.py +0 -56
  206. google/genai/tests/shared/tunings/test_list.py +0 -39
  207. google/genai/tests/tokens/__init__.py +0 -16
  208. google/genai/tests/tokens/test_create.py +0 -154
  209. google/genai/tests/transformers/__init__.py +0 -17
  210. google/genai/tests/transformers/test_blobs.py +0 -71
  211. google/genai/tests/transformers/test_bytes.py +0 -15
  212. google/genai/tests/transformers/test_duck_type.py +0 -96
  213. google/genai/tests/transformers/test_function_responses.py +0 -72
  214. google/genai/tests/transformers/test_schema.py +0 -653
  215. google/genai/tests/transformers/test_t_batch.py +0 -286
  216. google/genai/tests/transformers/test_t_content.py +0 -160
  217. google/genai/tests/transformers/test_t_contents.py +0 -398
  218. google/genai/tests/transformers/test_t_part.py +0 -85
  219. google/genai/tests/transformers/test_t_parts.py +0 -87
  220. google/genai/tests/transformers/test_t_tool.py +0 -157
  221. google/genai/tests/transformers/test_t_tools.py +0 -195
  222. google/genai/tests/tunings/__init__.py +0 -16
  223. google/genai/tests/tunings/test_cancel.py +0 -39
  224. google/genai/tests/tunings/test_end_to_end.py +0 -106
  225. google/genai/tests/tunings/test_get.py +0 -67
  226. google/genai/tests/tunings/test_list.py +0 -75
  227. google/genai/tests/tunings/test_tune.py +0 -268
  228. google/genai/tests/types/__init__.py +0 -16
  229. google/genai/tests/types/test_bytes_internal.py +0 -271
  230. google/genai/tests/types/test_bytes_type.py +0 -152
  231. google/genai/tests/types/test_future.py +0 -101
  232. google/genai/tests/types/test_optional_types.py +0 -36
  233. google/genai/tests/types/test_part_type.py +0 -616
  234. google/genai/tests/types/test_schema_from_json_schema.py +0 -417
  235. google/genai/tests/types/test_schema_json_schema.py +0 -468
  236. google/genai/tests/types/test_types.py +0 -2903
  237. google_genai-1.55.0.dist-info/RECORD +0 -345
  238. /google/genai/{tests/interactions/__init__.py → _interactions/py.typed} +0 -0
  239. {google_genai-1.55.0.dist-info → google_genai-1.56.0.dist-info}/WHEEL +0 -0
  240. {google_genai-1.55.0.dist-info → google_genai-1.56.0.dist-info}/licenses/LICENSE +0 -0
  241. {google_genai-1.55.0.dist-info → google_genai-1.56.0.dist-info}/top_level.txt +0 -0
@@ -1,759 +0,0 @@
1
- # Copyright 2025 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
-
16
-
17
- """Tests for generate_videos."""
18
-
19
- import os
20
- import time
21
- import pytest
22
-
23
- from ... import _replay_api_client
24
- from ... import types
25
- from .. import pytest_helper
26
-
27
- VEO_MODEL_LATEST = "veo-3.1-generate-preview"
28
- VEO_MODEL_2 = "veo-2.0-generate-001"
29
- VEO_MODEL_2_EXP = "veo-2.0-generate-exp"
30
-
31
- OUTPUT_GCS_URI = "gs://genai-sdk-tests/temp/videos/"
32
-
33
- GCS_IMAGE = types.Image(
34
- gcs_uri="gs://cloud-samples-data/vertex-ai/llm/prompts/landmark1.png",
35
- # Required
36
- mime_type="image/png",
37
- )
38
-
39
- GCS_IMAGE2 = types.Image(
40
- gcs_uri="gs://cloud-samples-data/vertex-ai/llm/prompts/landmark2.png",
41
- # Required
42
- mime_type="image/png",
43
- )
44
-
45
- IMAGE_FILE_PATH = os.path.abspath(
46
- os.path.join(os.path.dirname(__file__), "../data/bridge1.png")
47
- )
48
- LOCAL_IMAGE = types.Image.from_file(location=IMAGE_FILE_PATH)
49
-
50
- LOCAL_IMAGE_MAN = types.Image.from_file(
51
- location=os.path.abspath(
52
- os.path.join(os.path.dirname(__file__), "../data/man.jpg")
53
- )
54
- )
55
-
56
- LOCAL_IMAGE_DOG = types.Image.from_file(
57
- location=os.path.abspath(
58
- os.path.join(os.path.dirname(__file__), "../data/dog.jpg")
59
- )
60
- )
61
-
62
- GCS_OUTPAINT_MASK = types.Image(
63
- gcs_uri="gs://genai-sdk-tests/inputs/videos/video_outpaint_mask.png",
64
- mime_type="image/png",
65
- )
66
-
67
- GCS_REMOVE_MASK = types.Image(
68
- gcs_uri="gs://genai-sdk-tests/inputs/videos/video_remove_mask.png",
69
- mime_type="image/png",
70
- )
71
-
72
- GCS_REMOVE_STATIC_MASK = types.Image(
73
- gcs_uri="gs://genai-sdk-tests/inputs/videos/video_remove_static_mask.png",
74
- mime_type="image/png",
75
- )
76
-
77
-
78
- test_table: list[pytest_helper.TestTableItem] = [
79
- pytest_helper.TestTableItem(
80
- name="test_simple_prompt",
81
- parameters=types._GenerateVideosParameters(
82
- model=VEO_MODEL_LATEST,
83
- prompt="Man with a dog",
84
- ),
85
- ),
86
- pytest_helper.TestTableItem(
87
- name="test_all_parameters_vertex",
88
- parameters=types._GenerateVideosParameters(
89
- model=VEO_MODEL_LATEST,
90
- prompt="A neon hologram of a cat driving at top speed",
91
- config=types.GenerateVideosConfig(
92
- number_of_videos=1,
93
- output_gcs_uri=OUTPUT_GCS_URI,
94
- fps=30,
95
- duration_seconds=6,
96
- seed=1,
97
- aspect_ratio="16:9",
98
- resolution="720p",
99
- person_generation="allow_adult",
100
- # pubsub_topic="projects/<my-project>/topics/video-generation-test",
101
- negative_prompt="ugly, low quality",
102
- enhance_prompt=True,
103
- compression_quality=types.VideoCompressionQuality.LOSSLESS,
104
- ),
105
- ),
106
- exception_if_mldev=(
107
- "not supported in Gemini API"
108
- ),
109
- ),
110
- pytest_helper.TestTableItem(
111
- name="test_from_text_source",
112
- parameters=types._GenerateVideosParameters(
113
- model=VEO_MODEL_LATEST,
114
- source=types.GenerateVideosSource(prompt="Man with a dog"),
115
- config=types.GenerateVideosConfig(
116
- number_of_videos=1,
117
- ),
118
- ),
119
- ),
120
- pytest_helper.TestTableItem(
121
- name="test_from_image_source",
122
- parameters=types._GenerateVideosParameters(
123
- model=VEO_MODEL_LATEST,
124
- source=types.GenerateVideosSource(
125
- image=LOCAL_IMAGE,
126
- ),
127
- config=types.GenerateVideosConfig(
128
- number_of_videos=1,
129
- ),
130
- ),
131
- ),
132
- pytest_helper.TestTableItem(
133
- name="test_from_text_and_image_source",
134
- parameters=types._GenerateVideosParameters(
135
- model=VEO_MODEL_LATEST,
136
- source=types.GenerateVideosSource(
137
- prompt="Lightning storm",
138
- image=LOCAL_IMAGE,
139
- ),
140
- config=types.GenerateVideosConfig(
141
- number_of_videos=1,
142
- ),
143
- ),
144
- ),
145
- pytest_helper.TestTableItem(
146
- name="test_from_video_source",
147
- parameters=types._GenerateVideosParameters(
148
- model=VEO_MODEL_LATEST,
149
- source=types.GenerateVideosSource(
150
- video=types.Video(
151
- uri="gs://genai-sdk-tests/inputs/videos/cat_driving.mp4",
152
- mime_type="video/mp4",
153
- ),
154
- ),
155
- config=types.GenerateVideosConfig(
156
- number_of_videos=1,
157
- output_gcs_uri=OUTPUT_GCS_URI,
158
- ),
159
- ),
160
- exception_if_mldev=(
161
- "output_gcs_uri parameter is not supported in Gemini API"
162
- ),
163
- ),
164
- pytest_helper.TestTableItem(
165
- name="test_from_text_and_video_source",
166
- parameters=types._GenerateVideosParameters(
167
- model=VEO_MODEL_LATEST,
168
- source=types.GenerateVideosSource(
169
- prompt="Rain",
170
- video=types.Video(
171
- uri="gs://genai-sdk-tests/inputs/videos/cat_driving.mp4",
172
- mime_type="video/mp4",
173
- ),
174
- ),
175
- config=types.GenerateVideosConfig(
176
- number_of_videos=1,
177
- output_gcs_uri=OUTPUT_GCS_URI,
178
- ),
179
- ),
180
- exception_if_mldev=(
181
- "output_gcs_uri parameter is not supported in Gemini API"
182
- ),
183
- ),
184
- pytest_helper.TestTableItem(
185
- name="test_video_edit_outpaint",
186
- parameters=types._GenerateVideosParameters(
187
- model=VEO_MODEL_2_EXP,
188
- source=types.GenerateVideosSource(
189
- prompt="A mountain landscape",
190
- video=types.Video(
191
- uri="gs://genai-sdk-tests/inputs/videos/editing_demo.mp4",
192
- mime_type="video/mp4",
193
- ),
194
- ),
195
- config=types.GenerateVideosConfig(
196
- output_gcs_uri=OUTPUT_GCS_URI,
197
- aspect_ratio="16:9",
198
- mask=types.VideoGenerationMask(
199
- image=GCS_OUTPAINT_MASK,
200
- mask_mode=types.VideoGenerationMaskMode.OUTPAINT,
201
- ),
202
- ),
203
- ),
204
- exception_if_mldev=(
205
- "not supported in Gemini API"
206
- ),
207
- ),
208
- pytest_helper.TestTableItem(
209
- name="test_all_parameters_mldev",
210
- parameters=types._GenerateVideosParameters(
211
- model=VEO_MODEL_2,
212
- prompt="A neon hologram of a cat driving at top speed",
213
- config=types.GenerateVideosConfig(
214
- number_of_videos=1,
215
- duration_seconds=6,
216
- aspect_ratio="16:9",
217
- person_generation="allow_adult",
218
- negative_prompt="ugly, low quality",
219
- enhance_prompt=True,
220
- ),
221
- ),
222
- ),
223
- pytest_helper.TestTableItem(
224
- name="test_all_parameters_veo3_mldev",
225
- parameters=types._GenerateVideosParameters(
226
- model=VEO_MODEL_LATEST,
227
- prompt="A neon hologram of a cat driving at top speed",
228
- config=types.GenerateVideosConfig(
229
- number_of_videos=1,
230
- aspect_ratio="16:9",
231
- resolution="1080p",
232
- negative_prompt="ugly, low quality",
233
- ),
234
- ),
235
- ),
236
- pytest_helper.TestTableItem(
237
- name="test_reference_to_video",
238
- parameters=types._GenerateVideosParameters(
239
- model=VEO_MODEL_LATEST,
240
- prompt="Rain",
241
- config=types.GenerateVideosConfig(
242
- output_gcs_uri=OUTPUT_GCS_URI,
243
- reference_images=[
244
- types.VideoGenerationReferenceImage(
245
- image=GCS_IMAGE,
246
- reference_type=types.VideoGenerationReferenceType.ASSET,
247
- )
248
- ],
249
- ),
250
- ),
251
- exception_if_mldev=(
252
- "output_gcs_uri parameter is not supported in Gemini API"
253
- ),
254
- ),
255
- ]
256
-
257
- pytestmark = pytest_helper.setup(
258
- file=__file__,
259
- globals_for_file=globals(),
260
- test_method="models.generate_videos",
261
- test_table=test_table,
262
- )
263
-
264
-
265
- def test_text_to_video_poll(client):
266
- operation = client.models.generate_videos(
267
- model=VEO_MODEL_LATEST,
268
- prompt="A neon hologram of a cat driving at top speed",
269
- config=types.GenerateVideosConfig(
270
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
271
- ),
272
- )
273
- while not operation.done:
274
- # Skip the sleep when in replay mode.
275
- if client._api_client._mode not in ("replay", "auto"):
276
- time.sleep(20)
277
- operation = client.operations.get(operation=operation)
278
-
279
- assert operation.result.generated_videos[0].video.uri
280
-
281
-
282
- def test_image_to_video_poll(client):
283
- operation = client.models.generate_videos(
284
- model=VEO_MODEL_LATEST,
285
- image=GCS_IMAGE if client.vertexai else LOCAL_IMAGE,
286
- config=types.GenerateVideosConfig(
287
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
288
- ),
289
- )
290
- while not operation.done:
291
- # Skip the sleep when in replay mode.
292
- if client._api_client._mode not in ("replay", "auto"):
293
- time.sleep(20)
294
- operation = client.operations.get(operation=operation)
295
-
296
- assert operation.result.generated_videos[0].video.uri
297
-
298
-
299
- def test_text_and_image_to_video_poll(client):
300
- operation = client.models.generate_videos(
301
- model=VEO_MODEL_LATEST,
302
- prompt="Lightning storm",
303
- image=GCS_IMAGE if client.vertexai else LOCAL_IMAGE,
304
- config=types.GenerateVideosConfig(
305
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
306
- ),
307
- )
308
- while not operation.done:
309
- # Skip the sleep when in replay mode.
310
- if client._api_client._mode not in ("replay", "auto"):
311
- time.sleep(20)
312
- operation = client.operations.get(operation=operation)
313
-
314
- assert operation.result.generated_videos[0].video.uri
315
-
316
-
317
- def test_video_to_video_poll(client):
318
- # GCS URI video input is only supported in Vertex AI.
319
- if not client.vertexai:
320
- return
321
-
322
- operation = client.models.generate_videos(
323
- model=VEO_MODEL_2,
324
- video=types.Video(
325
- uri="gs://genai-sdk-tests/inputs/videos/cat_driving.mp4",
326
- mime_type="video/mp4",
327
- ),
328
- config=types.GenerateVideosConfig(
329
- output_gcs_uri=OUTPUT_GCS_URI,
330
- ),
331
- )
332
- while not operation.done:
333
- # Skip the sleep when in replay mode.
334
- if client._api_client._mode not in ("replay", "auto"):
335
- time.sleep(20)
336
- operation = client.operations.get(operation=operation)
337
-
338
- assert operation.result.generated_videos[0].video.uri
339
-
340
-
341
- def test_text_and_video_to_video_poll(client):
342
- # GCS URI video input is only supported in Vertex AI.
343
- if not client.vertexai:
344
- return
345
-
346
- operation = client.models.generate_videos(
347
- model=VEO_MODEL_2,
348
- prompt="Rain",
349
- video=types.Video(
350
- uri="gs://genai-sdk-tests/inputs/videos/cat_driving.mp4",
351
- mime_type="video/mp4",
352
- ),
353
- config=types.GenerateVideosConfig(
354
- output_gcs_uri=OUTPUT_GCS_URI,
355
- ),
356
- )
357
- while not operation.done:
358
- # Skip the sleep when in replay mode.
359
- if client._api_client._mode not in ("replay", "auto"):
360
- time.sleep(20)
361
- operation = client.operations.get(operation=operation)
362
-
363
- assert operation.result.generated_videos[0].video.uri
364
-
365
-
366
- def test_generated_video_extension_poll(client):
367
- # Gemini API only supports video extension on generated videos.
368
- if client.vertexai:
369
- return
370
-
371
- operation1 = client.models.generate_videos(
372
- model=VEO_MODEL_LATEST,
373
- prompt="Rain",
374
- config=types.GenerateVideosConfig(
375
- number_of_videos=1,
376
- ),
377
- )
378
- while not operation1.done:
379
- # Skip the sleep when in replay mode.
380
- if client._api_client._mode not in ("replay", "auto"):
381
- time.sleep(20)
382
- operation1 = client.operations.get(operation=operation1)
383
-
384
- video1 = operation1.result.generated_videos[0].video
385
- assert video1.uri
386
- client.files.download(file=video1)
387
- assert video1.video_bytes
388
-
389
- operation2 = client.models.generate_videos(
390
- model=VEO_MODEL_LATEST,
391
- prompt="Sun",
392
- video=video1,
393
- config=types.GenerateVideosConfig(
394
- number_of_videos=1,
395
- ),
396
- )
397
- while not operation2.done:
398
- # Skip the sleep when in replay mode.
399
- if client._api_client._mode not in ("replay", "auto"):
400
- time.sleep(20)
401
- operation2 = client.operations.get(operation=operation2)
402
-
403
- video2 = operation2.result.generated_videos[0].video
404
- assert video2.uri
405
- client.files.download(file=video2)
406
- assert video2.video_bytes
407
-
408
-
409
- def test_generated_video_extension_from_source_poll(client):
410
- # Gemini API only supports video extension on generated videos.
411
- if client.vertexai:
412
- return
413
-
414
- operation1 = client.models.generate_videos(
415
- model=VEO_MODEL_LATEST,
416
- prompt="Rain",
417
- config=types.GenerateVideosConfig(
418
- number_of_videos=1,
419
- ),
420
- )
421
- while not operation1.done:
422
- # Skip the sleep when in replay mode.
423
- if client._api_client._mode not in ("replay", "auto"):
424
- time.sleep(20)
425
- operation1 = client.operations.get(operation=operation1)
426
-
427
- video1 = operation1.result.generated_videos[0].video
428
- assert video1.uri
429
- client.files.download(file=video1)
430
- assert video1.video_bytes
431
-
432
- operation2 = client.models.generate_videos(
433
- model=VEO_MODEL_LATEST,
434
- source=types.GenerateVideosSource(
435
- prompt="Sun",
436
- video=video1
437
- ),
438
- config=types.GenerateVideosConfig(
439
- number_of_videos=1,
440
- ),
441
- )
442
- while not operation2.done:
443
- # Skip the sleep when in replay mode.
444
- if client._api_client._mode not in ("replay", "auto"):
445
- time.sleep(20)
446
- operation2 = client.operations.get(operation=operation2)
447
-
448
- video2 = operation2.result.generated_videos[0].video
449
- assert video2.uri
450
- client.files.download(file=video2)
451
- assert video2.video_bytes
452
-
453
-
454
- def test_generated_video_extension_from_source_dict_poll(client):
455
- # Gemini API only supports video extension on generated videos.
456
- if client.vertexai:
457
- return
458
-
459
- operation1 = client.models.generate_videos(
460
- model=VEO_MODEL_LATEST,
461
- prompt="Rain",
462
- config=types.GenerateVideosConfig(
463
- number_of_videos=1,
464
- ),
465
- )
466
- while not operation1.done:
467
- # Skip the sleep when in replay mode.
468
- if client._api_client._mode not in ("replay", "auto"):
469
- time.sleep(20)
470
- operation1 = client.operations.get(operation=operation1)
471
-
472
- video1 = operation1.result.generated_videos[0].video
473
- assert video1.uri
474
- client.files.download(file=video1)
475
- assert video1.video_bytes
476
-
477
- operation2 = client.models.generate_videos(
478
- model=VEO_MODEL_LATEST,
479
- source={
480
- "prompt": "Sun",
481
- "video": video1,
482
- },
483
- config=types.GenerateVideosConfig(
484
- number_of_videos=1,
485
- ),
486
- )
487
- while not operation2.done:
488
- # Skip the sleep when in replay mode.
489
- if client._api_client._mode not in ("replay", "auto"):
490
- time.sleep(20)
491
- operation2 = client.operations.get(operation=operation2)
492
-
493
- video2 = operation2.result.generated_videos[0].video
494
- assert video2.uri
495
- client.files.download(file=video2)
496
- assert video2.video_bytes
497
-
498
-
499
- def test_image_to_video_frame_interpolation_poll(client):
500
- operation = client.models.generate_videos(
501
- model=VEO_MODEL_LATEST,
502
- prompt="Rain",
503
- image=GCS_IMAGE if client.vertexai else LOCAL_IMAGE_MAN,
504
- config=types.GenerateVideosConfig(
505
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
506
- last_frame=GCS_IMAGE2 if client.vertexai else LOCAL_IMAGE_DOG,
507
- ),
508
- )
509
- while not operation.done:
510
- # Skip the sleep when in replay mode.
511
- if client._api_client._mode not in ("replay", "auto"):
512
- time.sleep(20)
513
- operation = client.operations.get(operation=operation)
514
-
515
- assert operation.result.generated_videos[0].video.uri
516
-
517
-
518
- def test_reference_images_to_video_poll(client):
519
- operation = client.models.generate_videos(
520
- model=VEO_MODEL_LATEST,
521
- prompt="Chirping birds in a colorful forest",
522
- config=types.GenerateVideosConfig(
523
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
524
- reference_images=[
525
- types.VideoGenerationReferenceImage(
526
- image=GCS_IMAGE if client.vertexai else LOCAL_IMAGE_MAN,
527
- reference_type=types.VideoGenerationReferenceType.ASSET,
528
- ),
529
- ],
530
- ),
531
- )
532
- while not operation.done:
533
- # Skip the sleep when in replay mode.
534
- if client._api_client._mode not in ("replay", "auto"):
535
- time.sleep(20)
536
- operation = client.operations.get(operation=operation)
537
-
538
- assert operation.result.generated_videos[0].video.uri
539
-
540
-
541
- def test_video_edit_outpaint_poll(client):
542
- # Editing videos is only supported in Vertex AI.
543
- if not client.vertexai:
544
- return
545
-
546
- operation = client.models.generate_videos(
547
- model=VEO_MODEL_2_EXP,
548
- source=types.GenerateVideosSource(
549
- prompt="A mountain landscape",
550
- video=types.Video(
551
- uri="gs://genai-sdk-tests/inputs/videos/editing_demo.mp4",
552
- mime_type="video/mp4",
553
- ),
554
- ),
555
- config=types.GenerateVideosConfig(
556
- output_gcs_uri=OUTPUT_GCS_URI,
557
- aspect_ratio="16:9",
558
- mask=types.VideoGenerationMask(
559
- image=GCS_OUTPAINT_MASK,
560
- mask_mode=types.VideoGenerationMaskMode.OUTPAINT,
561
- ),
562
- ),
563
- )
564
- while not operation.done:
565
- # Skip the sleep when in replay mode.
566
- if client._api_client._mode not in ("replay", "auto"):
567
- time.sleep(20)
568
- operation = client.operations.get(operation=operation)
569
-
570
- assert operation.result.generated_videos[0].video.uri
571
-
572
-
573
- def test_video_edit_remove_poll(client):
574
- # Editing videos is only supported in Vertex AI.
575
- if not client.vertexai:
576
- return
577
-
578
- operation = client.models.generate_videos(
579
- model=VEO_MODEL_2_EXP,
580
- source=types.GenerateVideosSource(
581
- prompt="A red dune buggy",
582
- video=types.Video(
583
- uri="gs://genai-sdk-tests/inputs/videos/editing_demo.mp4",
584
- mime_type="video/mp4",
585
- ),
586
- ),
587
- config=types.GenerateVideosConfig(
588
- output_gcs_uri=OUTPUT_GCS_URI,
589
- aspect_ratio="16:9",
590
- mask=types.VideoGenerationMask(
591
- image=GCS_REMOVE_MASK,
592
- mask_mode=types.VideoGenerationMaskMode.REMOVE,
593
- ),
594
- ),
595
- )
596
- while not operation.done:
597
- # Skip the sleep when in replay mode.
598
- if client._api_client._mode not in ("replay", "auto"):
599
- time.sleep(20)
600
- operation = client.operations.get(operation=operation)
601
-
602
- assert operation.result.generated_videos[0].video.uri
603
-
604
-
605
- def test_video_edit_remove_static_poll(client):
606
- # Editing videos is only supported in Vertex AI.
607
- if not client.vertexai:
608
- return
609
-
610
- operation = client.models.generate_videos(
611
- model=VEO_MODEL_2_EXP,
612
- source=types.GenerateVideosSource(
613
- prompt="A red dune buggy",
614
- video=types.Video(
615
- uri="gs://genai-sdk-tests/inputs/videos/editing_demo.mp4",
616
- mime_type="video/mp4",
617
- ),
618
- ),
619
- config=types.GenerateVideosConfig(
620
- output_gcs_uri=OUTPUT_GCS_URI,
621
- aspect_ratio="16:9",
622
- mask=types.VideoGenerationMask(
623
- image=GCS_REMOVE_STATIC_MASK,
624
- mask_mode=types.VideoGenerationMaskMode.REMOVE_STATIC,
625
- ),
626
- ),
627
- )
628
- while not operation.done:
629
- # Skip the sleep when in replay mode.
630
- if client._api_client._mode not in ("replay", "auto"):
631
- time.sleep(20)
632
- operation = client.operations.get(operation=operation)
633
-
634
- assert operation.result.generated_videos[0].video.uri
635
-
636
-
637
- def test_video_edit_insert_poll(client):
638
- # Editing videos is only supported in Vertex AI.
639
- if not client.vertexai:
640
- return
641
-
642
- operation = client.models.generate_videos(
643
- model=VEO_MODEL_2_EXP,
644
- source=types.GenerateVideosSource(
645
- prompt="Bike",
646
- video=types.Video(
647
- uri="gs://genai-sdk-tests/inputs/videos/editing_demo.mp4",
648
- mime_type="video/mp4",
649
- ),
650
- ),
651
- config=types.GenerateVideosConfig(
652
- output_gcs_uri=OUTPUT_GCS_URI,
653
- aspect_ratio="16:9",
654
- mask=types.VideoGenerationMask(
655
- # Insert and remove masks are the same for this input.
656
- image=GCS_REMOVE_MASK,
657
- mask_mode=types.VideoGenerationMaskMode.INSERT,
658
- ),
659
- ),
660
- )
661
- while not operation.done:
662
- # Skip the sleep when in replay mode.
663
- if client._api_client._mode not in ("replay", "auto"):
664
- time.sleep(20)
665
- operation = client.operations.get(operation=operation)
666
-
667
- assert operation.result.generated_videos[0].video.uri
668
-
669
-
670
- def test_create_operation_to_poll(client):
671
- if client.vertexai:
672
- # Fill in project and location for record mode
673
- operation_name = "projects/<project>/locations/<location>/publishers/google/models/veo-3.1-generate-preview/operations/9d2fc0b5-5bdf-4b5f-9a41-82970515e20b"
674
- else:
675
- operation_name = "models/veo-3.1-generate-preview/operations/vz341u0pmdlc"
676
-
677
- operation = types.GenerateVideosOperation(
678
- name=operation_name,
679
- )
680
- operation = client.operations.get(operation=operation)
681
- while not operation.done:
682
- # Skip the sleep when in replay mode.
683
- if client._api_client._mode not in ("replay", "auto"):
684
- time.sleep(20)
685
- operation = client.operations.get(operation=operation)
686
-
687
- assert operation.result.generated_videos[0].video.uri
688
-
689
-
690
- def test_source_and_prompt_raises(client):
691
- with pytest.raises(ValueError):
692
- client.models.generate_videos(
693
- model=VEO_MODEL_LATEST,
694
- prompt="Prompt 1",
695
- source=types.GenerateVideosSource(prompt="Prompt 2"),
696
- )
697
-
698
-
699
- @pytest.mark.asyncio
700
- async def test_text_to_video_poll_async(client):
701
- operation = await client.aio.models.generate_videos(
702
- model=VEO_MODEL_LATEST,
703
- prompt="A neon hologram of a cat driving at top speed",
704
- config=types.GenerateVideosConfig(
705
- output_gcs_uri=OUTPUT_GCS_URI if client.vertexai else None,
706
- ),
707
- )
708
- while not operation.done:
709
- # Skip the sleep when in replay mode.
710
- if client._api_client._mode not in ("replay", "auto"):
711
- time.sleep(20)
712
- operation = await client.aio.operations.get(operation=operation)
713
-
714
- assert operation.result.generated_videos[0].video.uri
715
-
716
-
717
- @pytest.mark.asyncio
718
- async def test_generated_video_extension_from_source_poll_async(client):
719
- # Gemini API only supports video extension on generated videos.
720
- if client.vertexai:
721
- return
722
-
723
- operation1 = await client.aio.models.generate_videos(
724
- model=VEO_MODEL_LATEST,
725
- prompt="Rain",
726
- config=types.GenerateVideosConfig(
727
- number_of_videos=1,
728
- ),
729
- )
730
- while not operation1.done:
731
- # Skip the sleep when in replay mode.
732
- if client._api_client._mode not in ("replay", "auto"):
733
- time.sleep(20)
734
- operation1 = await client.aio.operations.get(operation=operation1)
735
-
736
- video1 = operation1.result.generated_videos[0].video
737
- assert video1.uri
738
- assert await client.aio.files.download(file=video1)
739
-
740
- operation2 = await client.aio.models.generate_videos(
741
- model=VEO_MODEL_LATEST,
742
- source=types.GenerateVideosSource(
743
- prompt="Sun",
744
- video=video1
745
- ),
746
- config=types.GenerateVideosConfig(
747
- number_of_videos=1,
748
- ),
749
- )
750
- while not operation2.done:
751
- # Skip the sleep when in replay mode.
752
- if client._api_client._mode not in ("replay", "auto"):
753
- time.sleep(20)
754
- operation2 = await client.aio.operations.get(operation=operation2)
755
-
756
- video2 = operation2.result.generated_videos[0].video
757
- assert video2.uri
758
- assert await client.aio.files.download(file=video2)
759
-