google-genai 1.48.0__py3-none-any.whl → 1.50.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.
google/genai/models.py CHANGED
@@ -2299,6 +2299,13 @@ def _GenerationConfig_to_vertex(
2299
2299
  getv(from_object, ['model_selection_config']),
2300
2300
  )
2301
2301
 
2302
+ if getv(from_object, ['response_json_schema']) is not None:
2303
+ setv(
2304
+ to_object,
2305
+ ['responseJsonSchema'],
2306
+ getv(from_object, ['response_json_schema']),
2307
+ )
2308
+
2302
2309
  if getv(from_object, ['audio_timestamp']) is not None:
2303
2310
  setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))
2304
2311
 
@@ -2337,13 +2344,6 @@ def _GenerationConfig_to_vertex(
2337
2344
  to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
2338
2345
  )
2339
2346
 
2340
- if getv(from_object, ['response_json_schema']) is not None:
2341
- setv(
2342
- to_object,
2343
- ['responseJsonSchema'],
2344
- getv(from_object, ['response_json_schema']),
2345
- )
2346
-
2347
2347
  if getv(from_object, ['response_logprobs']) is not None:
2348
2348
  setv(
2349
2349
  to_object,
@@ -2759,6 +2759,21 @@ def _Model_from_mldev(
2759
2759
  getv(from_object, ['supportedGenerationMethods']),
2760
2760
  )
2761
2761
 
2762
+ if getv(from_object, ['temperature']) is not None:
2763
+ setv(to_object, ['temperature'], getv(from_object, ['temperature']))
2764
+
2765
+ if getv(from_object, ['maxTemperature']) is not None:
2766
+ setv(to_object, ['max_temperature'], getv(from_object, ['maxTemperature']))
2767
+
2768
+ if getv(from_object, ['topP']) is not None:
2769
+ setv(to_object, ['top_p'], getv(from_object, ['topP']))
2770
+
2771
+ if getv(from_object, ['topK']) is not None:
2772
+ setv(to_object, ['top_k'], getv(from_object, ['topK']))
2773
+
2774
+ if getv(from_object, ['thinking']) is not None:
2775
+ setv(to_object, ['thinking'], getv(from_object, ['thinking']))
2776
+
2762
2777
  return to_object
2763
2778
 
2764
2779
 
@@ -2905,7 +2920,7 @@ def _RecontextImageConfig_to_vertex(
2905
2920
  if getv(from_object, ['base_steps']) is not None:
2906
2921
  setv(
2907
2922
  parent_object,
2908
- ['parameters', 'editConfig', 'baseSteps'],
2923
+ ['parameters', 'baseSteps'],
2909
2924
  getv(from_object, ['base_steps']),
2910
2925
  )
2911
2926
 
@@ -3321,16 +3336,12 @@ def _Tool_to_mldev(
3321
3336
  getv(from_object, ['google_search_retrieval']),
3322
3337
  )
3323
3338
 
3324
- if getv(from_object, ['google_maps']) is not None:
3325
- setv(
3326
- to_object,
3327
- ['googleMaps'],
3328
- _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
3329
- )
3330
-
3331
3339
  if getv(from_object, ['computer_use']) is not None:
3332
3340
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
3333
3341
 
3342
+ if getv(from_object, ['file_search']) is not None:
3343
+ setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
3344
+
3334
3345
  if getv(from_object, ['code_execution']) is not None:
3335
3346
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
3336
3347
 
@@ -3339,6 +3350,13 @@ def _Tool_to_mldev(
3339
3350
  'enterprise_web_search parameter is not supported in Gemini API.'
3340
3351
  )
3341
3352
 
3353
+ if getv(from_object, ['google_maps']) is not None:
3354
+ setv(
3355
+ to_object,
3356
+ ['googleMaps'],
3357
+ _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
3358
+ )
3359
+
3342
3360
  if getv(from_object, ['google_search']) is not None:
3343
3361
  setv(
3344
3362
  to_object,
@@ -3377,12 +3395,12 @@ def _Tool_to_vertex(
3377
3395
  getv(from_object, ['google_search_retrieval']),
3378
3396
  )
3379
3397
 
3380
- if getv(from_object, ['google_maps']) is not None:
3381
- setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
3382
-
3383
3398
  if getv(from_object, ['computer_use']) is not None:
3384
3399
  setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
3385
3400
 
3401
+ if getv(from_object, ['file_search']) is not None:
3402
+ raise ValueError('file_search parameter is not supported in Vertex AI.')
3403
+
3386
3404
  if getv(from_object, ['code_execution']) is not None:
3387
3405
  setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
3388
3406
 
@@ -3393,6 +3411,9 @@ def _Tool_to_vertex(
3393
3411
  getv(from_object, ['enterprise_web_search']),
3394
3412
  )
3395
3413
 
3414
+ if getv(from_object, ['google_maps']) is not None:
3415
+ setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
3416
+
3396
3417
  if getv(from_object, ['google_search']) is not None:
3397
3418
  setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
3398
3419
 
@@ -4515,7 +4536,12 @@ class Models(_api_module.BaseModule):
4515
4536
  else:
4516
4537
  path = '{models_url}'
4517
4538
  query_params = request_dict.get('_query')
4518
- if query_params:
4539
+ if query_params and query_params.get('filter'):
4540
+ query_param_filter = query_params.pop('filter')
4541
+ path = f'{path}?filter={query_param_filter}'
4542
+ if query_params:
4543
+ path += f'&{urlencode(query_params)}'
4544
+ elif query_params:
4519
4545
  path = f'{path}?{urlencode(query_params)}'
4520
4546
  # TODO: remove the hack that pops config.
4521
4547
  request_dict.pop('config', None)
@@ -6355,7 +6381,12 @@ class AsyncModels(_api_module.BaseModule):
6355
6381
  else:
6356
6382
  path = '{models_url}'
6357
6383
  query_params = request_dict.get('_query')
6358
- if query_params:
6384
+ if query_params and query_params.get('filter'):
6385
+ query_param_filter = query_params.pop('filter')
6386
+ path = f'{path}?filter={query_param_filter}'
6387
+ if query_params:
6388
+ path += f'&{urlencode(query_params)}'
6389
+ elif query_params:
6359
6390
  path = f'{path}?{urlencode(query_params)}'
6360
6391
  # TODO: remove the hack that pops config.
6361
6392
  request_dict.pop('config', None)
@@ -282,6 +282,8 @@ class Operations(_api_module.BaseModule):
282
282
  response_operation = operation.from_api_response(
283
283
  response_dict, is_vertex_ai=True
284
284
  )
285
+
286
+ self._api_client._verify_response(response_operation) # type: ignore [arg-type]
285
287
  return response_operation # type: ignore[no-any-return]
286
288
  else:
287
289
  response_dict = self._get_videos_operation(
@@ -291,6 +293,8 @@ class Operations(_api_module.BaseModule):
291
293
  response_operation = operation.from_api_response(
292
294
  response_dict, is_vertex_ai=False
293
295
  )
296
+
297
+ self._api_client._verify_response(response_operation) # type: ignore [arg-type]
294
298
  return response_operation # type: ignore[no-any-return]
295
299
 
296
300
 
google/genai/pagers.py CHANGED
@@ -25,7 +25,13 @@ from . import types
25
25
  T = TypeVar('T')
26
26
 
27
27
  PagedItem = Literal[
28
- 'batch_jobs', 'models', 'tuning_jobs', 'files', 'cached_contents'
28
+ 'batch_jobs',
29
+ 'models',
30
+ 'tuning_jobs',
31
+ 'files',
32
+ 'cached_contents',
33
+ 'file_search_stores',
34
+ 'documents',
29
35
  ]
30
36
 
31
37
 
google/genai/tunings.py CHANGED
@@ -32,6 +32,60 @@ from .pagers import AsyncPager, Pager
32
32
  logger = logging.getLogger('google_genai.tunings')
33
33
 
34
34
 
35
+ def _AutoraterConfig_from_vertex(
36
+ from_object: Union[dict[str, Any], object],
37
+ parent_object: Optional[dict[str, Any]] = None,
38
+ root_object: Optional[Union[dict[str, Any], object]] = None,
39
+ ) -> dict[str, Any]:
40
+ to_object: dict[str, Any] = {}
41
+ if getv(from_object, ['samplingCount']) is not None:
42
+ setv(to_object, ['sampling_count'], getv(from_object, ['samplingCount']))
43
+
44
+ if getv(from_object, ['flipEnabled']) is not None:
45
+ setv(to_object, ['flip_enabled'], getv(from_object, ['flipEnabled']))
46
+
47
+ if getv(from_object, ['autoraterModel']) is not None:
48
+ setv(to_object, ['autorater_model'], getv(from_object, ['autoraterModel']))
49
+
50
+ if getv(from_object, ['generationConfig']) is not None:
51
+ setv(
52
+ to_object,
53
+ ['generation_config'],
54
+ _GenerationConfig_from_vertex(
55
+ getv(from_object, ['generationConfig']), to_object, root_object
56
+ ),
57
+ )
58
+
59
+ return to_object
60
+
61
+
62
+ def _AutoraterConfig_to_vertex(
63
+ from_object: Union[dict[str, Any], object],
64
+ parent_object: Optional[dict[str, Any]] = None,
65
+ root_object: Optional[Union[dict[str, Any], object]] = None,
66
+ ) -> dict[str, Any]:
67
+ to_object: dict[str, Any] = {}
68
+ if getv(from_object, ['sampling_count']) is not None:
69
+ setv(to_object, ['samplingCount'], getv(from_object, ['sampling_count']))
70
+
71
+ if getv(from_object, ['flip_enabled']) is not None:
72
+ setv(to_object, ['flipEnabled'], getv(from_object, ['flip_enabled']))
73
+
74
+ if getv(from_object, ['autorater_model']) is not None:
75
+ setv(to_object, ['autoraterModel'], getv(from_object, ['autorater_model']))
76
+
77
+ if getv(from_object, ['generation_config']) is not None:
78
+ setv(
79
+ to_object,
80
+ ['generationConfig'],
81
+ _GenerationConfig_to_vertex(
82
+ getv(from_object, ['generation_config']), to_object, root_object
83
+ ),
84
+ )
85
+
86
+ return to_object
87
+
88
+
35
89
  def _CancelTuningJobParameters_to_mldev(
36
90
  from_object: Union[dict[str, Any], object],
37
91
  parent_object: Optional[dict[str, Any]] = None,
@@ -360,7 +414,11 @@ def _EvaluationConfig_from_vertex(
360
414
 
361
415
  if getv(from_object, ['autoraterConfig']) is not None:
362
416
  setv(
363
- to_object, ['autorater_config'], getv(from_object, ['autoraterConfig'])
417
+ to_object,
418
+ ['autorater_config'],
419
+ _AutoraterConfig_from_vertex(
420
+ getv(from_object, ['autoraterConfig']), to_object, root_object
421
+ ),
364
422
  )
365
423
 
366
424
  return to_object
@@ -380,7 +438,240 @@ def _EvaluationConfig_to_vertex(
380
438
 
381
439
  if getv(from_object, ['autorater_config']) is not None:
382
440
  setv(
383
- to_object, ['autoraterConfig'], getv(from_object, ['autorater_config'])
441
+ to_object,
442
+ ['autoraterConfig'],
443
+ _AutoraterConfig_to_vertex(
444
+ getv(from_object, ['autorater_config']), to_object, root_object
445
+ ),
446
+ )
447
+
448
+ return to_object
449
+
450
+
451
+ def _GenerationConfig_from_vertex(
452
+ from_object: Union[dict[str, Any], object],
453
+ parent_object: Optional[dict[str, Any]] = None,
454
+ root_object: Optional[Union[dict[str, Any], object]] = None,
455
+ ) -> dict[str, Any]:
456
+ to_object: dict[str, Any] = {}
457
+ if getv(from_object, ['modelConfig']) is not None:
458
+ setv(
459
+ to_object,
460
+ ['model_selection_config'],
461
+ getv(from_object, ['modelConfig']),
462
+ )
463
+
464
+ if getv(from_object, ['responseJsonSchema']) is not None:
465
+ setv(
466
+ to_object,
467
+ ['response_json_schema'],
468
+ getv(from_object, ['responseJsonSchema']),
469
+ )
470
+
471
+ if getv(from_object, ['audioTimestamp']) is not None:
472
+ setv(to_object, ['audio_timestamp'], getv(from_object, ['audioTimestamp']))
473
+
474
+ if getv(from_object, ['candidateCount']) is not None:
475
+ setv(to_object, ['candidate_count'], getv(from_object, ['candidateCount']))
476
+
477
+ if getv(from_object, ['enableAffectiveDialog']) is not None:
478
+ setv(
479
+ to_object,
480
+ ['enable_affective_dialog'],
481
+ getv(from_object, ['enableAffectiveDialog']),
482
+ )
483
+
484
+ if getv(from_object, ['frequencyPenalty']) is not None:
485
+ setv(
486
+ to_object,
487
+ ['frequency_penalty'],
488
+ getv(from_object, ['frequencyPenalty']),
489
+ )
490
+
491
+ if getv(from_object, ['logprobs']) is not None:
492
+ setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
493
+
494
+ if getv(from_object, ['maxOutputTokens']) is not None:
495
+ setv(
496
+ to_object, ['max_output_tokens'], getv(from_object, ['maxOutputTokens'])
497
+ )
498
+
499
+ if getv(from_object, ['mediaResolution']) is not None:
500
+ setv(
501
+ to_object, ['media_resolution'], getv(from_object, ['mediaResolution'])
502
+ )
503
+
504
+ if getv(from_object, ['presencePenalty']) is not None:
505
+ setv(
506
+ to_object, ['presence_penalty'], getv(from_object, ['presencePenalty'])
507
+ )
508
+
509
+ if getv(from_object, ['responseLogprobs']) is not None:
510
+ setv(
511
+ to_object,
512
+ ['response_logprobs'],
513
+ getv(from_object, ['responseLogprobs']),
514
+ )
515
+
516
+ if getv(from_object, ['responseMimeType']) is not None:
517
+ setv(
518
+ to_object,
519
+ ['response_mime_type'],
520
+ getv(from_object, ['responseMimeType']),
521
+ )
522
+
523
+ if getv(from_object, ['responseModalities']) is not None:
524
+ setv(
525
+ to_object,
526
+ ['response_modalities'],
527
+ getv(from_object, ['responseModalities']),
528
+ )
529
+
530
+ if getv(from_object, ['responseSchema']) is not None:
531
+ setv(to_object, ['response_schema'], getv(from_object, ['responseSchema']))
532
+
533
+ if getv(from_object, ['routingConfig']) is not None:
534
+ setv(to_object, ['routing_config'], getv(from_object, ['routingConfig']))
535
+
536
+ if getv(from_object, ['seed']) is not None:
537
+ setv(to_object, ['seed'], getv(from_object, ['seed']))
538
+
539
+ if getv(from_object, ['speechConfig']) is not None:
540
+ setv(to_object, ['speech_config'], getv(from_object, ['speechConfig']))
541
+
542
+ if getv(from_object, ['stopSequences']) is not None:
543
+ setv(to_object, ['stop_sequences'], getv(from_object, ['stopSequences']))
544
+
545
+ if getv(from_object, ['temperature']) is not None:
546
+ setv(to_object, ['temperature'], getv(from_object, ['temperature']))
547
+
548
+ if getv(from_object, ['thinkingConfig']) is not None:
549
+ setv(to_object, ['thinking_config'], getv(from_object, ['thinkingConfig']))
550
+
551
+ if getv(from_object, ['topK']) is not None:
552
+ setv(to_object, ['top_k'], getv(from_object, ['topK']))
553
+
554
+ if getv(from_object, ['topP']) is not None:
555
+ setv(to_object, ['top_p'], getv(from_object, ['topP']))
556
+
557
+ return to_object
558
+
559
+
560
+ def _GenerationConfig_to_vertex(
561
+ from_object: Union[dict[str, Any], object],
562
+ parent_object: Optional[dict[str, Any]] = None,
563
+ root_object: Optional[Union[dict[str, Any], object]] = None,
564
+ ) -> dict[str, Any]:
565
+ to_object: dict[str, Any] = {}
566
+ if getv(from_object, ['model_selection_config']) is not None:
567
+ setv(
568
+ to_object,
569
+ ['modelConfig'],
570
+ getv(from_object, ['model_selection_config']),
571
+ )
572
+
573
+ if getv(from_object, ['response_json_schema']) is not None:
574
+ setv(
575
+ to_object,
576
+ ['responseJsonSchema'],
577
+ getv(from_object, ['response_json_schema']),
578
+ )
579
+
580
+ if getv(from_object, ['audio_timestamp']) is not None:
581
+ setv(to_object, ['audioTimestamp'], getv(from_object, ['audio_timestamp']))
582
+
583
+ if getv(from_object, ['candidate_count']) is not None:
584
+ setv(to_object, ['candidateCount'], getv(from_object, ['candidate_count']))
585
+
586
+ if getv(from_object, ['enable_affective_dialog']) is not None:
587
+ setv(
588
+ to_object,
589
+ ['enableAffectiveDialog'],
590
+ getv(from_object, ['enable_affective_dialog']),
591
+ )
592
+
593
+ if getv(from_object, ['frequency_penalty']) is not None:
594
+ setv(
595
+ to_object,
596
+ ['frequencyPenalty'],
597
+ getv(from_object, ['frequency_penalty']),
598
+ )
599
+
600
+ if getv(from_object, ['logprobs']) is not None:
601
+ setv(to_object, ['logprobs'], getv(from_object, ['logprobs']))
602
+
603
+ if getv(from_object, ['max_output_tokens']) is not None:
604
+ setv(
605
+ to_object, ['maxOutputTokens'], getv(from_object, ['max_output_tokens'])
606
+ )
607
+
608
+ if getv(from_object, ['media_resolution']) is not None:
609
+ setv(
610
+ to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
611
+ )
612
+
613
+ if getv(from_object, ['presence_penalty']) is not None:
614
+ setv(
615
+ to_object, ['presencePenalty'], getv(from_object, ['presence_penalty'])
616
+ )
617
+
618
+ if getv(from_object, ['response_logprobs']) is not None:
619
+ setv(
620
+ to_object,
621
+ ['responseLogprobs'],
622
+ getv(from_object, ['response_logprobs']),
623
+ )
624
+
625
+ if getv(from_object, ['response_mime_type']) is not None:
626
+ setv(
627
+ to_object,
628
+ ['responseMimeType'],
629
+ getv(from_object, ['response_mime_type']),
630
+ )
631
+
632
+ if getv(from_object, ['response_modalities']) is not None:
633
+ setv(
634
+ to_object,
635
+ ['responseModalities'],
636
+ getv(from_object, ['response_modalities']),
637
+ )
638
+
639
+ if getv(from_object, ['response_schema']) is not None:
640
+ setv(to_object, ['responseSchema'], getv(from_object, ['response_schema']))
641
+
642
+ if getv(from_object, ['routing_config']) is not None:
643
+ setv(to_object, ['routingConfig'], getv(from_object, ['routing_config']))
644
+
645
+ if getv(from_object, ['seed']) is not None:
646
+ setv(to_object, ['seed'], getv(from_object, ['seed']))
647
+
648
+ if getv(from_object, ['speech_config']) is not None:
649
+ setv(
650
+ to_object,
651
+ ['speechConfig'],
652
+ _SpeechConfig_to_vertex(
653
+ getv(from_object, ['speech_config']), to_object, root_object
654
+ ),
655
+ )
656
+
657
+ if getv(from_object, ['stop_sequences']) is not None:
658
+ setv(to_object, ['stopSequences'], getv(from_object, ['stop_sequences']))
659
+
660
+ if getv(from_object, ['temperature']) is not None:
661
+ setv(to_object, ['temperature'], getv(from_object, ['temperature']))
662
+
663
+ if getv(from_object, ['thinking_config']) is not None:
664
+ setv(to_object, ['thinkingConfig'], getv(from_object, ['thinking_config']))
665
+
666
+ if getv(from_object, ['top_k']) is not None:
667
+ setv(to_object, ['topK'], getv(from_object, ['top_k']))
668
+
669
+ if getv(from_object, ['top_p']) is not None:
670
+ setv(to_object, ['topP'], getv(from_object, ['top_p']))
671
+
672
+ if getv(from_object, ['enable_enhanced_civic_answers']) is not None:
673
+ raise ValueError(
674
+ 'enable_enhanced_civic_answers parameter is not supported in Vertex AI.'
384
675
  )
385
676
 
386
677
  return to_object
@@ -542,6 +833,26 @@ def _ListTuningJobsResponse_from_vertex(
542
833
  return to_object
543
834
 
544
835
 
836
+ def _SpeechConfig_to_vertex(
837
+ from_object: Union[dict[str, Any], object],
838
+ parent_object: Optional[dict[str, Any]] = None,
839
+ root_object: Optional[Union[dict[str, Any], object]] = None,
840
+ ) -> dict[str, Any]:
841
+ to_object: dict[str, Any] = {}
842
+ if getv(from_object, ['language_code']) is not None:
843
+ setv(to_object, ['languageCode'], getv(from_object, ['language_code']))
844
+
845
+ if getv(from_object, ['voice_config']) is not None:
846
+ setv(to_object, ['voiceConfig'], getv(from_object, ['voice_config']))
847
+
848
+ if getv(from_object, ['multi_speaker_voice_config']) is not None:
849
+ raise ValueError(
850
+ 'multi_speaker_voice_config parameter is not supported in Vertex AI.'
851
+ )
852
+
853
+ return to_object
854
+
855
+
545
856
  def _TunedModel_from_mldev(
546
857
  from_object: Union[dict[str, Any], object],
547
858
  parent_object: Optional[dict[str, Any]] = None,