google-genai 0.2.2__py3-none-any.whl → 0.4.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/__init__.py +2 -1
- google/genai/_api_client.py +91 -38
- google/genai/_automatic_function_calling_util.py +19 -22
- google/genai/_replay_api_client.py +22 -28
- google/genai/_transformers.py +15 -0
- google/genai/batches.py +16 -16
- google/genai/caches.py +48 -46
- google/genai/chats.py +88 -15
- google/genai/client.py +6 -3
- google/genai/files.py +22 -22
- google/genai/live.py +28 -5
- google/genai/models.py +109 -77
- google/genai/tunings.py +17 -17
- google/genai/types.py +173 -90
- google/genai/version.py +16 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/METADATA +66 -18
- google_genai-0.4.0.dist-info/RECORD +25 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/WHEEL +1 -1
- google_genai-0.2.2.dist-info/RECORD +0 -24
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/LICENSE +0 -0
- {google_genai-0.2.2.dist-info → google_genai-0.4.0.dist-info}/top_level.txt +0 -0
google/genai/types.py
CHANGED
@@ -441,6 +441,10 @@ class Part(_common.BaseModel):
|
|
441
441
|
video_metadata: Optional[VideoMetadata] = Field(
|
442
442
|
default=None, description="""Metadata for a given video."""
|
443
443
|
)
|
444
|
+
thought: Optional[bool] = Field(
|
445
|
+
default=None,
|
446
|
+
description="""Indicates if the part is thought from the model.""",
|
447
|
+
)
|
444
448
|
code_execution_result: Optional[CodeExecutionResult] = Field(
|
445
449
|
default=None,
|
446
450
|
description="""Optional. Result of executing the [ExecutableCode].""",
|
@@ -525,6 +529,9 @@ class PartDict(TypedDict, total=False):
|
|
525
529
|
video_metadata: Optional[VideoMetadataDict]
|
526
530
|
"""Metadata for a given video."""
|
527
531
|
|
532
|
+
thought: Optional[bool]
|
533
|
+
"""Indicates if the part is thought from the model."""
|
534
|
+
|
528
535
|
code_execution_result: Optional[CodeExecutionResultDict]
|
529
536
|
"""Optional. Result of executing the [ExecutableCode]."""
|
530
537
|
|
@@ -562,7 +569,9 @@ class Content(_common.BaseModel):
|
|
562
569
|
)
|
563
570
|
role: Optional[str] = Field(
|
564
571
|
default=None,
|
565
|
-
description="""Optional. The producer of the content. Must be either 'user' or
|
572
|
+
description="""Optional. The producer of the content. Must be either 'user' or
|
573
|
+
'model'. Useful to set for multi-turn conversations, otherwise can be
|
574
|
+
left blank or unset. If role is not specified, SDK will determine the role.""",
|
566
575
|
)
|
567
576
|
|
568
577
|
|
@@ -574,7 +583,9 @@ class ContentDict(TypedDict, total=False):
|
|
574
583
|
a different IANA MIME type."""
|
575
584
|
|
576
585
|
role: Optional[str]
|
577
|
-
"""Optional. The producer of the content. Must be either 'user' or
|
586
|
+
"""Optional. The producer of the content. Must be either 'user' or
|
587
|
+
'model'. Useful to set for multi-turn conversations, otherwise can be
|
588
|
+
left blank or unset. If role is not specified, SDK will determine the role."""
|
578
589
|
|
579
590
|
|
580
591
|
ContentOrDict = Union[Content, ContentDict]
|
@@ -591,7 +602,7 @@ class Schema(_common.BaseModel):
|
|
591
602
|
Represents a select subset of an OpenAPI 3.0 schema object.
|
592
603
|
"""
|
593
604
|
|
594
|
-
min_items: Optional[
|
605
|
+
min_items: Optional[int] = Field(
|
595
606
|
default=None,
|
596
607
|
description="""Optional. Minimum number of the elements for Type.ARRAY.""",
|
597
608
|
)
|
@@ -618,22 +629,22 @@ class Schema(_common.BaseModel):
|
|
618
629
|
default=None,
|
619
630
|
description="""Optional. The value should be validated against any (one or more) of the subschemas in the list.""",
|
620
631
|
)
|
621
|
-
max_length: Optional[
|
632
|
+
max_length: Optional[int] = Field(
|
622
633
|
default=None,
|
623
634
|
description="""Optional. Maximum length of the Type.STRING""",
|
624
635
|
)
|
625
636
|
title: Optional[str] = Field(
|
626
637
|
default=None, description="""Optional. The title of the Schema."""
|
627
638
|
)
|
628
|
-
min_length: Optional[
|
639
|
+
min_length: Optional[int] = Field(
|
629
640
|
default=None,
|
630
641
|
description="""Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING""",
|
631
642
|
)
|
632
|
-
min_properties: Optional[
|
643
|
+
min_properties: Optional[int] = Field(
|
633
644
|
default=None,
|
634
645
|
description="""Optional. Minimum number of the properties for Type.OBJECT.""",
|
635
646
|
)
|
636
|
-
max_items: Optional[
|
647
|
+
max_items: Optional[int] = Field(
|
637
648
|
default=None,
|
638
649
|
description="""Optional. Maximum number of the elements for Type.ARRAY.""",
|
639
650
|
)
|
@@ -645,7 +656,7 @@ class Schema(_common.BaseModel):
|
|
645
656
|
default=None,
|
646
657
|
description="""Optional. Indicates if the value may be null.""",
|
647
658
|
)
|
648
|
-
max_properties: Optional[
|
659
|
+
max_properties: Optional[int] = Field(
|
649
660
|
default=None,
|
650
661
|
description="""Optional. Maximum number of the properties for Type.OBJECT.""",
|
651
662
|
)
|
@@ -683,7 +694,7 @@ class SchemaDict(TypedDict, total=False):
|
|
683
694
|
Represents a select subset of an OpenAPI 3.0 schema object.
|
684
695
|
"""
|
685
696
|
|
686
|
-
min_items: Optional[
|
697
|
+
min_items: Optional[int]
|
687
698
|
"""Optional. Minimum number of the elements for Type.ARRAY."""
|
688
699
|
|
689
700
|
example: Optional[Any]
|
@@ -704,19 +715,19 @@ class SchemaDict(TypedDict, total=False):
|
|
704
715
|
any_of: list["SchemaDict"]
|
705
716
|
"""Optional. The value should be validated against any (one or more) of the subschemas in the list."""
|
706
717
|
|
707
|
-
max_length: Optional[
|
718
|
+
max_length: Optional[int]
|
708
719
|
"""Optional. Maximum length of the Type.STRING"""
|
709
720
|
|
710
721
|
title: Optional[str]
|
711
722
|
"""Optional. The title of the Schema."""
|
712
723
|
|
713
|
-
min_length: Optional[
|
724
|
+
min_length: Optional[int]
|
714
725
|
"""Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING"""
|
715
726
|
|
716
|
-
min_properties: Optional[
|
727
|
+
min_properties: Optional[int]
|
717
728
|
"""Optional. Minimum number of the properties for Type.OBJECT."""
|
718
729
|
|
719
|
-
max_items: Optional[
|
730
|
+
max_items: Optional[int]
|
720
731
|
"""Optional. Maximum number of the elements for Type.ARRAY."""
|
721
732
|
|
722
733
|
maximum: Optional[float]
|
@@ -725,7 +736,7 @@ class SchemaDict(TypedDict, total=False):
|
|
725
736
|
nullable: Optional[bool]
|
726
737
|
"""Optional. Indicates if the value may be null."""
|
727
738
|
|
728
|
-
max_properties: Optional[
|
739
|
+
max_properties: Optional[int]
|
729
740
|
"""Optional. Maximum number of the properties for Type.OBJECT."""
|
730
741
|
|
731
742
|
type: Optional[Type]
|
@@ -813,11 +824,35 @@ class FunctionDeclaration(_common.BaseModel):
|
|
813
824
|
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""",
|
814
825
|
)
|
815
826
|
|
816
|
-
@
|
817
|
-
def
|
818
|
-
"""
|
827
|
+
@classmethod
|
828
|
+
def _get_variant(cls, client) -> str:
|
829
|
+
"""Returns the function variant based on the provided client object."""
|
830
|
+
if client.vertexai:
|
831
|
+
return "VERTEX_AI"
|
832
|
+
else:
|
833
|
+
return "GOOGLE_AI"
|
834
|
+
|
835
|
+
@classmethod
|
836
|
+
def from_function_with_options(
|
837
|
+
cls,
|
838
|
+
func: Callable,
|
839
|
+
variant: Literal["GOOGLE_AI", "VERTEX_AI", "DEFAULT"] = "GOOGLE_AI",
|
840
|
+
) -> "FunctionDeclaration":
|
841
|
+
"""Converts a function to a FunctionDeclaration based on an API endpoint.
|
842
|
+
|
843
|
+
Supported endpoints are: 'GOOGLE_AI', 'VERTEX_AI', or 'DEFAULT'.
|
844
|
+
"""
|
819
845
|
from . import _automatic_function_calling_util
|
820
846
|
|
847
|
+
supported_variants = ["GOOGLE_AI", "VERTEX_AI", "DEFAULT"]
|
848
|
+
if variant not in supported_variants:
|
849
|
+
raise ValueError(
|
850
|
+
f"Unsupported variant: {variant}. Supported variants are:"
|
851
|
+
f" {', '.join(supported_variants)}"
|
852
|
+
)
|
853
|
+
|
854
|
+
# TODO: b/382524014 - Add support for DEFAULT API endpoint.
|
855
|
+
|
821
856
|
parameters_properties = {}
|
822
857
|
for name, param in inspect.signature(func).parameters.items():
|
823
858
|
if param.kind in (
|
@@ -826,7 +861,7 @@ class FunctionDeclaration(_common.BaseModel):
|
|
826
861
|
inspect.Parameter.POSITIONAL_ONLY,
|
827
862
|
):
|
828
863
|
schema = _automatic_function_calling_util._parse_schema_from_parameter(
|
829
|
-
|
864
|
+
variant, param, func.__name__
|
830
865
|
)
|
831
866
|
parameters_properties[name] = schema
|
832
867
|
declaration = FunctionDeclaration(
|
@@ -838,13 +873,13 @@ class FunctionDeclaration(_common.BaseModel):
|
|
838
873
|
type="OBJECT",
|
839
874
|
properties=parameters_properties,
|
840
875
|
)
|
841
|
-
if
|
876
|
+
if variant == "VERTEX_AI":
|
842
877
|
declaration.parameters.required = (
|
843
878
|
_automatic_function_calling_util._get_required_fields(
|
844
879
|
declaration.parameters
|
845
880
|
)
|
846
881
|
)
|
847
|
-
if not
|
882
|
+
if not variant == "VERTEX_AI":
|
848
883
|
return declaration
|
849
884
|
|
850
885
|
return_annotation = inspect.signature(func).return_annotation
|
@@ -853,7 +888,7 @@ class FunctionDeclaration(_common.BaseModel):
|
|
853
888
|
|
854
889
|
declaration.response = (
|
855
890
|
_automatic_function_calling_util._parse_schema_from_parameter(
|
856
|
-
|
891
|
+
variant,
|
857
892
|
inspect.Parameter(
|
858
893
|
"return_value",
|
859
894
|
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
@@ -864,6 +899,14 @@ class FunctionDeclaration(_common.BaseModel):
|
|
864
899
|
)
|
865
900
|
return declaration
|
866
901
|
|
902
|
+
@classmethod
|
903
|
+
def from_function(cls, client, func: Callable) -> "FunctionDeclaration":
|
904
|
+
"""Converts a function to a FunctionDeclaration."""
|
905
|
+
return cls.from_function_with_options(
|
906
|
+
variant=cls._get_variant(client),
|
907
|
+
func=func,
|
908
|
+
)
|
909
|
+
|
867
910
|
|
868
911
|
class FunctionDeclarationDict(TypedDict, total=False):
|
869
912
|
"""Defines a function that the model can generate JSON inputs for.
|
@@ -2410,7 +2453,10 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2410
2453
|
default=None, description="""Usage metadata about the response(s)."""
|
2411
2454
|
)
|
2412
2455
|
automatic_function_calling_history: Optional[list[Content]] = None
|
2413
|
-
parsed: Union[pydantic.BaseModel, dict] =
|
2456
|
+
parsed: Union[pydantic.BaseModel, dict] = Field(
|
2457
|
+
default=None,
|
2458
|
+
description="""Parsed response if response_schema is provided. Not available for streaming.""",
|
2459
|
+
)
|
2414
2460
|
|
2415
2461
|
@property
|
2416
2462
|
def text(self) -> Optional[str]:
|
@@ -2430,18 +2476,44 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2430
2476
|
text = ""
|
2431
2477
|
any_text_part_text = False
|
2432
2478
|
for part in self.candidates[0].content.parts:
|
2433
|
-
for field_name, field_value in part.dict(
|
2479
|
+
for field_name, field_value in part.dict(
|
2480
|
+
exclude={"text", "thought"}
|
2481
|
+
).items():
|
2434
2482
|
if field_value is not None:
|
2435
2483
|
raise ValueError(
|
2436
2484
|
"GenerateContentResponse.text only supports text parts, but got"
|
2437
2485
|
f" {field_name} part{part}"
|
2438
2486
|
)
|
2439
2487
|
if isinstance(part.text, str):
|
2488
|
+
if isinstance(part.thought, bool) and part.thought:
|
2489
|
+
continue
|
2440
2490
|
any_text_part_text = True
|
2441
2491
|
text += part.text
|
2442
2492
|
# part.text == '' is different from part.text is None
|
2443
2493
|
return text if any_text_part_text else None
|
2444
2494
|
|
2495
|
+
@property
|
2496
|
+
def function_calls(self) -> Optional[list[FunctionCall]]:
|
2497
|
+
"""Returns the list of function calls in the response."""
|
2498
|
+
if (
|
2499
|
+
not self.candidates
|
2500
|
+
or not self.candidates[0].content
|
2501
|
+
or not self.candidates[0].content.parts
|
2502
|
+
):
|
2503
|
+
return None
|
2504
|
+
if len(self.candidates) > 1:
|
2505
|
+
logging.warning(
|
2506
|
+
"Warning: there are multiple candidates in the response, returning"
|
2507
|
+
" function calls from the first one."
|
2508
|
+
)
|
2509
|
+
function_calls = [
|
2510
|
+
part.function_call
|
2511
|
+
for part in self.candidates[0].content.parts
|
2512
|
+
if part.function_call is not None
|
2513
|
+
]
|
2514
|
+
|
2515
|
+
return function_calls if function_calls else None
|
2516
|
+
|
2445
2517
|
@classmethod
|
2446
2518
|
def _from_response(
|
2447
2519
|
cls, response: dict[str, object], kwargs: dict[str, object]
|
@@ -2456,12 +2528,21 @@ class GenerateContentResponse(_common.BaseModel):
|
|
2456
2528
|
response_schema, pydantic.BaseModel
|
2457
2529
|
):
|
2458
2530
|
# Pydantic schema.
|
2459
|
-
|
2531
|
+
try:
|
2532
|
+
result.parsed = response_schema.model_validate_json(result.text)
|
2533
|
+
# may not be a valid json per stream response
|
2534
|
+
except pydantic.ValidationError:
|
2535
|
+
pass
|
2536
|
+
|
2460
2537
|
elif isinstance(response_schema, dict) or isinstance(
|
2461
2538
|
response_schema, pydantic.BaseModel
|
2462
2539
|
):
|
2463
2540
|
# JSON schema.
|
2464
|
-
|
2541
|
+
try:
|
2542
|
+
result.parsed = json.loads(result.text)
|
2543
|
+
# may not be a valid json per stream response
|
2544
|
+
except json.decoder.JSONDecodeError:
|
2545
|
+
pass
|
2465
2546
|
|
2466
2547
|
return result
|
2467
2548
|
|
@@ -3511,10 +3592,6 @@ class _UpscaleImageAPIConfig(_common.BaseModel):
|
|
3511
3592
|
http_options: Optional[dict[str, Any]] = Field(
|
3512
3593
|
default=None, description="""Used to override HTTP request options."""
|
3513
3594
|
)
|
3514
|
-
upscale_factor: Optional[str] = Field(
|
3515
|
-
default=None,
|
3516
|
-
description="""The factor to which the image will be upscaled.""",
|
3517
|
-
)
|
3518
3595
|
include_rai_reason: Optional[bool] = Field(
|
3519
3596
|
default=None,
|
3520
3597
|
description="""Whether to include a reason for filtered-out images in the
|
@@ -3543,9 +3620,6 @@ class _UpscaleImageAPIConfigDict(TypedDict, total=False):
|
|
3543
3620
|
http_options: Optional[dict[str, Any]]
|
3544
3621
|
"""Used to override HTTP request options."""
|
3545
3622
|
|
3546
|
-
upscale_factor: Optional[str]
|
3547
|
-
"""The factor to which the image will be upscaled."""
|
3548
|
-
|
3549
3623
|
include_rai_reason: Optional[bool]
|
3550
3624
|
"""Whether to include a reason for filtered-out images in the
|
3551
3625
|
response."""
|
@@ -3578,6 +3652,10 @@ class _UpscaleImageAPIParameters(_common.BaseModel):
|
|
3578
3652
|
image: Optional[Image] = Field(
|
3579
3653
|
default=None, description="""The input image to upscale."""
|
3580
3654
|
)
|
3655
|
+
upscale_factor: Optional[str] = Field(
|
3656
|
+
default=None,
|
3657
|
+
description="""The factor to upscale the image (x2 or x4).""",
|
3658
|
+
)
|
3581
3659
|
config: Optional[_UpscaleImageAPIConfig] = Field(
|
3582
3660
|
default=None, description="""Configuration for upscaling."""
|
3583
3661
|
)
|
@@ -3592,6 +3670,9 @@ class _UpscaleImageAPIParametersDict(TypedDict, total=False):
|
|
3592
3670
|
image: Optional[ImageDict]
|
3593
3671
|
"""The input image to upscale."""
|
3594
3672
|
|
3673
|
+
upscale_factor: Optional[str]
|
3674
|
+
"""The factor to upscale the image (x2 or x4)."""
|
3675
|
+
|
3595
3676
|
config: Optional[_UpscaleImageAPIConfigDict]
|
3596
3677
|
"""Configuration for upscaling."""
|
3597
3678
|
|
@@ -4182,7 +4263,7 @@ class TokensInfo(_common.BaseModel):
|
|
4182
4263
|
default=None,
|
4183
4264
|
description="""Optional. Optional fields for the role from the corresponding Content.""",
|
4184
4265
|
)
|
4185
|
-
token_ids: Optional[list[
|
4266
|
+
token_ids: Optional[list[int]] = Field(
|
4186
4267
|
default=None, description="""A list of token ids from the input."""
|
4187
4268
|
)
|
4188
4269
|
tokens: Optional[list[bytes]] = Field(
|
@@ -4196,7 +4277,7 @@ class TokensInfoDict(TypedDict, total=False):
|
|
4196
4277
|
role: Optional[str]
|
4197
4278
|
"""Optional. Optional fields for the role from the corresponding Content."""
|
4198
4279
|
|
4199
|
-
token_ids: Optional[list[
|
4280
|
+
token_ids: Optional[list[int]]
|
4200
4281
|
"""A list of token ids from the input."""
|
4201
4282
|
|
4202
4283
|
tokens: Optional[list[bytes]]
|
@@ -4344,7 +4425,7 @@ class SupervisedHyperParameters(_common.BaseModel):
|
|
4344
4425
|
adapter_size: Optional[AdapterSize] = Field(
|
4345
4426
|
default=None, description="""Optional. Adapter size for tuning."""
|
4346
4427
|
)
|
4347
|
-
epoch_count: Optional[
|
4428
|
+
epoch_count: Optional[int] = Field(
|
4348
4429
|
default=None,
|
4349
4430
|
description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",
|
4350
4431
|
)
|
@@ -4360,7 +4441,7 @@ class SupervisedHyperParametersDict(TypedDict, total=False):
|
|
4360
4441
|
adapter_size: Optional[AdapterSize]
|
4361
4442
|
"""Optional. Adapter size for tuning."""
|
4362
4443
|
|
4363
|
-
epoch_count: Optional[
|
4444
|
+
epoch_count: Optional[int]
|
4364
4445
|
"""Optional. Number of complete passes the model makes over the entire training dataset during training."""
|
4365
4446
|
|
4366
4447
|
learning_rate_multiplier: Optional[float]
|
@@ -4409,7 +4490,7 @@ SupervisedTuningSpecOrDict = Union[
|
|
4409
4490
|
class DatasetDistributionDistributionBucket(_common.BaseModel):
|
4410
4491
|
"""Dataset bucket used to create a histogram for the distribution given a population of values."""
|
4411
4492
|
|
4412
|
-
count: Optional[
|
4493
|
+
count: Optional[int] = Field(
|
4413
4494
|
default=None,
|
4414
4495
|
description="""Output only. Number of values in the bucket.""",
|
4415
4496
|
)
|
@@ -4424,7 +4505,7 @@ class DatasetDistributionDistributionBucket(_common.BaseModel):
|
|
4424
4505
|
class DatasetDistributionDistributionBucketDict(TypedDict, total=False):
|
4425
4506
|
"""Dataset bucket used to create a histogram for the distribution given a population of values."""
|
4426
4507
|
|
4427
|
-
count: Optional[
|
4508
|
+
count: Optional[int]
|
4428
4509
|
"""Output only. Number of values in the bucket."""
|
4429
4510
|
|
4430
4511
|
left: Optional[float]
|
@@ -4510,19 +4591,19 @@ DatasetDistributionOrDict = Union[DatasetDistribution, DatasetDistributionDict]
|
|
4510
4591
|
class DatasetStats(_common.BaseModel):
|
4511
4592
|
"""Statistics computed over a tuning dataset."""
|
4512
4593
|
|
4513
|
-
total_billable_character_count: Optional[
|
4594
|
+
total_billable_character_count: Optional[int] = Field(
|
4514
4595
|
default=None,
|
4515
4596
|
description="""Output only. Number of billable characters in the tuning dataset.""",
|
4516
4597
|
)
|
4517
|
-
total_tuning_character_count: Optional[
|
4598
|
+
total_tuning_character_count: Optional[int] = Field(
|
4518
4599
|
default=None,
|
4519
4600
|
description="""Output only. Number of tuning characters in the tuning dataset.""",
|
4520
4601
|
)
|
4521
|
-
tuning_dataset_example_count: Optional[
|
4602
|
+
tuning_dataset_example_count: Optional[int] = Field(
|
4522
4603
|
default=None,
|
4523
4604
|
description="""Output only. Number of examples in the tuning dataset.""",
|
4524
4605
|
)
|
4525
|
-
tuning_step_count: Optional[
|
4606
|
+
tuning_step_count: Optional[int] = Field(
|
4526
4607
|
default=None,
|
4527
4608
|
description="""Output only. Number of tuning steps for this Tuning Job.""",
|
4528
4609
|
)
|
@@ -4547,16 +4628,16 @@ class DatasetStats(_common.BaseModel):
|
|
4547
4628
|
class DatasetStatsDict(TypedDict, total=False):
|
4548
4629
|
"""Statistics computed over a tuning dataset."""
|
4549
4630
|
|
4550
|
-
total_billable_character_count: Optional[
|
4631
|
+
total_billable_character_count: Optional[int]
|
4551
4632
|
"""Output only. Number of billable characters in the tuning dataset."""
|
4552
4633
|
|
4553
|
-
total_tuning_character_count: Optional[
|
4634
|
+
total_tuning_character_count: Optional[int]
|
4554
4635
|
"""Output only. Number of tuning characters in the tuning dataset."""
|
4555
4636
|
|
4556
|
-
tuning_dataset_example_count: Optional[
|
4637
|
+
tuning_dataset_example_count: Optional[int]
|
4557
4638
|
"""Output only. Number of examples in the tuning dataset."""
|
4558
4639
|
|
4559
|
-
tuning_step_count: Optional[
|
4640
|
+
tuning_step_count: Optional[int]
|
4560
4641
|
"""Output only. Number of tuning steps for this Tuning Job."""
|
4561
4642
|
|
4562
4643
|
user_dataset_examples: Optional[list[ContentDict]]
|
@@ -4635,7 +4716,7 @@ SupervisedTuningDatasetDistributionDatasetBucketOrDict = Union[
|
|
4635
4716
|
class SupervisedTuningDatasetDistribution(_common.BaseModel):
|
4636
4717
|
"""Dataset distribution for Supervised Tuning."""
|
4637
4718
|
|
4638
|
-
billable_sum: Optional[
|
4719
|
+
billable_sum: Optional[int] = Field(
|
4639
4720
|
default=None,
|
4640
4721
|
description="""Output only. Sum of a given population of values that are billable.""",
|
4641
4722
|
)
|
@@ -4669,7 +4750,7 @@ class SupervisedTuningDatasetDistribution(_common.BaseModel):
|
|
4669
4750
|
default=None,
|
4670
4751
|
description="""Output only. The 95th percentile of the values in the population.""",
|
4671
4752
|
)
|
4672
|
-
sum: Optional[
|
4753
|
+
sum: Optional[int] = Field(
|
4673
4754
|
default=None,
|
4674
4755
|
description="""Output only. Sum of a given population of values.""",
|
4675
4756
|
)
|
@@ -4678,7 +4759,7 @@ class SupervisedTuningDatasetDistribution(_common.BaseModel):
|
|
4678
4759
|
class SupervisedTuningDatasetDistributionDict(TypedDict, total=False):
|
4679
4760
|
"""Dataset distribution for Supervised Tuning."""
|
4680
4761
|
|
4681
|
-
billable_sum: Optional[
|
4762
|
+
billable_sum: Optional[int]
|
4682
4763
|
"""Output only. Sum of a given population of values that are billable."""
|
4683
4764
|
|
4684
4765
|
buckets: Optional[list[SupervisedTuningDatasetDistributionDatasetBucketDict]]
|
@@ -4702,7 +4783,7 @@ class SupervisedTuningDatasetDistributionDict(TypedDict, total=False):
|
|
4702
4783
|
p95: Optional[float]
|
4703
4784
|
"""Output only. The 95th percentile of the values in the population."""
|
4704
4785
|
|
4705
|
-
sum: Optional[
|
4786
|
+
sum: Optional[int]
|
4706
4787
|
"""Output only. Sum of a given population of values."""
|
4707
4788
|
|
4708
4789
|
|
@@ -4714,31 +4795,31 @@ SupervisedTuningDatasetDistributionOrDict = Union[
|
|
4714
4795
|
class SupervisedTuningDataStats(_common.BaseModel):
|
4715
4796
|
"""Tuning data statistics for Supervised Tuning."""
|
4716
4797
|
|
4717
|
-
total_billable_character_count: Optional[
|
4798
|
+
total_billable_character_count: Optional[int] = Field(
|
4718
4799
|
default=None,
|
4719
4800
|
description="""Output only. Number of billable characters in the tuning dataset.""",
|
4720
4801
|
)
|
4721
|
-
total_billable_token_count: Optional[
|
4802
|
+
total_billable_token_count: Optional[int] = Field(
|
4722
4803
|
default=None,
|
4723
4804
|
description="""Output only. Number of billable tokens in the tuning dataset.""",
|
4724
4805
|
)
|
4725
|
-
total_truncated_example_count: Optional[
|
4806
|
+
total_truncated_example_count: Optional[int] = Field(
|
4726
4807
|
default=None,
|
4727
4808
|
description="""The number of examples in the dataset that have been truncated by any amount.""",
|
4728
4809
|
)
|
4729
|
-
total_tuning_character_count: Optional[
|
4810
|
+
total_tuning_character_count: Optional[int] = Field(
|
4730
4811
|
default=None,
|
4731
4812
|
description="""Output only. Number of tuning characters in the tuning dataset.""",
|
4732
4813
|
)
|
4733
|
-
truncated_example_indices: Optional[list[
|
4814
|
+
truncated_example_indices: Optional[list[int]] = Field(
|
4734
4815
|
default=None,
|
4735
4816
|
description="""A partial sample of the indices (starting from 1) of the truncated examples.""",
|
4736
4817
|
)
|
4737
|
-
tuning_dataset_example_count: Optional[
|
4818
|
+
tuning_dataset_example_count: Optional[int] = Field(
|
4738
4819
|
default=None,
|
4739
4820
|
description="""Output only. Number of examples in the tuning dataset.""",
|
4740
4821
|
)
|
4741
|
-
tuning_step_count: Optional[
|
4822
|
+
tuning_step_count: Optional[int] = Field(
|
4742
4823
|
default=None,
|
4743
4824
|
description="""Output only. Number of tuning steps for this Tuning Job.""",
|
4744
4825
|
)
|
@@ -4769,25 +4850,25 @@ class SupervisedTuningDataStats(_common.BaseModel):
|
|
4769
4850
|
class SupervisedTuningDataStatsDict(TypedDict, total=False):
|
4770
4851
|
"""Tuning data statistics for Supervised Tuning."""
|
4771
4852
|
|
4772
|
-
total_billable_character_count: Optional[
|
4853
|
+
total_billable_character_count: Optional[int]
|
4773
4854
|
"""Output only. Number of billable characters in the tuning dataset."""
|
4774
4855
|
|
4775
|
-
total_billable_token_count: Optional[
|
4856
|
+
total_billable_token_count: Optional[int]
|
4776
4857
|
"""Output only. Number of billable tokens in the tuning dataset."""
|
4777
4858
|
|
4778
|
-
total_truncated_example_count: Optional[
|
4859
|
+
total_truncated_example_count: Optional[int]
|
4779
4860
|
"""The number of examples in the dataset that have been truncated by any amount."""
|
4780
4861
|
|
4781
|
-
total_tuning_character_count: Optional[
|
4862
|
+
total_tuning_character_count: Optional[int]
|
4782
4863
|
"""Output only. Number of tuning characters in the tuning dataset."""
|
4783
4864
|
|
4784
|
-
truncated_example_indices: Optional[list[
|
4865
|
+
truncated_example_indices: Optional[list[int]]
|
4785
4866
|
"""A partial sample of the indices (starting from 1) of the truncated examples."""
|
4786
4867
|
|
4787
|
-
tuning_dataset_example_count: Optional[
|
4868
|
+
tuning_dataset_example_count: Optional[int]
|
4788
4869
|
"""Output only. Number of examples in the tuning dataset."""
|
4789
4870
|
|
4790
|
-
tuning_step_count: Optional[
|
4871
|
+
tuning_step_count: Optional[int]
|
4791
4872
|
"""Output only. Number of tuning steps for this Tuning Job."""
|
4792
4873
|
|
4793
4874
|
user_dataset_examples: Optional[list[ContentDict]]
|
@@ -4863,7 +4944,7 @@ class DistillationHyperParameters(_common.BaseModel):
|
|
4863
4944
|
adapter_size: Optional[AdapterSize] = Field(
|
4864
4945
|
default=None, description="""Optional. Adapter size for distillation."""
|
4865
4946
|
)
|
4866
|
-
epoch_count: Optional[
|
4947
|
+
epoch_count: Optional[int] = Field(
|
4867
4948
|
default=None,
|
4868
4949
|
description="""Optional. Number of complete passes the model makes over the entire training dataset during training.""",
|
4869
4950
|
)
|
@@ -4879,7 +4960,7 @@ class DistillationHyperParametersDict(TypedDict, total=False):
|
|
4879
4960
|
adapter_size: Optional[AdapterSize]
|
4880
4961
|
"""Optional. Adapter size for distillation."""
|
4881
4962
|
|
4882
|
-
epoch_count: Optional[
|
4963
|
+
epoch_count: Optional[int]
|
4883
4964
|
"""Optional. Number of complete passes the model makes over the entire training dataset during training."""
|
4884
4965
|
|
4885
4966
|
learning_rate_multiplier: Optional[float]
|
@@ -5567,6 +5648,11 @@ class CreateCachedContentConfig(_common.BaseModel):
|
|
5567
5648
|
description="""The user-generated meaningful display name of the cached content.
|
5568
5649
|
""",
|
5569
5650
|
)
|
5651
|
+
contents: Optional[ContentListUnion] = Field(
|
5652
|
+
default=None,
|
5653
|
+
description="""The content to cache.
|
5654
|
+
""",
|
5655
|
+
)
|
5570
5656
|
system_instruction: Optional[ContentUnion] = Field(
|
5571
5657
|
default=None,
|
5572
5658
|
description="""Developer set system instruction.
|
@@ -5600,6 +5686,10 @@ class CreateCachedContentConfigDict(TypedDict, total=False):
|
|
5600
5686
|
"""The user-generated meaningful display name of the cached content.
|
5601
5687
|
"""
|
5602
5688
|
|
5689
|
+
contents: Optional[ContentListUnionDict]
|
5690
|
+
"""The content to cache.
|
5691
|
+
"""
|
5692
|
+
|
5603
5693
|
system_instruction: Optional[ContentUnionDict]
|
5604
5694
|
"""Developer set system instruction.
|
5605
5695
|
"""
|
@@ -5625,11 +5715,6 @@ class _CreateCachedContentParameters(_common.BaseModel):
|
|
5625
5715
|
default=None,
|
5626
5716
|
description="""ID of the model to use. Example: gemini-1.5-flash""",
|
5627
5717
|
)
|
5628
|
-
contents: Optional[ContentListUnion] = Field(
|
5629
|
-
default=None,
|
5630
|
-
description="""The content to cache.
|
5631
|
-
""",
|
5632
|
-
)
|
5633
5718
|
config: Optional[CreateCachedContentConfig] = Field(
|
5634
5719
|
default=None,
|
5635
5720
|
description="""Configuration that contains optional parameters.
|
@@ -5643,10 +5728,6 @@ class _CreateCachedContentParametersDict(TypedDict, total=False):
|
|
5643
5728
|
model: Optional[str]
|
5644
5729
|
"""ID of the model to use. Example: gemini-1.5-flash"""
|
5645
5730
|
|
5646
|
-
contents: Optional[ContentListUnionDict]
|
5647
|
-
"""The content to cache.
|
5648
|
-
"""
|
5649
|
-
|
5650
5731
|
config: Optional[CreateCachedContentConfigDict]
|
5651
5732
|
"""Configuration that contains optional parameters.
|
5652
5733
|
"""
|
@@ -6481,7 +6562,7 @@ class CreateBatchJobConfig(_common.BaseModel):
|
|
6481
6562
|
)
|
6482
6563
|
dest: Optional[str] = Field(
|
6483
6564
|
default=None,
|
6484
|
-
description="""GCS or
|
6565
|
+
description="""GCS or BigQuery URI prefix for the output predictions. Example:
|
6485
6566
|
"gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
|
6486
6567
|
""",
|
6487
6568
|
)
|
@@ -6498,7 +6579,7 @@ class CreateBatchJobConfigDict(TypedDict, total=False):
|
|
6498
6579
|
"""
|
6499
6580
|
|
6500
6581
|
dest: Optional[str]
|
6501
|
-
"""GCS or
|
6582
|
+
"""GCS or BigQuery URI prefix for the output predictions. Example:
|
6502
6583
|
"gs://path/to/output/data" or "bq://projectId.bqDatasetId.bqTableId".
|
6503
6584
|
"""
|
6504
6585
|
|
@@ -6518,7 +6599,7 @@ class _CreateBatchJobParameters(_common.BaseModel):
|
|
6518
6599
|
)
|
6519
6600
|
src: Optional[str] = Field(
|
6520
6601
|
default=None,
|
6521
|
-
description="""GCS URI(-s) or
|
6602
|
+
description="""GCS URI(-s) or BigQuery URI to your input data to run batch job.
|
6522
6603
|
Example: "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".
|
6523
6604
|
""",
|
6524
6605
|
)
|
@@ -6537,7 +6618,7 @@ class _CreateBatchJobParametersDict(TypedDict, total=False):
|
|
6537
6618
|
"""
|
6538
6619
|
|
6539
6620
|
src: Optional[str]
|
6540
|
-
"""GCS URI(-s) or
|
6621
|
+
"""GCS URI(-s) or BigQuery URI to your input data to run batch job.
|
6541
6622
|
Example: "gs://path/to/input/data" or "bq://projectId.bqDatasetId.bqTableId".
|
6542
6623
|
"""
|
6543
6624
|
|
@@ -7139,10 +7220,6 @@ class UpscaleImageConfig(_common.BaseModel):
|
|
7139
7220
|
http_options: Optional[dict[str, Any]] = Field(
|
7140
7221
|
default=None, description="""Used to override HTTP request options."""
|
7141
7222
|
)
|
7142
|
-
upscale_factor: Optional[str] = Field(
|
7143
|
-
default=None,
|
7144
|
-
description="""The factor to which the image will be upscaled.""",
|
7145
|
-
)
|
7146
7223
|
include_rai_reason: Optional[bool] = Field(
|
7147
7224
|
default=None,
|
7148
7225
|
description="""Whether to include a reason for filtered-out images in the
|
@@ -7170,9 +7247,6 @@ class UpscaleImageConfigDict(TypedDict, total=False):
|
|
7170
7247
|
http_options: Optional[dict[str, Any]]
|
7171
7248
|
"""Used to override HTTP request options."""
|
7172
7249
|
|
7173
|
-
upscale_factor: Optional[str]
|
7174
|
-
"""The factor to which the image will be upscaled."""
|
7175
|
-
|
7176
7250
|
include_rai_reason: Optional[bool]
|
7177
7251
|
"""Whether to include a reason for filtered-out images in the
|
7178
7252
|
response."""
|
@@ -7197,6 +7271,10 @@ class UpscaleImageParameters(_common.BaseModel):
|
|
7197
7271
|
image: Optional[Image] = Field(
|
7198
7272
|
default=None, description="""The input image to upscale."""
|
7199
7273
|
)
|
7274
|
+
upscale_factor: Optional[str] = Field(
|
7275
|
+
default=None,
|
7276
|
+
description="""The factor to upscale the image (x2 or x4).""",
|
7277
|
+
)
|
7200
7278
|
config: Optional[UpscaleImageConfig] = Field(
|
7201
7279
|
default=None, description="""Configuration for upscaling."""
|
7202
7280
|
)
|
@@ -7211,6 +7289,9 @@ class UpscaleImageParametersDict(TypedDict, total=False):
|
|
7211
7289
|
image: Optional[ImageDict]
|
7212
7290
|
"""The input image to upscale."""
|
7213
7291
|
|
7292
|
+
upscale_factor: Optional[str]
|
7293
|
+
"""The factor to upscale the image (x2 or x4)."""
|
7294
|
+
|
7214
7295
|
config: Optional[UpscaleImageConfigDict]
|
7215
7296
|
"""Configuration for upscaling."""
|
7216
7297
|
|
@@ -7644,7 +7725,7 @@ class LiveServerToolCallCancellation(_common.BaseModel):
|
|
7644
7725
|
server turns.
|
7645
7726
|
"""
|
7646
7727
|
|
7647
|
-
ids: Optional[list[
|
7728
|
+
ids: Optional[list[str]] = Field(
|
7648
7729
|
default=None, description="""The ids of the tool calls to be cancelled."""
|
7649
7730
|
)
|
7650
7731
|
|
@@ -7657,7 +7738,7 @@ class LiveServerToolCallCancellationDict(TypedDict, total=False):
|
|
7657
7738
|
server turns.
|
7658
7739
|
"""
|
7659
7740
|
|
7660
|
-
ids: Optional[list[
|
7741
|
+
ids: Optional[list[str]]
|
7661
7742
|
"""The ids of the tool calls to be cancelled."""
|
7662
7743
|
|
7663
7744
|
|
@@ -7699,6 +7780,8 @@ class LiveServerMessage(_common.BaseModel):
|
|
7699
7780
|
text = ""
|
7700
7781
|
for part in self.server_content.model_turn.parts:
|
7701
7782
|
if isinstance(part.text, str):
|
7783
|
+
if isinstance(part.thought, bool) and part.thought:
|
7784
|
+
continue
|
7702
7785
|
text += part.text
|
7703
7786
|
return text if text else None
|
7704
7787
|
|
@@ -7943,7 +8026,7 @@ class LiveClientMessage(_common.BaseModel):
|
|
7943
8026
|
default=None,
|
7944
8027
|
description="""Incremental update of the current conversation delivered from the client.""",
|
7945
8028
|
)
|
7946
|
-
|
8029
|
+
realtime_input: Optional[LiveClientRealtimeInput] = Field(
|
7947
8030
|
default=None, description="""User input that is sent in real time."""
|
7948
8031
|
)
|
7949
8032
|
tool_response: Optional[LiveClientToolResponse] = Field(
|
@@ -7961,7 +8044,7 @@ class LiveClientMessageDict(TypedDict, total=False):
|
|
7961
8044
|
client_content: Optional[LiveClientContentDict]
|
7962
8045
|
"""Incremental update of the current conversation delivered from the client."""
|
7963
8046
|
|
7964
|
-
|
8047
|
+
realtime_input: Optional[LiveClientRealtimeInputDict]
|
7965
8048
|
"""User input that is sent in real time."""
|
7966
8049
|
|
7967
8050
|
tool_response: Optional[LiveClientToolResponseDict]
|