google-genai 1.55.0__py3-none-any.whl → 1.57.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 (88) hide show
  1. google/genai/_api_client.py +37 -18
  2. google/genai/_interactions/_base_client.py +8 -2
  3. google/genai/_interactions/resources/interactions.py +6 -6
  4. google/genai/_interactions/types/__init__.py +4 -0
  5. google/genai/_interactions/types/audio_content.py +0 -1
  6. google/genai/_interactions/types/audio_content_param.py +0 -1
  7. google/genai/_interactions/types/code_execution_call_content.py +0 -1
  8. google/genai/_interactions/types/code_execution_call_content_param.py +0 -1
  9. google/genai/_interactions/types/code_execution_result_content.py +0 -1
  10. google/genai/_interactions/types/code_execution_result_content_param.py +0 -1
  11. google/genai/_interactions/types/content.py +63 -0
  12. google/genai/_interactions/types/content_delta.py +7 -23
  13. google/genai/_interactions/types/content_param.py +61 -0
  14. google/genai/_interactions/types/content_start.py +4 -44
  15. google/genai/_interactions/types/deep_research_agent_config.py +0 -1
  16. google/genai/_interactions/types/deep_research_agent_config_param.py +0 -1
  17. google/genai/_interactions/types/document_content.py +3 -2
  18. google/genai/_interactions/types/document_content_param.py +3 -2
  19. google/genai/_interactions/types/document_mime_type.py +23 -0
  20. google/genai/_interactions/types/document_mime_type_param.py +25 -0
  21. google/genai/_interactions/types/dynamic_agent_config.py +0 -1
  22. google/genai/_interactions/types/dynamic_agent_config_param.py +0 -1
  23. google/genai/_interactions/types/file_search_result_content.py +0 -1
  24. google/genai/_interactions/types/file_search_result_content_param.py +0 -1
  25. google/genai/_interactions/types/function_call_content.py +0 -1
  26. google/genai/_interactions/types/function_call_content_param.py +0 -1
  27. google/genai/_interactions/types/function_result_content.py +1 -2
  28. google/genai/_interactions/types/function_result_content_param.py +1 -2
  29. google/genai/_interactions/types/google_search_call_content.py +0 -1
  30. google/genai/_interactions/types/google_search_call_content_param.py +0 -1
  31. google/genai/_interactions/types/google_search_result_content.py +0 -1
  32. google/genai/_interactions/types/google_search_result_content_param.py +0 -1
  33. google/genai/_interactions/types/image_content.py +1 -2
  34. google/genai/_interactions/types/image_content_param.py +1 -2
  35. google/genai/_interactions/types/interaction.py +4 -52
  36. google/genai/_interactions/types/interaction_create_params.py +2 -22
  37. google/genai/_interactions/types/mcp_server_tool_call_content.py +0 -1
  38. google/genai/_interactions/types/mcp_server_tool_call_content_param.py +0 -1
  39. google/genai/_interactions/types/mcp_server_tool_result_content.py +1 -2
  40. google/genai/_interactions/types/mcp_server_tool_result_content_param.py +1 -2
  41. google/genai/_interactions/types/model.py +1 -0
  42. google/genai/_interactions/types/model_param.py +1 -0
  43. google/genai/_interactions/types/text_content.py +0 -1
  44. google/genai/_interactions/types/text_content_param.py +0 -1
  45. google/genai/_interactions/types/thinking_level.py +1 -1
  46. google/genai/_interactions/types/thought_content.py +0 -1
  47. google/genai/_interactions/types/thought_content_param.py +0 -1
  48. google/genai/_interactions/types/turn.py +3 -44
  49. google/genai/_interactions/types/turn_param.py +4 -40
  50. google/genai/_interactions/types/url_context_call_content.py +0 -1
  51. google/genai/_interactions/types/url_context_call_content_param.py +0 -1
  52. google/genai/_interactions/types/url_context_result_content.py +0 -1
  53. google/genai/_interactions/types/url_context_result_content_param.py +0 -1
  54. google/genai/_interactions/types/usage.py +1 -1
  55. google/genai/_interactions/types/usage_param.py +1 -1
  56. google/genai/_interactions/types/video_content.py +1 -2
  57. google/genai/_interactions/types/video_content_param.py +1 -2
  58. google/genai/_live_converters.py +36 -64
  59. google/genai/_local_tokenizer_loader.py +1 -0
  60. google/genai/_tokens_converters.py +14 -14
  61. google/genai/batches.py +27 -22
  62. google/genai/caches.py +42 -42
  63. google/genai/chats.py +0 -2
  64. google/genai/client.py +3 -1
  65. google/genai/files.py +224 -0
  66. google/genai/models.py +57 -72
  67. google/genai/tests/chats/test_get_history.py +9 -8
  68. google/genai/tests/chats/test_validate_response.py +1 -1
  69. google/genai/tests/client/test_client_requests.py +1 -135
  70. google/genai/tests/files/test_register.py +272 -0
  71. google/genai/tests/files/test_register_table.py +70 -0
  72. google/genai/tests/interactions/test_auth.py +479 -0
  73. google/genai/tests/interactions/test_integration.py +2 -0
  74. google/genai/tests/interactions/test_paths.py +105 -0
  75. google/genai/tests/live/test_live.py +2 -36
  76. google/genai/tests/local_tokenizer/test_local_tokenizer.py +1 -1
  77. google/genai/tests/models/test_function_call_streaming.py +90 -90
  78. google/genai/tests/models/test_generate_content.py +1 -2
  79. google/genai/tests/models/test_recontext_image.py +1 -1
  80. google/genai/tests/pytest_helper.py +17 -0
  81. google/genai/tunings.py +1 -27
  82. google/genai/types.py +603 -518
  83. google/genai/version.py +1 -1
  84. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/METADATA +224 -22
  85. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/RECORD +88 -80
  86. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/WHEEL +0 -0
  87. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/licenses/LICENSE +0 -0
  88. {google_genai-1.55.0.dist-info → google_genai-1.57.0.dist-info}/top_level.txt +0 -0
@@ -154,7 +154,7 @@ def test_streaming_with_python_native_no_afc_config(client):
154
154
  return
155
155
  with pytest.raises(ValueError) as e:
156
156
  for chunk in client.models.generate_content_stream(
157
- model='gemini-2.5-pro',
157
+ model='gemini-3-pro-preview',
158
158
  contents=generate_content_prompt,
159
159
  config=types.GenerateContentConfig(
160
160
  tools=[
@@ -179,36 +179,18 @@ def test_streaming_with_python_afc_disabled_false(client):
179
179
  return
180
180
  with pytest.raises(ValueError) as e:
181
181
  for chunk in client.models.generate_content_stream(
182
- model='gemini-2.5-pro',
183
- contents='What is the price of GOOG? And what is the weather in Boston?',
184
- config=types.GenerateContentConfig(
185
- tools=[
186
- test_generate_content_tools.get_weather,
187
- test_generate_content_tools.get_stock_price,
188
- ],
189
- automatic_function_calling=types.AutomaticFunctionCallingConfig(
190
- disable=False,
191
- ),
192
- tool_config=types.ToolConfig(
193
- function_calling_config={
194
- 'stream_function_call_arguments': True,
195
- }
196
- ),
197
- ),
198
- ):
199
- pass
200
- assert 'not compatible with automatic function calling (AFC)' in str(e.value)
201
-
202
-
203
- def test_streaming_with_json_parameters_without_history(client):
204
- """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
205
-
206
- with pytest_helper.exception_if_mldev(client, ValueError):
207
- for chunk in client.models.generate_content_stream(
208
- model='gemini-2.5-pro',
209
- contents=generate_content_prompt,
182
+ model='gemini-3-pro-preview',
183
+ contents=(
184
+ 'What is the price of GOOG? And what is the weather in Boston?'
185
+ ),
210
186
  config=types.GenerateContentConfig(
211
- tools=[{'function_declarations': json_function_declarations}],
187
+ tools=[
188
+ test_generate_content_tools.get_weather,
189
+ test_generate_content_tools.get_stock_price,
190
+ ],
191
+ automatic_function_calling=types.AutomaticFunctionCallingConfig(
192
+ disable=False,
193
+ ),
212
194
  tool_config=types.ToolConfig(
213
195
  function_calling_config={
214
196
  'stream_function_call_arguments': True,
@@ -216,18 +198,17 @@ def test_streaming_with_json_parameters_without_history(client):
216
198
  ),
217
199
  ),
218
200
  ):
219
- assert chunk is not None
220
- assert chunk.candidates is not None
221
- assert chunk.candidates[0].content is not None
222
- assert chunk.candidates[0].content.parts is not None
201
+ pass
202
+ assert 'not compatible with automatic function calling (AFC)' in str(e.value)
223
203
 
224
204
 
225
- def test_streaming_with_json_parameters_with_history(client):
205
+ def test_streaming_with_json_parameters_without_history(client):
226
206
  """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
207
+
227
208
  with pytest_helper.exception_if_mldev(client, ValueError):
228
209
  for chunk in client.models.generate_content_stream(
229
- model='gemini-2.5-pro',
230
- contents=previous_generate_content_history,
210
+ model='gemini-3-pro-preview',
211
+ contents=generate_content_prompt,
231
212
  config=types.GenerateContentConfig(
232
213
  tools=[{'function_declarations': json_function_declarations}],
233
214
  tool_config=types.ToolConfig(
@@ -242,12 +223,13 @@ def test_streaming_with_json_parameters_with_history(client):
242
223
  assert chunk.candidates[0].content is not None
243
224
  assert chunk.candidates[0].content.parts is not None
244
225
 
226
+
245
227
  @pytest.mark.asyncio
246
228
  async def test_streaming_with_json_parameters_async(client):
247
229
  """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
248
230
  with pytest_helper.exception_if_mldev(client, ValueError):
249
231
  async for chunk in await client.aio.models.generate_content_stream(
250
- model='gemini-2.5-pro',
232
+ model='gemini-3-pro-preview',
251
233
  contents=generate_content_prompt,
252
234
  config=types.GenerateContentConfig(
253
235
  tools=[{'function_declarations': json_function_declarations}],
@@ -268,7 +250,7 @@ def test_streaming_with_gemini_parameters_without_history(client):
268
250
  """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
269
251
  with pytest_helper.exception_if_mldev(client, ValueError):
270
252
  for chunk in client.models.generate_content_stream(
271
- model='gemini-2.5-pro',
253
+ model='gemini-3-pro-preview',
272
254
  contents=generate_content_prompt,
273
255
  config=types.GenerateContentConfig(
274
256
  tools=[{
@@ -291,7 +273,7 @@ def test_streaming_with_gemini_parameters_with_response(client):
291
273
  with pytest_helper.exception_if_mldev(client, ValueError):
292
274
  streaming_function_call_content = []
293
275
  for chunk in client.models.generate_content_stream(
294
- model='gemini-2.5-pro',
276
+ model='gemini-3-pro-preview',
295
277
  contents=[
296
278
  types.Content(
297
279
  role='user',
@@ -335,7 +317,7 @@ def test_streaming_with_gemini_parameters_with_response(client):
335
317
  )
336
318
 
337
319
  for chunk in client.models.generate_content_stream(
338
- model='gemini-2.5-pro',
320
+ model='gemini-3-pro-preview',
339
321
  contents=streaming_function_call_content,
340
322
  config=types.GenerateContentConfig(
341
323
  tools=[{'function_declarations': json_function_declarations}],
@@ -348,41 +330,41 @@ def test_streaming_with_gemini_parameters_with_response(client):
348
330
  ):
349
331
  pass
350
332
 
351
- def test_streaming_with_gemini_parameters_with_history(client):
352
- """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
353
- with pytest_helper.exception_if_mldev(client, ValueError):
354
- for chunk in client.models.generate_content_stream(
355
- model='gemini-2.5-pro',
356
- contents=previous_generate_content_history,
357
- config=types.GenerateContentConfig(
358
- tools=[{
359
- 'function_declarations': gemini_function_declarations
360
- }],
361
- tool_config=types.ToolConfig(
362
- function_calling_config={
363
- 'stream_function_call_arguments': True,
364
- }
365
- ),
366
- ),
367
- ):
368
- assert chunk is not None
369
- assert chunk.candidates is not None
370
- assert chunk.candidates[0].content is not None
371
- assert chunk.candidates[0].content.parts is not None
372
-
373
333
  def test_chat_streaming_with_json_parameters_with_history(client):
374
334
  """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
375
335
  with pytest_helper.exception_if_mldev(client, ValueError):
376
- messages = [
377
- """
378
- get the current weather in boston in celsius, the country is U.S., the purpose is to know what to wear today.
379
- """,
380
- """
381
- get the current weather in new brunswick in celsius, the country is U.S., the purpose is to know what to prepare an event today.
382
- """,
336
+ test_parts = [
337
+ types.Part(
338
+ text=(
339
+ 'get the current weather in boston in celsius, the'
340
+ ' country should be US, the purpose is to know'
341
+ ' what to wear today?'
342
+ )
343
+ ),
344
+ types.Part.from_function_response(
345
+ name='get_current_weather',
346
+ response={
347
+ 'temperature': 21,
348
+ 'unit': 'C',
349
+ },
350
+ ),
351
+ types.Part(
352
+ text=(
353
+ 'get the current weather in new brunswick in celsius, the'
354
+ ' country should be US, the purpose is to know'
355
+ ' what to prepare an event today?'
356
+ )
357
+ ),
358
+ types.Part.from_function_response(
359
+ name='get_current_weather',
360
+ response={
361
+ 'temperature': 21,
362
+ 'unit': 'C',
363
+ },
364
+ ),
383
365
  ]
384
366
  chat = client.chats.create(
385
- model='gemini-2.5-pro',
367
+ model='gemini-3-pro-preview',
386
368
  history=previous_generate_content_history,
387
369
  config=types.GenerateContentConfig(
388
370
  tools=[{
@@ -395,7 +377,7 @@ def test_chat_streaming_with_json_parameters_with_history(client):
395
377
  ),
396
378
  ),
397
379
  )
398
- for message in messages:
380
+ for message in test_parts:
399
381
  result = chat.send_message_stream(message)
400
382
  for chunk in result:
401
383
  assert chunk is not None
@@ -409,17 +391,39 @@ def test_chat_streaming_with_json_parameters_with_history(client):
409
391
  @pytest.mark.asyncio
410
392
  async def test_chat_streaming_with_json_parameters_with_history_async(client):
411
393
  """Tests streaming function calls with FunctionDeclaration withJSON parameters."""
412
- messages = [
413
- """
414
- get the current weather in boston in celsius, the country is U.S., the purpose is to know what to wear today.
415
- """,
416
- """
417
- get the current weather in new brunswick in celsius, the country is U.S., the purpose is to know what to prepare an event today.
418
- """,
394
+ test_parts = [
395
+ types.Part(
396
+ text=(
397
+ 'get the current weather in boston in celsius, the'
398
+ ' country should be US, the purpose is to know'
399
+ ' what to wear today?'
400
+ )
401
+ ),
402
+ types.Part.from_function_response(
403
+ name='get_current_weather',
404
+ response={
405
+ 'temperature': 21,
406
+ 'unit': 'C',
407
+ },
408
+ ),
409
+ types.Part(
410
+ text=(
411
+ 'get the current weather in new brunswick in celsius, the'
412
+ ' country should be US, the purpose is to know'
413
+ ' what to prepare an event today?'
414
+ )
415
+ ),
416
+ types.Part.from_function_response(
417
+ name='get_current_weather',
418
+ response={
419
+ 'temperature': 21,
420
+ 'unit': 'C',
421
+ },
422
+ ),
419
423
  ]
420
424
  with pytest_helper.exception_if_mldev(client, ValueError):
421
425
  chat = client.aio.chats.create(
422
- model='gemini-2.5-pro',
426
+ model='gemini-3-pro-preview',
423
427
  history=previous_generate_content_history,
424
428
  config=types.GenerateContentConfig(
425
429
  tools=[{'function_declarations': gemini_function_declarations}],
@@ -430,13 +434,9 @@ async def test_chat_streaming_with_json_parameters_with_history_async(client):
430
434
  ),
431
435
  ),
432
436
  )
433
- async for chunk in await chat.send_message_stream(messages[0]):
434
- assert chunk is not None
435
- assert chunk.candidates is not None
436
- assert chunk.candidates[0].content is not None
437
- assert chunk.candidates[0].content.parts is not None
438
- async for chunk in await chat.send_message_stream(messages[1]):
439
- assert chunk is not None
440
- assert chunk.candidates is not None
441
- assert chunk.candidates[0].content is not None
442
- assert chunk.candidates[0].content.parts is not None
437
+ for message in test_parts:
438
+ async for chunk in await chat.send_message_stream(message):
439
+ assert chunk is not None
440
+ assert chunk.candidates is not None
441
+ assert chunk.candidates[0].content is not None
442
+ assert chunk.candidates[0].content.parts is not None
@@ -374,7 +374,6 @@ test_table: list[pytest_helper.TestTableItem] = [
374
374
  ),
375
375
  pytest_helper.TestTableItem(
376
376
  name='test_speech_with_multi_speaker_voice_config',
377
- exception_if_vertex='not supported',
378
377
  parameters=types._GenerateContentParameters(
379
378
  model='gemini-2.5-flash-preview-tts',
380
379
  contents=t.t_contents(
@@ -409,7 +408,7 @@ test_table: list[pytest_helper.TestTableItem] = [
409
408
  ),
410
409
  pytest_helper.TestTableItem(
411
410
  name='test_speech_error_with_speech_config_and_multi_speech_config',
412
- exception_if_vertex='not supported',
411
+ exception_if_vertex='mutually exclusive',
413
412
  exception_if_mldev='mutually exclusive',
414
413
  parameters=types._GenerateContentParameters(
415
414
  model='gemini-2.5-flash-preview-tts',
@@ -23,7 +23,7 @@ from .. import pytest_helper
23
23
 
24
24
  PRODUCT_RECONTEXT_MODEL_LATEST = 'imagen-product-recontext-preview-06-30'
25
25
 
26
- VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST = 'virtual-try-on-preview-08-04'
26
+ VIRTUAL_TRY_ON_IMAGE_MODEL_LATEST = 'virtual-try-on-001'
27
27
 
28
28
  BACKPACK1 = types.Image(
29
29
  gcs_uri='gs://genai-sdk-tests/inputs/images/backpack1.png',
@@ -227,3 +227,20 @@ def camel_to_snake(camel_str: str) -> str:
227
227
  def get_value_ignore_key_case(obj, key):
228
228
  """Returns the value of the key in the object, converting to camelCase or snake_case if necessary."""
229
229
  return obj.get(snake_to_camel(key), obj.get(camel_to_snake(key), None))
230
+
231
+
232
+ def camel_to_snake_all_keys(data):
233
+ """Converts all keys in a dictionary or list to snake_case."""
234
+ if isinstance(data, dict):
235
+ new_dict = {}
236
+ for key, value in data.items():
237
+ if isinstance(key, str):
238
+ new_key = camel_to_snake(key)
239
+ else:
240
+ new_key = key
241
+ new_dict[new_key] = camel_to_snake_all_keys(value)
242
+ return new_dict
243
+ elif isinstance(data, list):
244
+ return [camel_to_snake_all_keys(item) for item in data]
245
+ else:
246
+ return data
google/genai/tunings.py CHANGED
@@ -674,13 +674,7 @@ def _GenerationConfig_to_vertex(
674
674
  setv(to_object, ['seed'], getv(from_object, ['seed']))
675
675
 
676
676
  if getv(from_object, ['speech_config']) is not None:
677
- setv(
678
- to_object,
679
- ['speechConfig'],
680
- _SpeechConfig_to_vertex(
681
- getv(from_object, ['speech_config']), to_object, root_object
682
- ),
683
- )
677
+ setv(to_object, ['speechConfig'], getv(from_object, ['speech_config']))
684
678
 
685
679
  if getv(from_object, ['stop_sequences']) is not None:
686
680
  setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
@@ -861,26 +855,6 @@ def _ListTuningJobsResponse_from_vertex(
861
855
  return to_object
862
856
 
863
857
 
864
- def _SpeechConfig_to_vertex(
865
- from_object: Union[dict[str, Any], object],
866
- parent_object: Optional[dict[str, Any]] = None,
867
- root_object: Optional[Union[dict[str, Any], object]] = None,
868
- ) -> dict[str, Any]:
869
- to_object: dict[str, Any] = {}
870
- if getv(from_object, ['voice_config']) is not None:
871
- setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
872
-
873
- if getv(from_object, ['language_code']) is not None:
874
- setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
875
-
876
- if getv(from_object, ['multi_speaker_voice_config']) is not None:
877
- raise ValueError(
878
- 'multi_speaker_voice_config parameter is not supported in Vertex AI.'
879
- )
880
-
881
- return to_object
882
-
883
-
884
858
  def _TunedModel_from_mldev(
885
859
  from_object: Union[dict[str, Any], object],
886
860
  parent_object: Optional[dict[str, Any]] = None,