google-genai 1.12.0__py3-none-any.whl → 1.13.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/_api_client.py +0 -17
- google/genai/_base_url.py +50 -0
- google/genai/_live_converters.py +28 -226
- google/genai/_transformers.py +2 -2
- google/genai/batches.py +2 -2
- google/genai/caches.py +14 -226
- google/genai/chats.py +4 -4
- google/genai/client.py +21 -9
- google/genai/live.py +9 -6
- google/genai/models.py +16 -236
- google/genai/types.py +836 -840
- google/genai/version.py +1 -1
- {google_genai-1.12.0.dist-info → google_genai-1.13.0.dist-info}/METADATA +6 -6
- google_genai-1.13.0.dist-info/RECORD +30 -0
- {google_genai-1.12.0.dist-info → google_genai-1.13.0.dist-info}/WHEEL +1 -1
- google_genai-1.12.0.dist-info/RECORD +0 -29
- {google_genai-1.12.0.dist-info → google_genai-1.13.0.dist-info}/licenses/LICENSE +0 -0
- {google_genai-1.12.0.dist-info → google_genai-1.13.0.dist-info}/top_level.txt +0 -0
google/genai/types.py
CHANGED
@@ -76,18 +76,6 @@ class Language(_common.CaseInSensitiveEnum):
|
|
76
76
|
PYTHON = 'PYTHON'
|
77
77
|
|
78
78
|
|
79
|
-
class Type(_common.CaseInSensitiveEnum):
|
80
|
-
"""Optional. The type of the data."""
|
81
|
-
|
82
|
-
TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'
|
83
|
-
STRING = 'STRING'
|
84
|
-
NUMBER = 'NUMBER'
|
85
|
-
INTEGER = 'INTEGER'
|
86
|
-
BOOLEAN = 'BOOLEAN'
|
87
|
-
ARRAY = 'ARRAY'
|
88
|
-
OBJECT = 'OBJECT'
|
89
|
-
|
90
|
-
|
91
79
|
class HarmCategory(_common.CaseInSensitiveEnum):
|
92
80
|
"""Required. Harm category."""
|
93
81
|
|
@@ -129,6 +117,18 @@ class Mode(_common.CaseInSensitiveEnum):
|
|
129
117
|
MODE_DYNAMIC = 'MODE_DYNAMIC'
|
130
118
|
|
131
119
|
|
120
|
+
class Type(_common.CaseInSensitiveEnum):
|
121
|
+
"""Optional. The type of the data."""
|
122
|
+
|
123
|
+
TYPE_UNSPECIFIED = 'TYPE_UNSPECIFIED'
|
124
|
+
STRING = 'STRING'
|
125
|
+
NUMBER = 'NUMBER'
|
126
|
+
INTEGER = 'INTEGER'
|
127
|
+
BOOLEAN = 'BOOLEAN'
|
128
|
+
ARRAY = 'ARRAY'
|
129
|
+
OBJECT = 'OBJECT'
|
130
|
+
|
131
|
+
|
132
132
|
class FinishReason(_common.CaseInSensitiveEnum):
|
133
133
|
"""Output only. The reason why the model stopped generating tokens.
|
134
134
|
|
@@ -881,219 +881,653 @@ class HttpOptionsDict(TypedDict, total=False):
|
|
881
881
|
HttpOptionsOrDict = Union[HttpOptions, HttpOptionsDict]
|
882
882
|
|
883
883
|
|
884
|
-
class
|
885
|
-
"""
|
884
|
+
class ModelSelectionConfig(_common.BaseModel):
|
885
|
+
"""Config for model selection."""
|
886
886
|
|
887
|
-
|
888
|
-
|
889
|
-
|
887
|
+
feature_selection_preference: Optional[FeatureSelectionPreference] = Field(
|
888
|
+
default=None, description="""Options for feature selection preference."""
|
889
|
+
)
|
890
890
|
|
891
|
-
NULL = 'null'
|
892
|
-
BOOLEAN = 'boolean'
|
893
|
-
OBJECT = 'object'
|
894
|
-
ARRAY = 'array'
|
895
|
-
NUMBER = 'number'
|
896
|
-
INTEGER = 'integer'
|
897
|
-
STRING = 'string'
|
898
891
|
|
892
|
+
class ModelSelectionConfigDict(TypedDict, total=False):
|
893
|
+
"""Config for model selection."""
|
899
894
|
|
900
|
-
|
901
|
-
"""
|
895
|
+
feature_selection_preference: Optional[FeatureSelectionPreference]
|
896
|
+
"""Options for feature selection preference."""
|
902
897
|
|
903
|
-
Represents a subset of a JSON Schema object that is used by the Gemini model.
|
904
|
-
The difference between this class and the Schema class is that this class is
|
905
|
-
compatible with OpenAPI 3.1 schema objects. And the Schema class is used to
|
906
|
-
make API call to Gemini model.
|
907
|
-
"""
|
908
898
|
|
909
|
-
|
899
|
+
ModelSelectionConfigOrDict = Union[
|
900
|
+
ModelSelectionConfig, ModelSelectionConfigDict
|
901
|
+
]
|
902
|
+
|
903
|
+
|
904
|
+
class SafetySetting(_common.BaseModel):
|
905
|
+
"""Safety settings."""
|
906
|
+
|
907
|
+
method: Optional[HarmBlockMethod] = Field(
|
910
908
|
default=None,
|
911
|
-
description="""
|
909
|
+
description="""Determines if the harm block method uses probability or probability
|
910
|
+
and severity scores.""",
|
912
911
|
)
|
913
|
-
|
914
|
-
default=None,
|
915
|
-
description='Define semantic information about a string instance.',
|
912
|
+
category: Optional[HarmCategory] = Field(
|
913
|
+
default=None, description="""Required. Harm category."""
|
916
914
|
)
|
917
|
-
|
915
|
+
threshold: Optional[HarmBlockThreshold] = Field(
|
916
|
+
default=None, description="""Required. The harm block threshold."""
|
917
|
+
)
|
918
|
+
|
919
|
+
|
920
|
+
class SafetySettingDict(TypedDict, total=False):
|
921
|
+
"""Safety settings."""
|
922
|
+
|
923
|
+
method: Optional[HarmBlockMethod]
|
924
|
+
"""Determines if the harm block method uses probability or probability
|
925
|
+
and severity scores."""
|
926
|
+
|
927
|
+
category: Optional[HarmCategory]
|
928
|
+
"""Required. Harm category."""
|
929
|
+
|
930
|
+
threshold: Optional[HarmBlockThreshold]
|
931
|
+
"""Required. The harm block threshold."""
|
932
|
+
|
933
|
+
|
934
|
+
SafetySettingOrDict = Union[SafetySetting, SafetySettingDict]
|
935
|
+
|
936
|
+
|
937
|
+
class GoogleSearch(_common.BaseModel):
|
938
|
+
"""Tool to support Google Search in Model. Powered by Google."""
|
939
|
+
|
940
|
+
pass
|
941
|
+
|
942
|
+
|
943
|
+
class GoogleSearchDict(TypedDict, total=False):
|
944
|
+
"""Tool to support Google Search in Model. Powered by Google."""
|
945
|
+
|
946
|
+
pass
|
947
|
+
|
948
|
+
|
949
|
+
GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict]
|
950
|
+
|
951
|
+
|
952
|
+
class DynamicRetrievalConfig(_common.BaseModel):
|
953
|
+
"""Describes the options to customize dynamic retrieval."""
|
954
|
+
|
955
|
+
mode: Optional[DynamicRetrievalConfigMode] = Field(
|
918
956
|
default=None,
|
919
|
-
description=
|
920
|
-
'A preferably short description about the purpose of the instance'
|
921
|
-
' described by the schema.'
|
922
|
-
),
|
957
|
+
description="""The mode of the predictor to be used in dynamic retrieval.""",
|
923
958
|
)
|
924
|
-
|
959
|
+
dynamic_threshold: Optional[float] = Field(
|
925
960
|
default=None,
|
926
|
-
description=
|
927
|
-
'An explanation about the purpose of the instance described by the'
|
928
|
-
' schema.'
|
929
|
-
),
|
961
|
+
description="""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.""",
|
930
962
|
)
|
931
|
-
|
963
|
+
|
964
|
+
|
965
|
+
class DynamicRetrievalConfigDict(TypedDict, total=False):
|
966
|
+
"""Describes the options to customize dynamic retrieval."""
|
967
|
+
|
968
|
+
mode: Optional[DynamicRetrievalConfigMode]
|
969
|
+
"""The mode of the predictor to be used in dynamic retrieval."""
|
970
|
+
|
971
|
+
dynamic_threshold: Optional[float]
|
972
|
+
"""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used."""
|
973
|
+
|
974
|
+
|
975
|
+
DynamicRetrievalConfigOrDict = Union[
|
976
|
+
DynamicRetrievalConfig, DynamicRetrievalConfigDict
|
977
|
+
]
|
978
|
+
|
979
|
+
|
980
|
+
class GoogleSearchRetrieval(_common.BaseModel):
|
981
|
+
"""Tool to retrieve public web data for grounding, powered by Google."""
|
982
|
+
|
983
|
+
dynamic_retrieval_config: Optional[DynamicRetrievalConfig] = Field(
|
932
984
|
default=None,
|
933
|
-
description=
|
934
|
-
'This keyword can be used to supply a default JSON value associated'
|
935
|
-
' with a particular schema.'
|
936
|
-
),
|
985
|
+
description="""Specifies the dynamic retrieval configuration for the given source.""",
|
937
986
|
)
|
938
|
-
|
987
|
+
|
988
|
+
|
989
|
+
class GoogleSearchRetrievalDict(TypedDict, total=False):
|
990
|
+
"""Tool to retrieve public web data for grounding, powered by Google."""
|
991
|
+
|
992
|
+
dynamic_retrieval_config: Optional[DynamicRetrievalConfigDict]
|
993
|
+
"""Specifies the dynamic retrieval configuration for the given source."""
|
994
|
+
|
995
|
+
|
996
|
+
GoogleSearchRetrievalOrDict = Union[
|
997
|
+
GoogleSearchRetrieval, GoogleSearchRetrievalDict
|
998
|
+
]
|
999
|
+
|
1000
|
+
|
1001
|
+
class VertexAISearch(_common.BaseModel):
|
1002
|
+
"""Retrieve from Vertex AI Search datastore or engine for grounding.
|
1003
|
+
|
1004
|
+
datastore and engine are mutually exclusive. See
|
1005
|
+
https://cloud.google.com/products/agent-builder
|
1006
|
+
"""
|
1007
|
+
|
1008
|
+
datastore: Optional[str] = Field(
|
939
1009
|
default=None,
|
940
|
-
description=
|
941
|
-
'Validation succeeds if each element of the instance not covered by'
|
942
|
-
' prefixItems validates against this schema.'
|
943
|
-
),
|
1010
|
+
description="""Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`""",
|
944
1011
|
)
|
945
|
-
|
1012
|
+
engine: Optional[str] = Field(
|
946
1013
|
default=None,
|
947
|
-
description=
|
948
|
-
'An array instance is valid if its size is greater than, or equal to,'
|
949
|
-
' the value of this keyword.'
|
950
|
-
),
|
1014
|
+
description="""Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`""",
|
951
1015
|
)
|
952
|
-
|
1016
|
+
|
1017
|
+
|
1018
|
+
class VertexAISearchDict(TypedDict, total=False):
|
1019
|
+
"""Retrieve from Vertex AI Search datastore or engine for grounding.
|
1020
|
+
|
1021
|
+
datastore and engine are mutually exclusive. See
|
1022
|
+
https://cloud.google.com/products/agent-builder
|
1023
|
+
"""
|
1024
|
+
|
1025
|
+
datastore: Optional[str]
|
1026
|
+
"""Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`"""
|
1027
|
+
|
1028
|
+
engine: Optional[str]
|
1029
|
+
"""Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`"""
|
1030
|
+
|
1031
|
+
|
1032
|
+
VertexAISearchOrDict = Union[VertexAISearch, VertexAISearchDict]
|
1033
|
+
|
1034
|
+
|
1035
|
+
class VertexRagStoreRagResource(_common.BaseModel):
|
1036
|
+
"""The definition of the Rag resource."""
|
1037
|
+
|
1038
|
+
rag_corpus: Optional[str] = Field(
|
953
1039
|
default=None,
|
954
|
-
description=
|
955
|
-
'An array instance is valid if its size is less than, or equal to,'
|
956
|
-
' the value of this keyword.'
|
957
|
-
),
|
1040
|
+
description="""Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`""",
|
958
1041
|
)
|
959
|
-
|
1042
|
+
rag_file_ids: Optional[list[str]] = Field(
|
960
1043
|
default=None,
|
961
|
-
description=
|
962
|
-
'Validation succeeds if the instance is equal to one of the elements'
|
963
|
-
' in this keyword’s array value.'
|
964
|
-
),
|
1044
|
+
description="""Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field.""",
|
965
1045
|
)
|
966
|
-
|
1046
|
+
|
1047
|
+
|
1048
|
+
class VertexRagStoreRagResourceDict(TypedDict, total=False):
|
1049
|
+
"""The definition of the Rag resource."""
|
1050
|
+
|
1051
|
+
rag_corpus: Optional[str]
|
1052
|
+
"""Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`"""
|
1053
|
+
|
1054
|
+
rag_file_ids: Optional[list[str]]
|
1055
|
+
"""Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field."""
|
1056
|
+
|
1057
|
+
|
1058
|
+
VertexRagStoreRagResourceOrDict = Union[
|
1059
|
+
VertexRagStoreRagResource, VertexRagStoreRagResourceDict
|
1060
|
+
]
|
1061
|
+
|
1062
|
+
|
1063
|
+
class RagRetrievalConfigFilter(_common.BaseModel):
|
1064
|
+
"""Config for filters."""
|
1065
|
+
|
1066
|
+
metadata_filter: Optional[str] = Field(
|
1067
|
+
default=None, description="""Optional. String for metadata filtering."""
|
1068
|
+
)
|
1069
|
+
vector_distance_threshold: Optional[float] = Field(
|
967
1070
|
default=None,
|
968
|
-
description=
|
969
|
-
'Validation succeeds if, for each name that appears in both the'
|
970
|
-
' instance and as a name within this keyword’s value, the child'
|
971
|
-
' instance for that name successfully validates against the'
|
972
|
-
' corresponding schema.'
|
973
|
-
),
|
1071
|
+
description="""Optional. Only returns contexts with vector distance smaller than the threshold.""",
|
974
1072
|
)
|
975
|
-
|
1073
|
+
vector_similarity_threshold: Optional[float] = Field(
|
976
1074
|
default=None,
|
977
|
-
description=
|
978
|
-
'An object instance is valid against this keyword if every item in'
|
979
|
-
' the array is the name of a property in the instance.'
|
980
|
-
),
|
1075
|
+
description="""Optional. Only returns contexts with vector similarity larger than the threshold.""",
|
981
1076
|
)
|
982
|
-
|
1077
|
+
|
1078
|
+
|
1079
|
+
class RagRetrievalConfigFilterDict(TypedDict, total=False):
|
1080
|
+
"""Config for filters."""
|
1081
|
+
|
1082
|
+
metadata_filter: Optional[str]
|
1083
|
+
"""Optional. String for metadata filtering."""
|
1084
|
+
|
1085
|
+
vector_distance_threshold: Optional[float]
|
1086
|
+
"""Optional. Only returns contexts with vector distance smaller than the threshold."""
|
1087
|
+
|
1088
|
+
vector_similarity_threshold: Optional[float]
|
1089
|
+
"""Optional. Only returns contexts with vector similarity larger than the threshold."""
|
1090
|
+
|
1091
|
+
|
1092
|
+
RagRetrievalConfigFilterOrDict = Union[
|
1093
|
+
RagRetrievalConfigFilter, RagRetrievalConfigFilterDict
|
1094
|
+
]
|
1095
|
+
|
1096
|
+
|
1097
|
+
class RagRetrievalConfigHybridSearch(_common.BaseModel):
|
1098
|
+
"""Config for Hybrid Search."""
|
1099
|
+
|
1100
|
+
alpha: Optional[float] = Field(
|
983
1101
|
default=None,
|
984
|
-
description=
|
985
|
-
'An object instance is valid if its number of properties is greater'
|
986
|
-
' than, or equal to, the value of this keyword.'
|
987
|
-
),
|
1102
|
+
description="""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally.""",
|
988
1103
|
)
|
989
|
-
|
1104
|
+
|
1105
|
+
|
1106
|
+
class RagRetrievalConfigHybridSearchDict(TypedDict, total=False):
|
1107
|
+
"""Config for Hybrid Search."""
|
1108
|
+
|
1109
|
+
alpha: Optional[float]
|
1110
|
+
"""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally."""
|
1111
|
+
|
1112
|
+
|
1113
|
+
RagRetrievalConfigHybridSearchOrDict = Union[
|
1114
|
+
RagRetrievalConfigHybridSearch, RagRetrievalConfigHybridSearchDict
|
1115
|
+
]
|
1116
|
+
|
1117
|
+
|
1118
|
+
class RagRetrievalConfigRankingLlmRanker(_common.BaseModel):
|
1119
|
+
"""Config for LlmRanker."""
|
1120
|
+
|
1121
|
+
model_name: Optional[str] = Field(
|
990
1122
|
default=None,
|
991
|
-
description=
|
992
|
-
'An object instance is valid if its number of properties is less'
|
993
|
-
' than, or equal to, the value of this keyword.'
|
994
|
-
),
|
1123
|
+
description="""Optional. The model name used for ranking. Format: `gemini-1.5-pro`""",
|
995
1124
|
)
|
996
|
-
|
1125
|
+
|
1126
|
+
|
1127
|
+
class RagRetrievalConfigRankingLlmRankerDict(TypedDict, total=False):
|
1128
|
+
"""Config for LlmRanker."""
|
1129
|
+
|
1130
|
+
model_name: Optional[str]
|
1131
|
+
"""Optional. The model name used for ranking. Format: `gemini-1.5-pro`"""
|
1132
|
+
|
1133
|
+
|
1134
|
+
RagRetrievalConfigRankingLlmRankerOrDict = Union[
|
1135
|
+
RagRetrievalConfigRankingLlmRanker, RagRetrievalConfigRankingLlmRankerDict
|
1136
|
+
]
|
1137
|
+
|
1138
|
+
|
1139
|
+
class RagRetrievalConfigRankingRankService(_common.BaseModel):
|
1140
|
+
"""Config for Rank Service."""
|
1141
|
+
|
1142
|
+
model_name: Optional[str] = Field(
|
997
1143
|
default=None,
|
998
|
-
description=
|
999
|
-
'Validation succeeds if the numeric instance is greater than or equal'
|
1000
|
-
' to the given number.'
|
1001
|
-
),
|
1144
|
+
description="""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`""",
|
1002
1145
|
)
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1146
|
+
|
1147
|
+
|
1148
|
+
class RagRetrievalConfigRankingRankServiceDict(TypedDict, total=False):
|
1149
|
+
"""Config for Rank Service."""
|
1150
|
+
|
1151
|
+
model_name: Optional[str]
|
1152
|
+
"""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`"""
|
1153
|
+
|
1154
|
+
|
1155
|
+
RagRetrievalConfigRankingRankServiceOrDict = Union[
|
1156
|
+
RagRetrievalConfigRankingRankService,
|
1157
|
+
RagRetrievalConfigRankingRankServiceDict,
|
1158
|
+
]
|
1159
|
+
|
1160
|
+
|
1161
|
+
class RagRetrievalConfigRanking(_common.BaseModel):
|
1162
|
+
"""Config for ranking and reranking."""
|
1163
|
+
|
1164
|
+
llm_ranker: Optional[RagRetrievalConfigRankingLlmRanker] = Field(
|
1165
|
+
default=None, description="""Optional. Config for LlmRanker."""
|
1009
1166
|
)
|
1010
|
-
|
1011
|
-
default=None,
|
1012
|
-
description=(
|
1013
|
-
'A string instance is valid against this keyword if its length is'
|
1014
|
-
' greater than, or equal to, the value of this keyword.'
|
1015
|
-
),
|
1167
|
+
rank_service: Optional[RagRetrievalConfigRankingRankService] = Field(
|
1168
|
+
default=None, description="""Optional. Config for Rank Service."""
|
1016
1169
|
)
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1170
|
+
|
1171
|
+
|
1172
|
+
class RagRetrievalConfigRankingDict(TypedDict, total=False):
|
1173
|
+
"""Config for ranking and reranking."""
|
1174
|
+
|
1175
|
+
llm_ranker: Optional[RagRetrievalConfigRankingLlmRankerDict]
|
1176
|
+
"""Optional. Config for LlmRanker."""
|
1177
|
+
|
1178
|
+
rank_service: Optional[RagRetrievalConfigRankingRankServiceDict]
|
1179
|
+
"""Optional. Config for Rank Service."""
|
1180
|
+
|
1181
|
+
|
1182
|
+
RagRetrievalConfigRankingOrDict = Union[
|
1183
|
+
RagRetrievalConfigRanking, RagRetrievalConfigRankingDict
|
1184
|
+
]
|
1185
|
+
|
1186
|
+
|
1187
|
+
class RagRetrievalConfig(_common.BaseModel):
|
1188
|
+
"""Specifies the context retrieval config."""
|
1189
|
+
|
1190
|
+
filter: Optional[RagRetrievalConfigFilter] = Field(
|
1191
|
+
default=None, description="""Optional. Config for filters."""
|
1023
1192
|
)
|
1024
|
-
|
1193
|
+
hybrid_search: Optional[RagRetrievalConfigHybridSearch] = Field(
|
1194
|
+
default=None, description="""Optional. Config for Hybrid Search."""
|
1195
|
+
)
|
1196
|
+
ranking: Optional[RagRetrievalConfigRanking] = Field(
|
1025
1197
|
default=None,
|
1026
|
-
description=
|
1027
|
-
'A string instance is considered valid if the regular expression'
|
1028
|
-
' matches the instance successfully.'
|
1029
|
-
),
|
1198
|
+
description="""Optional. Config for ranking and reranking.""",
|
1030
1199
|
)
|
1031
|
-
|
1200
|
+
top_k: Optional[int] = Field(
|
1032
1201
|
default=None,
|
1033
|
-
description=
|
1034
|
-
'An instance validates successfully against this keyword if it'
|
1035
|
-
' validates successfully against at least one schema defined by this'
|
1036
|
-
' keyword’s value.'
|
1037
|
-
),
|
1202
|
+
description="""Optional. The number of contexts to retrieve.""",
|
1038
1203
|
)
|
1039
1204
|
|
1040
1205
|
|
1041
|
-
class
|
1042
|
-
"""
|
1206
|
+
class RagRetrievalConfigDict(TypedDict, total=False):
|
1207
|
+
"""Specifies the context retrieval config."""
|
1043
1208
|
|
1044
|
-
|
1045
|
-
"""
|
1209
|
+
filter: Optional[RagRetrievalConfigFilterDict]
|
1210
|
+
"""Optional. Config for filters."""
|
1046
1211
|
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1212
|
+
hybrid_search: Optional[RagRetrievalConfigHybridSearchDict]
|
1213
|
+
"""Optional. Config for Hybrid Search."""
|
1214
|
+
|
1215
|
+
ranking: Optional[RagRetrievalConfigRankingDict]
|
1216
|
+
"""Optional. Config for ranking and reranking."""
|
1217
|
+
|
1218
|
+
top_k: Optional[int]
|
1219
|
+
"""Optional. The number of contexts to retrieve."""
|
1220
|
+
|
1221
|
+
|
1222
|
+
RagRetrievalConfigOrDict = Union[RagRetrievalConfig, RagRetrievalConfigDict]
|
1223
|
+
|
1224
|
+
|
1225
|
+
class VertexRagStore(_common.BaseModel):
|
1226
|
+
"""Retrieve from Vertex RAG Store for grounding."""
|
1227
|
+
|
1228
|
+
rag_corpora: Optional[list[str]] = Field(
|
1052
1229
|
default=None,
|
1053
|
-
description="""Optional.
|
1054
|
-
)
|
1055
|
-
default: Optional[Any] = Field(
|
1056
|
-
default=None, description="""Optional. Default value of the data."""
|
1230
|
+
description="""Optional. Deprecated. Please use rag_resources instead.""",
|
1057
1231
|
)
|
1058
|
-
|
1232
|
+
rag_resources: Optional[list[VertexRagStoreRagResource]] = Field(
|
1059
1233
|
default=None,
|
1060
|
-
description="""Optional.
|
1234
|
+
description="""Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.""",
|
1061
1235
|
)
|
1062
|
-
|
1236
|
+
rag_retrieval_config: Optional[RagRetrievalConfig] = Field(
|
1063
1237
|
default=None,
|
1064
|
-
description="""Optional.
|
1238
|
+
description="""Optional. The retrieval config for the Rag query.""",
|
1065
1239
|
)
|
1066
|
-
|
1240
|
+
similarity_top_k: Optional[int] = Field(
|
1067
1241
|
default=None,
|
1068
|
-
description="""Optional.
|
1242
|
+
description="""Optional. Number of top k results to return from the selected corpora.""",
|
1069
1243
|
)
|
1070
|
-
|
1244
|
+
vector_distance_threshold: Optional[float] = Field(
|
1071
1245
|
default=None,
|
1072
|
-
description="""Optional.
|
1246
|
+
description="""Optional. Only return results with vector distance smaller than the threshold.""",
|
1073
1247
|
)
|
1074
|
-
|
1248
|
+
|
1249
|
+
|
1250
|
+
class VertexRagStoreDict(TypedDict, total=False):
|
1251
|
+
"""Retrieve from Vertex RAG Store for grounding."""
|
1252
|
+
|
1253
|
+
rag_corpora: Optional[list[str]]
|
1254
|
+
"""Optional. Deprecated. Please use rag_resources instead."""
|
1255
|
+
|
1256
|
+
rag_resources: Optional[list[VertexRagStoreRagResourceDict]]
|
1257
|
+
"""Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support."""
|
1258
|
+
|
1259
|
+
rag_retrieval_config: Optional[RagRetrievalConfigDict]
|
1260
|
+
"""Optional. The retrieval config for the Rag query."""
|
1261
|
+
|
1262
|
+
similarity_top_k: Optional[int]
|
1263
|
+
"""Optional. Number of top k results to return from the selected corpora."""
|
1264
|
+
|
1265
|
+
vector_distance_threshold: Optional[float]
|
1266
|
+
"""Optional. Only return results with vector distance smaller than the threshold."""
|
1267
|
+
|
1268
|
+
|
1269
|
+
VertexRagStoreOrDict = Union[VertexRagStore, VertexRagStoreDict]
|
1270
|
+
|
1271
|
+
|
1272
|
+
class Retrieval(_common.BaseModel):
|
1273
|
+
"""Defines a retrieval tool that model can call to access external knowledge."""
|
1274
|
+
|
1275
|
+
disable_attribution: Optional[bool] = Field(
|
1075
1276
|
default=None,
|
1076
|
-
description="""Optional.
|
1077
|
-
)
|
1078
|
-
description: Optional[str] = Field(
|
1079
|
-
default=None, description="""Optional. The description of the data."""
|
1277
|
+
description="""Optional. Deprecated. This option is no longer supported.""",
|
1080
1278
|
)
|
1081
|
-
|
1279
|
+
vertex_ai_search: Optional[VertexAISearch] = Field(
|
1082
1280
|
default=None,
|
1083
|
-
description="""
|
1281
|
+
description="""Set to use data source powered by Vertex AI Search.""",
|
1084
1282
|
)
|
1085
|
-
|
1283
|
+
vertex_rag_store: Optional[VertexRagStore] = Field(
|
1086
1284
|
default=None,
|
1087
|
-
description="""
|
1285
|
+
description="""Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService.""",
|
1088
1286
|
)
|
1089
|
-
|
1090
|
-
|
1287
|
+
|
1288
|
+
|
1289
|
+
class RetrievalDict(TypedDict, total=False):
|
1290
|
+
"""Defines a retrieval tool that model can call to access external knowledge."""
|
1291
|
+
|
1292
|
+
disable_attribution: Optional[bool]
|
1293
|
+
"""Optional. Deprecated. This option is no longer supported."""
|
1294
|
+
|
1295
|
+
vertex_ai_search: Optional[VertexAISearchDict]
|
1296
|
+
"""Set to use data source powered by Vertex AI Search."""
|
1297
|
+
|
1298
|
+
vertex_rag_store: Optional[VertexRagStoreDict]
|
1299
|
+
"""Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService."""
|
1300
|
+
|
1301
|
+
|
1302
|
+
RetrievalOrDict = Union[Retrieval, RetrievalDict]
|
1303
|
+
|
1304
|
+
|
1305
|
+
class ToolCodeExecution(_common.BaseModel):
|
1306
|
+
"""Tool that executes code generated by the model, and automatically returns the result to the model.
|
1307
|
+
|
1308
|
+
See also [ExecutableCode]and [CodeExecutionResult] which are input and output
|
1309
|
+
to this tool.
|
1310
|
+
"""
|
1311
|
+
|
1312
|
+
pass
|
1313
|
+
|
1314
|
+
|
1315
|
+
class ToolCodeExecutionDict(TypedDict, total=False):
|
1316
|
+
"""Tool that executes code generated by the model, and automatically returns the result to the model.
|
1317
|
+
|
1318
|
+
See also [ExecutableCode]and [CodeExecutionResult] which are input and output
|
1319
|
+
to this tool.
|
1320
|
+
"""
|
1321
|
+
|
1322
|
+
pass
|
1323
|
+
|
1324
|
+
|
1325
|
+
ToolCodeExecutionOrDict = Union[ToolCodeExecution, ToolCodeExecutionDict]
|
1326
|
+
|
1327
|
+
|
1328
|
+
class JSONSchemaType(Enum):
|
1329
|
+
"""The type of the data supported by JSON Schema.
|
1330
|
+
|
1331
|
+
The values of the enums are lower case strings, while the values of the enums
|
1332
|
+
for the Type class are upper case strings.
|
1333
|
+
"""
|
1334
|
+
|
1335
|
+
NULL = 'null'
|
1336
|
+
BOOLEAN = 'boolean'
|
1337
|
+
OBJECT = 'object'
|
1338
|
+
ARRAY = 'array'
|
1339
|
+
NUMBER = 'number'
|
1340
|
+
INTEGER = 'integer'
|
1341
|
+
STRING = 'string'
|
1342
|
+
|
1343
|
+
|
1344
|
+
class JSONSchema(pydantic.BaseModel):
|
1345
|
+
"""A subset of JSON Schema according to 2020-12 JSON Schema draft.
|
1346
|
+
|
1347
|
+
Represents a subset of a JSON Schema object that is used by the Gemini model.
|
1348
|
+
The difference between this class and the Schema class is that this class is
|
1349
|
+
compatible with OpenAPI 3.1 schema objects. And the Schema class is used to
|
1350
|
+
make API call to Gemini model.
|
1351
|
+
"""
|
1352
|
+
|
1353
|
+
type: Optional[Union[JSONSchemaType, list[JSONSchemaType]]] = Field(
|
1354
|
+
default=None,
|
1355
|
+
description="""Validation succeeds if the type of the instance matches the type represented by the given type, or matches at least one of the given types.""",
|
1356
|
+
)
|
1357
|
+
format: Optional[str] = Field(
|
1358
|
+
default=None,
|
1359
|
+
description='Define semantic information about a string instance.',
|
1360
|
+
)
|
1361
|
+
title: Optional[str] = Field(
|
1362
|
+
default=None,
|
1363
|
+
description=(
|
1364
|
+
'A preferably short description about the purpose of the instance'
|
1365
|
+
' described by the schema.'
|
1366
|
+
),
|
1367
|
+
)
|
1368
|
+
description: Optional[str] = Field(
|
1369
|
+
default=None,
|
1370
|
+
description=(
|
1371
|
+
'An explanation about the purpose of the instance described by the'
|
1372
|
+
' schema.'
|
1373
|
+
),
|
1374
|
+
)
|
1375
|
+
default: Optional[Any] = Field(
|
1376
|
+
default=None,
|
1377
|
+
description=(
|
1378
|
+
'This keyword can be used to supply a default JSON value associated'
|
1379
|
+
' with a particular schema.'
|
1380
|
+
),
|
1381
|
+
)
|
1382
|
+
items: Optional['JSONSchema'] = Field(
|
1383
|
+
default=None,
|
1384
|
+
description=(
|
1385
|
+
'Validation succeeds if each element of the instance not covered by'
|
1386
|
+
' prefixItems validates against this schema.'
|
1387
|
+
),
|
1388
|
+
)
|
1389
|
+
min_items: Optional[int] = Field(
|
1390
|
+
default=None,
|
1391
|
+
description=(
|
1392
|
+
'An array instance is valid if its size is greater than, or equal to,'
|
1393
|
+
' the value of this keyword.'
|
1394
|
+
),
|
1395
|
+
)
|
1396
|
+
max_items: Optional[int] = Field(
|
1397
|
+
default=None,
|
1398
|
+
description=(
|
1399
|
+
'An array instance is valid if its size is less than, or equal to,'
|
1400
|
+
' the value of this keyword.'
|
1401
|
+
),
|
1402
|
+
)
|
1403
|
+
enum: Optional[list[Any]] = Field(
|
1404
|
+
default=None,
|
1405
|
+
description=(
|
1406
|
+
'Validation succeeds if the instance is equal to one of the elements'
|
1407
|
+
' in this keyword’s array value.'
|
1408
|
+
),
|
1409
|
+
)
|
1410
|
+
properties: Optional[dict[str, 'JSONSchema']] = Field(
|
1411
|
+
default=None,
|
1412
|
+
description=(
|
1413
|
+
'Validation succeeds if, for each name that appears in both the'
|
1414
|
+
' instance and as a name within this keyword’s value, the child'
|
1415
|
+
' instance for that name successfully validates against the'
|
1416
|
+
' corresponding schema.'
|
1417
|
+
),
|
1418
|
+
)
|
1419
|
+
required: Optional[list[str]] = Field(
|
1420
|
+
default=None,
|
1421
|
+
description=(
|
1422
|
+
'An object instance is valid against this keyword if every item in'
|
1423
|
+
' the array is the name of a property in the instance.'
|
1424
|
+
),
|
1425
|
+
)
|
1426
|
+
min_properties: Optional[int] = Field(
|
1427
|
+
default=None,
|
1428
|
+
description=(
|
1429
|
+
'An object instance is valid if its number of properties is greater'
|
1430
|
+
' than, or equal to, the value of this keyword.'
|
1431
|
+
),
|
1432
|
+
)
|
1433
|
+
max_properties: Optional[int] = Field(
|
1434
|
+
default=None,
|
1435
|
+
description=(
|
1436
|
+
'An object instance is valid if its number of properties is less'
|
1437
|
+
' than, or equal to, the value of this keyword.'
|
1438
|
+
),
|
1439
|
+
)
|
1440
|
+
minimum: Optional[float] = Field(
|
1441
|
+
default=None,
|
1442
|
+
description=(
|
1443
|
+
'Validation succeeds if the numeric instance is greater than or equal'
|
1444
|
+
' to the given number.'
|
1445
|
+
),
|
1446
|
+
)
|
1447
|
+
maximum: Optional[float] = Field(
|
1448
|
+
default=None,
|
1449
|
+
description=(
|
1450
|
+
'Validation succeeds if the numeric instance is less than or equal to'
|
1451
|
+
' the given number.'
|
1452
|
+
),
|
1453
|
+
)
|
1454
|
+
min_length: Optional[int] = Field(
|
1455
|
+
default=None,
|
1456
|
+
description=(
|
1457
|
+
'A string instance is valid against this keyword if its length is'
|
1458
|
+
' greater than, or equal to, the value of this keyword.'
|
1459
|
+
),
|
1460
|
+
)
|
1461
|
+
max_length: Optional[int] = Field(
|
1462
|
+
default=None,
|
1463
|
+
description=(
|
1464
|
+
'A string instance is valid against this keyword if its length is'
|
1465
|
+
' less than, or equal to, the value of this keyword.'
|
1466
|
+
),
|
1467
|
+
)
|
1468
|
+
pattern: Optional[str] = Field(
|
1469
|
+
default=None,
|
1470
|
+
description=(
|
1471
|
+
'A string instance is considered valid if the regular expression'
|
1472
|
+
' matches the instance successfully.'
|
1473
|
+
),
|
1474
|
+
)
|
1475
|
+
any_of: Optional[list['JSONSchema']] = Field(
|
1476
|
+
default=None,
|
1477
|
+
description=(
|
1478
|
+
'An instance validates successfully against this keyword if it'
|
1479
|
+
' validates successfully against at least one schema defined by this'
|
1480
|
+
' keyword’s value.'
|
1481
|
+
),
|
1482
|
+
)
|
1483
|
+
|
1484
|
+
|
1485
|
+
class Schema(_common.BaseModel):
|
1486
|
+
"""Schema is used to define the format of input/output data.
|
1487
|
+
|
1488
|
+
Represents a select subset of an [OpenAPI 3.0 schema
|
1489
|
+
object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may
|
1490
|
+
be added in the future as needed.
|
1491
|
+
"""
|
1492
|
+
|
1493
|
+
any_of: Optional[list['Schema']] = Field(
|
1494
|
+
default=None,
|
1495
|
+
description="""Optional. The value should be validated against any (one or more) of the subschemas in the list.""",
|
1496
|
+
)
|
1497
|
+
default: Optional[Any] = Field(
|
1498
|
+
default=None, description="""Optional. Default value of the data."""
|
1499
|
+
)
|
1500
|
+
description: Optional[str] = Field(
|
1501
|
+
default=None, description="""Optional. The description of the data."""
|
1502
|
+
)
|
1503
|
+
enum: Optional[list[str]] = Field(
|
1504
|
+
default=None,
|
1505
|
+
description="""Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]}""",
|
1506
|
+
)
|
1507
|
+
example: Optional[Any] = Field(
|
1508
|
+
default=None,
|
1509
|
+
description="""Optional. Example of the object. Will only populated when the object is the root.""",
|
1510
|
+
)
|
1511
|
+
format: Optional[str] = Field(
|
1512
|
+
default=None,
|
1513
|
+
description="""Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc""",
|
1514
|
+
)
|
1515
|
+
items: Optional['Schema'] = Field(
|
1516
|
+
default=None,
|
1091
1517
|
description="""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY.""",
|
1092
1518
|
)
|
1093
1519
|
max_items: Optional[int] = Field(
|
1094
1520
|
default=None,
|
1095
1521
|
description="""Optional. Maximum number of the elements for Type.ARRAY.""",
|
1096
1522
|
)
|
1523
|
+
max_length: Optional[int] = Field(
|
1524
|
+
default=None,
|
1525
|
+
description="""Optional. Maximum length of the Type.STRING""",
|
1526
|
+
)
|
1527
|
+
max_properties: Optional[int] = Field(
|
1528
|
+
default=None,
|
1529
|
+
description="""Optional. Maximum number of the properties for Type.OBJECT.""",
|
1530
|
+
)
|
1097
1531
|
maximum: Optional[float] = Field(
|
1098
1532
|
default=None,
|
1099
1533
|
description="""Optional. Maximum value of the Type.INTEGER and Type.NUMBER""",
|
@@ -1102,6 +1536,14 @@ class Schema(_common.BaseModel):
|
|
1102
1536
|
default=None,
|
1103
1537
|
description="""Optional. Minimum number of the elements for Type.ARRAY.""",
|
1104
1538
|
)
|
1539
|
+
min_length: Optional[int] = Field(
|
1540
|
+
default=None,
|
1541
|
+
description="""Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING""",
|
1542
|
+
)
|
1543
|
+
min_properties: Optional[int] = Field(
|
1544
|
+
default=None,
|
1545
|
+
description="""Optional. Minimum number of the properties for Type.OBJECT.""",
|
1546
|
+
)
|
1105
1547
|
minimum: Optional[float] = Field(
|
1106
1548
|
default=None,
|
1107
1549
|
description="""Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER""",
|
@@ -1110,6 +1552,10 @@ class Schema(_common.BaseModel):
|
|
1110
1552
|
default=None,
|
1111
1553
|
description="""Optional. Indicates if the value may be null.""",
|
1112
1554
|
)
|
1555
|
+
pattern: Optional[str] = Field(
|
1556
|
+
default=None,
|
1557
|
+
description="""Optional. Pattern of the Type.STRING to restrict a string to a regular expression.""",
|
1558
|
+
)
|
1113
1559
|
properties: Optional[dict[str, 'Schema']] = Field(
|
1114
1560
|
default=None,
|
1115
1561
|
description="""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT.""",
|
@@ -1229,43 +1675,50 @@ class Schema(_common.BaseModel):
|
|
1229
1675
|
)
|
1230
1676
|
dict_schema_field_names: tuple[str, ...] = ('properties',) # 'defs' to come
|
1231
1677
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1678
|
+
related_field_names_by_type: dict[str, tuple[str, ...]] = {
|
1679
|
+
JSONSchemaType.NUMBER.value: (
|
1680
|
+
'description',
|
1681
|
+
'enum',
|
1682
|
+
'format',
|
1683
|
+
'maximum',
|
1684
|
+
'minimum',
|
1685
|
+
'title',
|
1686
|
+
),
|
1687
|
+
JSONSchemaType.STRING.value: (
|
1688
|
+
'description',
|
1689
|
+
'enum',
|
1690
|
+
'format',
|
1691
|
+
'max_length',
|
1692
|
+
'min_length',
|
1693
|
+
'pattern',
|
1694
|
+
'title',
|
1695
|
+
),
|
1696
|
+
JSONSchemaType.OBJECT.value: (
|
1697
|
+
'any_of',
|
1698
|
+
'description',
|
1699
|
+
'max_properties',
|
1700
|
+
'min_properties',
|
1701
|
+
'properties',
|
1702
|
+
'required',
|
1703
|
+
'title',
|
1704
|
+
),
|
1705
|
+
JSONSchemaType.ARRAY.value: (
|
1706
|
+
'description',
|
1707
|
+
'items',
|
1708
|
+
'max_items',
|
1709
|
+
'min_items',
|
1710
|
+
'title',
|
1711
|
+
),
|
1712
|
+
JSONSchemaType.BOOLEAN.value: (
|
1713
|
+
'description',
|
1714
|
+
'title',
|
1715
|
+
),
|
1716
|
+
}
|
1717
|
+
# Treat `INTEGER` like `NUMBER`.
|
1718
|
+
related_field_names_by_type[JSONSchemaType.INTEGER.value] = (
|
1719
|
+
related_field_names_by_type[JSONSchemaType.NUMBER.value]
|
1268
1720
|
)
|
1721
|
+
|
1269
1722
|
# placeholder for potential gemini api unsupported fields
|
1270
1723
|
gemini_api_unsupported_field_names: tuple[str, ...] = ()
|
1271
1724
|
|
@@ -1277,14 +1730,8 @@ class Schema(_common.BaseModel):
|
|
1277
1730
|
"""Returns (non_null_types, nullable)"""
|
1278
1731
|
if json_schema_type is None:
|
1279
1732
|
return [], False
|
1280
|
-
if isinstance(json_schema_type,
|
1281
|
-
|
1282
|
-
return [], True
|
1283
|
-
return [json_schema_type], False
|
1284
|
-
if isinstance(json_schema_type, JSONSchemaType):
|
1285
|
-
if json_schema_type == JSONSchemaType.NULL:
|
1286
|
-
return [], True
|
1287
|
-
return [json_schema_type.value], False
|
1733
|
+
if not isinstance(json_schema_type, Sequence):
|
1734
|
+
json_schema_type = [json_schema_type]
|
1288
1735
|
non_null_types = []
|
1289
1736
|
nullable = False
|
1290
1737
|
for type_value in json_schema_type:
|
@@ -1383,37 +1830,11 @@ class Schema(_common.BaseModel):
|
|
1383
1830
|
schema.nullable = True
|
1384
1831
|
for normalized_type in non_null_types:
|
1385
1832
|
sub_schema_in_any_of = {'type': normalized_type}
|
1386
|
-
|
1387
|
-
|
1388
|
-
json_schema_dict=json_schema_dict,
|
1389
|
-
related_fields_to_copy=boolean_related_field_names,
|
1390
|
-
sub_schema_in_any_of=sub_schema_in_any_of,
|
1391
|
-
)
|
1392
|
-
elif normalized_type in (
|
1393
|
-
JSONSchemaType.NUMBER.value,
|
1394
|
-
JSONSchemaType.INTEGER.value,
|
1395
|
-
):
|
1833
|
+
related_field_names = related_field_names_by_type.get(normalized_type)
|
1834
|
+
if related_field_names is not None:
|
1396
1835
|
copy_schema_fields(
|
1397
1836
|
json_schema_dict=json_schema_dict,
|
1398
|
-
related_fields_to_copy=
|
1399
|
-
sub_schema_in_any_of=sub_schema_in_any_of,
|
1400
|
-
)
|
1401
|
-
elif normalized_type == JSONSchemaType.STRING.value:
|
1402
|
-
copy_schema_fields(
|
1403
|
-
json_schema_dict=json_schema_dict,
|
1404
|
-
related_fields_to_copy=string_related_field_names,
|
1405
|
-
sub_schema_in_any_of=sub_schema_in_any_of,
|
1406
|
-
)
|
1407
|
-
elif normalized_type == JSONSchemaType.ARRAY.value:
|
1408
|
-
copy_schema_fields(
|
1409
|
-
json_schema_dict=json_schema_dict,
|
1410
|
-
related_fields_to_copy=array_related_field_names,
|
1411
|
-
sub_schema_in_any_of=sub_schema_in_any_of,
|
1412
|
-
)
|
1413
|
-
elif normalized_type == JSONSchemaType.OBJECT.value:
|
1414
|
-
copy_schema_fields(
|
1415
|
-
json_schema_dict=json_schema_dict,
|
1416
|
-
related_fields_to_copy=object_related_field_names,
|
1837
|
+
related_fields_to_copy=related_field_names,
|
1417
1838
|
sub_schema_in_any_of=sub_schema_in_any_of,
|
1418
1839
|
)
|
1419
1840
|
any_of.append(JSONSchema(**sub_schema_in_any_of))
|
@@ -1473,665 +1894,219 @@ class Schema(_common.BaseModel):
|
|
1473
1894
|
|
1474
1895
|
|
1475
1896
|
class SchemaDict(TypedDict, total=False):
|
1476
|
-
"""Schema
|
1897
|
+
"""Schema is used to define the format of input/output data.
|
1477
1898
|
|
1478
|
-
Represents a select subset of an OpenAPI 3.0 schema
|
1899
|
+
Represents a select subset of an [OpenAPI 3.0 schema
|
1900
|
+
object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may
|
1901
|
+
be added in the future as needed.
|
1479
1902
|
"""
|
1480
1903
|
|
1481
|
-
example: Optional[Any]
|
1482
|
-
"""Optional. Example of the object. Will only populated when the object is the root."""
|
1483
|
-
|
1484
|
-
pattern: Optional[str]
|
1485
|
-
"""Optional. Pattern of the Type.STRING to restrict a string to a regular expression."""
|
1486
|
-
|
1487
|
-
default: Optional[Any]
|
1488
|
-
"""Optional. Default value of the data."""
|
1489
|
-
|
1490
|
-
max_length: Optional[int]
|
1491
|
-
"""Optional. Maximum length of the Type.STRING"""
|
1492
|
-
|
1493
|
-
min_length: Optional[int]
|
1494
|
-
"""Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING"""
|
1495
|
-
|
1496
|
-
min_properties: Optional[int]
|
1497
|
-
"""Optional. Minimum number of the properties for Type.OBJECT."""
|
1498
|
-
|
1499
|
-
max_properties: Optional[int]
|
1500
|
-
"""Optional. Maximum number of the properties for Type.OBJECT."""
|
1501
|
-
|
1502
1904
|
any_of: Optional[list['SchemaDict']]
|
1503
|
-
"""Optional. The value should be validated against any (one or more) of the subschemas in the list."""
|
1504
|
-
|
1505
|
-
description: Optional[str]
|
1506
|
-
"""Optional. The description of the data."""
|
1507
|
-
|
1508
|
-
enum: Optional[list[str]]
|
1509
|
-
"""Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]}"""
|
1510
|
-
|
1511
|
-
format: Optional[str]
|
1512
|
-
"""Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc"""
|
1513
|
-
|
1514
|
-
items: Optional['SchemaDict']
|
1515
|
-
"""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY."""
|
1516
|
-
|
1517
|
-
max_items: Optional[int]
|
1518
|
-
"""Optional. Maximum number of the elements for Type.ARRAY."""
|
1519
|
-
|
1520
|
-
maximum: Optional[float]
|
1521
|
-
"""Optional. Maximum value of the Type.INTEGER and Type.NUMBER"""
|
1522
|
-
|
1523
|
-
min_items: Optional[int]
|
1524
|
-
"""Optional. Minimum number of the elements for Type.ARRAY."""
|
1525
|
-
|
1526
|
-
minimum: Optional[float]
|
1527
|
-
"""Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER"""
|
1528
|
-
|
1529
|
-
nullable: Optional[bool]
|
1530
|
-
"""Optional. Indicates if the value may be null."""
|
1531
|
-
|
1532
|
-
properties: Optional[dict[str, 'SchemaDict']]
|
1533
|
-
"""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT."""
|
1534
|
-
|
1535
|
-
property_ordering: Optional[list[str]]
|
1536
|
-
"""Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties."""
|
1537
|
-
|
1538
|
-
required: Optional[list[str]]
|
1539
|
-
"""Optional. Required properties of Type.OBJECT."""
|
1540
|
-
|
1541
|
-
title: Optional[str]
|
1542
|
-
"""Optional. The title of the Schema."""
|
1543
|
-
|
1544
|
-
type: Optional[Type]
|
1545
|
-
"""Optional. The type of the data."""
|
1546
|
-
|
1547
|
-
|
1548
|
-
SchemaOrDict = Union[Schema, SchemaDict]
|
1549
|
-
|
1550
|
-
|
1551
|
-
class ModelSelectionConfig(_common.BaseModel):
|
1552
|
-
"""Config for model selection."""
|
1553
|
-
|
1554
|
-
feature_selection_preference: Optional[FeatureSelectionPreference] = Field(
|
1555
|
-
default=None, description="""Options for feature selection preference."""
|
1556
|
-
)
|
1557
|
-
|
1558
|
-
|
1559
|
-
class ModelSelectionConfigDict(TypedDict, total=False):
|
1560
|
-
"""Config for model selection."""
|
1561
|
-
|
1562
|
-
feature_selection_preference: Optional[FeatureSelectionPreference]
|
1563
|
-
"""Options for feature selection preference."""
|
1564
|
-
|
1565
|
-
|
1566
|
-
ModelSelectionConfigOrDict = Union[
|
1567
|
-
ModelSelectionConfig, ModelSelectionConfigDict
|
1568
|
-
]
|
1569
|
-
|
1570
|
-
|
1571
|
-
class SafetySetting(_common.BaseModel):
|
1572
|
-
"""Safety settings."""
|
1573
|
-
|
1574
|
-
method: Optional[HarmBlockMethod] = Field(
|
1575
|
-
default=None,
|
1576
|
-
description="""Determines if the harm block method uses probability or probability
|
1577
|
-
and severity scores.""",
|
1578
|
-
)
|
1579
|
-
category: Optional[HarmCategory] = Field(
|
1580
|
-
default=None, description="""Required. Harm category."""
|
1581
|
-
)
|
1582
|
-
threshold: Optional[HarmBlockThreshold] = Field(
|
1583
|
-
default=None, description="""Required. The harm block threshold."""
|
1584
|
-
)
|
1585
|
-
|
1586
|
-
|
1587
|
-
class SafetySettingDict(TypedDict, total=False):
|
1588
|
-
"""Safety settings."""
|
1589
|
-
|
1590
|
-
method: Optional[HarmBlockMethod]
|
1591
|
-
"""Determines if the harm block method uses probability or probability
|
1592
|
-
and severity scores."""
|
1593
|
-
|
1594
|
-
category: Optional[HarmCategory]
|
1595
|
-
"""Required. Harm category."""
|
1596
|
-
|
1597
|
-
threshold: Optional[HarmBlockThreshold]
|
1598
|
-
"""Required. The harm block threshold."""
|
1599
|
-
|
1600
|
-
|
1601
|
-
SafetySettingOrDict = Union[SafetySetting, SafetySettingDict]
|
1602
|
-
|
1603
|
-
|
1604
|
-
class FunctionDeclaration(_common.BaseModel):
|
1605
|
-
"""Defines a function that the model can generate JSON inputs for.
|
1606
|
-
|
1607
|
-
The inputs are based on `OpenAPI 3.0 specifications
|
1608
|
-
<https://spec.openapis.org/oas/v3.0.3>`_.
|
1609
|
-
"""
|
1610
|
-
|
1611
|
-
response: Optional[Schema] = Field(
|
1612
|
-
default=None,
|
1613
|
-
description="""Describes the output from the function in the OpenAPI JSON Schema
|
1614
|
-
Object format.""",
|
1615
|
-
)
|
1616
|
-
description: Optional[str] = Field(
|
1617
|
-
default=None,
|
1618
|
-
description="""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""",
|
1619
|
-
)
|
1620
|
-
name: Optional[str] = Field(
|
1621
|
-
default=None,
|
1622
|
-
description="""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64.""",
|
1623
|
-
)
|
1624
|
-
parameters: Optional[Schema] = Field(
|
1625
|
-
default=None,
|
1626
|
-
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""",
|
1627
|
-
)
|
1628
|
-
|
1629
|
-
@classmethod
|
1630
|
-
def from_callable_with_api_option(
|
1631
|
-
cls,
|
1632
|
-
*,
|
1633
|
-
callable: Callable[..., Any],
|
1634
|
-
api_option: Literal['VERTEX_AI', 'GEMINI_API'] = 'GEMINI_API',
|
1635
|
-
) -> 'FunctionDeclaration':
|
1636
|
-
"""Converts a Callable to a FunctionDeclaration based on the API option.
|
1637
|
-
|
1638
|
-
Supported API option is 'VERTEX_AI' or 'GEMINI_API'. If api_option is unset,
|
1639
|
-
it will default to 'GEMINI_API'. If unsupported api_option is provided, it
|
1640
|
-
will raise ValueError.
|
1641
|
-
"""
|
1642
|
-
supported_api_options = ['VERTEX_AI', 'GEMINI_API']
|
1643
|
-
if api_option not in supported_api_options:
|
1644
|
-
raise ValueError(
|
1645
|
-
f'Unsupported api_option value: {api_option}. Supported api_option'
|
1646
|
-
f' value is one of: {supported_api_options}.'
|
1647
|
-
)
|
1648
|
-
from . import _automatic_function_calling_util
|
1649
|
-
|
1650
|
-
parameters_properties = {}
|
1651
|
-
for name, param in inspect.signature(callable).parameters.items():
|
1652
|
-
if param.kind in (
|
1653
|
-
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
1654
|
-
inspect.Parameter.KEYWORD_ONLY,
|
1655
|
-
inspect.Parameter.POSITIONAL_ONLY,
|
1656
|
-
):
|
1657
|
-
schema = _automatic_function_calling_util._parse_schema_from_parameter(
|
1658
|
-
api_option, param, callable.__name__
|
1659
|
-
)
|
1660
|
-
parameters_properties[name] = schema
|
1661
|
-
declaration = FunctionDeclaration(
|
1662
|
-
name=callable.__name__,
|
1663
|
-
description=callable.__doc__,
|
1664
|
-
)
|
1665
|
-
if parameters_properties:
|
1666
|
-
declaration.parameters = Schema(
|
1667
|
-
type='OBJECT',
|
1668
|
-
properties=parameters_properties,
|
1669
|
-
)
|
1670
|
-
declaration.parameters.required = (
|
1671
|
-
_automatic_function_calling_util._get_required_fields(
|
1672
|
-
declaration.parameters
|
1673
|
-
)
|
1674
|
-
)
|
1675
|
-
if api_option == 'GEMINI_API':
|
1676
|
-
return declaration
|
1677
|
-
|
1678
|
-
return_annotation = inspect.signature(callable).return_annotation
|
1679
|
-
if return_annotation is inspect._empty:
|
1680
|
-
return declaration
|
1681
|
-
|
1682
|
-
declaration.response = (
|
1683
|
-
_automatic_function_calling_util._parse_schema_from_parameter(
|
1684
|
-
api_option,
|
1685
|
-
inspect.Parameter(
|
1686
|
-
'return_value',
|
1687
|
-
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
1688
|
-
annotation=return_annotation,
|
1689
|
-
),
|
1690
|
-
callable.__name__,
|
1691
|
-
)
|
1692
|
-
)
|
1693
|
-
return declaration
|
1694
|
-
|
1695
|
-
@classmethod
|
1696
|
-
def from_callable(
|
1697
|
-
cls,
|
1698
|
-
*,
|
1699
|
-
client: 'BaseApiClient',
|
1700
|
-
callable: Callable[..., Any],
|
1701
|
-
) -> 'FunctionDeclaration':
|
1702
|
-
"""Converts a Callable to a FunctionDeclaration based on the client."""
|
1703
|
-
if client.vertexai:
|
1704
|
-
return cls.from_callable_with_api_option(
|
1705
|
-
callable=callable, api_option='VERTEX_AI'
|
1706
|
-
)
|
1707
|
-
else:
|
1708
|
-
return cls.from_callable_with_api_option(
|
1709
|
-
callable=callable, api_option='GEMINI_API'
|
1710
|
-
)
|
1711
|
-
|
1712
|
-
|
1713
|
-
class FunctionDeclarationDict(TypedDict, total=False):
|
1714
|
-
"""Defines a function that the model can generate JSON inputs for.
|
1715
|
-
|
1716
|
-
The inputs are based on `OpenAPI 3.0 specifications
|
1717
|
-
<https://spec.openapis.org/oas/v3.0.3>`_.
|
1718
|
-
"""
|
1719
|
-
|
1720
|
-
response: Optional[SchemaDict]
|
1721
|
-
"""Describes the output from the function in the OpenAPI JSON Schema
|
1722
|
-
Object format."""
|
1723
|
-
|
1724
|
-
description: Optional[str]
|
1725
|
-
"""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function."""
|
1726
|
-
|
1727
|
-
name: Optional[str]
|
1728
|
-
"""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64."""
|
1729
|
-
|
1730
|
-
parameters: Optional[SchemaDict]
|
1731
|
-
"""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"""
|
1732
|
-
|
1733
|
-
|
1734
|
-
FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]
|
1735
|
-
|
1736
|
-
|
1737
|
-
class GoogleSearch(_common.BaseModel):
|
1738
|
-
"""Tool to support Google Search in Model. Powered by Google."""
|
1739
|
-
|
1740
|
-
pass
|
1741
|
-
|
1742
|
-
|
1743
|
-
class GoogleSearchDict(TypedDict, total=False):
|
1744
|
-
"""Tool to support Google Search in Model. Powered by Google."""
|
1745
|
-
|
1746
|
-
pass
|
1747
|
-
|
1748
|
-
|
1749
|
-
GoogleSearchOrDict = Union[GoogleSearch, GoogleSearchDict]
|
1750
|
-
|
1751
|
-
|
1752
|
-
class DynamicRetrievalConfig(_common.BaseModel):
|
1753
|
-
"""Describes the options to customize dynamic retrieval."""
|
1754
|
-
|
1755
|
-
mode: Optional[DynamicRetrievalConfigMode] = Field(
|
1756
|
-
default=None,
|
1757
|
-
description="""The mode of the predictor to be used in dynamic retrieval.""",
|
1758
|
-
)
|
1759
|
-
dynamic_threshold: Optional[float] = Field(
|
1760
|
-
default=None,
|
1761
|
-
description="""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.""",
|
1762
|
-
)
|
1763
|
-
|
1764
|
-
|
1765
|
-
class DynamicRetrievalConfigDict(TypedDict, total=False):
|
1766
|
-
"""Describes the options to customize dynamic retrieval."""
|
1767
|
-
|
1768
|
-
mode: Optional[DynamicRetrievalConfigMode]
|
1769
|
-
"""The mode of the predictor to be used in dynamic retrieval."""
|
1770
|
-
|
1771
|
-
dynamic_threshold: Optional[float]
|
1772
|
-
"""Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used."""
|
1773
|
-
|
1774
|
-
|
1775
|
-
DynamicRetrievalConfigOrDict = Union[
|
1776
|
-
DynamicRetrievalConfig, DynamicRetrievalConfigDict
|
1777
|
-
]
|
1778
|
-
|
1779
|
-
|
1780
|
-
class GoogleSearchRetrieval(_common.BaseModel):
|
1781
|
-
"""Tool to retrieve public web data for grounding, powered by Google."""
|
1782
|
-
|
1783
|
-
dynamic_retrieval_config: Optional[DynamicRetrievalConfig] = Field(
|
1784
|
-
default=None,
|
1785
|
-
description="""Specifies the dynamic retrieval configuration for the given source.""",
|
1786
|
-
)
|
1787
|
-
|
1788
|
-
|
1789
|
-
class GoogleSearchRetrievalDict(TypedDict, total=False):
|
1790
|
-
"""Tool to retrieve public web data for grounding, powered by Google."""
|
1791
|
-
|
1792
|
-
dynamic_retrieval_config: Optional[DynamicRetrievalConfigDict]
|
1793
|
-
"""Specifies the dynamic retrieval configuration for the given source."""
|
1794
|
-
|
1795
|
-
|
1796
|
-
GoogleSearchRetrievalOrDict = Union[
|
1797
|
-
GoogleSearchRetrieval, GoogleSearchRetrievalDict
|
1798
|
-
]
|
1799
|
-
|
1800
|
-
|
1801
|
-
class VertexAISearch(_common.BaseModel):
|
1802
|
-
"""Retrieve from Vertex AI Search datastore or engine for grounding.
|
1803
|
-
|
1804
|
-
datastore and engine are mutually exclusive. See
|
1805
|
-
https://cloud.google.com/products/agent-builder
|
1806
|
-
"""
|
1807
|
-
|
1808
|
-
datastore: Optional[str] = Field(
|
1809
|
-
default=None,
|
1810
|
-
description="""Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`""",
|
1811
|
-
)
|
1812
|
-
engine: Optional[str] = Field(
|
1813
|
-
default=None,
|
1814
|
-
description="""Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`""",
|
1815
|
-
)
|
1816
|
-
|
1817
|
-
|
1818
|
-
class VertexAISearchDict(TypedDict, total=False):
|
1819
|
-
"""Retrieve from Vertex AI Search datastore or engine for grounding.
|
1820
|
-
|
1821
|
-
datastore and engine are mutually exclusive. See
|
1822
|
-
https://cloud.google.com/products/agent-builder
|
1823
|
-
"""
|
1824
|
-
|
1825
|
-
datastore: Optional[str]
|
1826
|
-
"""Optional. Fully-qualified Vertex AI Search data store resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{dataStore}`"""
|
1827
|
-
|
1828
|
-
engine: Optional[str]
|
1829
|
-
"""Optional. Fully-qualified Vertex AI Search engine resource ID. Format: `projects/{project}/locations/{location}/collections/{collection}/engines/{engine}`"""
|
1830
|
-
|
1831
|
-
|
1832
|
-
VertexAISearchOrDict = Union[VertexAISearch, VertexAISearchDict]
|
1833
|
-
|
1834
|
-
|
1835
|
-
class VertexRagStoreRagResource(_common.BaseModel):
|
1836
|
-
"""The definition of the Rag resource."""
|
1837
|
-
|
1838
|
-
rag_corpus: Optional[str] = Field(
|
1839
|
-
default=None,
|
1840
|
-
description="""Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`""",
|
1841
|
-
)
|
1842
|
-
rag_file_ids: Optional[list[str]] = Field(
|
1843
|
-
default=None,
|
1844
|
-
description="""Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field.""",
|
1845
|
-
)
|
1846
|
-
|
1847
|
-
|
1848
|
-
class VertexRagStoreRagResourceDict(TypedDict, total=False):
|
1849
|
-
"""The definition of the Rag resource."""
|
1850
|
-
|
1851
|
-
rag_corpus: Optional[str]
|
1852
|
-
"""Optional. RagCorpora resource name. Format: `projects/{project}/locations/{location}/ragCorpora/{rag_corpus}`"""
|
1853
|
-
|
1854
|
-
rag_file_ids: Optional[list[str]]
|
1855
|
-
"""Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field."""
|
1856
|
-
|
1857
|
-
|
1858
|
-
VertexRagStoreRagResourceOrDict = Union[
|
1859
|
-
VertexRagStoreRagResource, VertexRagStoreRagResourceDict
|
1860
|
-
]
|
1861
|
-
|
1862
|
-
|
1863
|
-
class RagRetrievalConfigFilter(_common.BaseModel):
|
1864
|
-
"""Config for filters."""
|
1865
|
-
|
1866
|
-
metadata_filter: Optional[str] = Field(
|
1867
|
-
default=None, description="""Optional. String for metadata filtering."""
|
1868
|
-
)
|
1869
|
-
vector_distance_threshold: Optional[float] = Field(
|
1870
|
-
default=None,
|
1871
|
-
description="""Optional. Only returns contexts with vector distance smaller than the threshold.""",
|
1872
|
-
)
|
1873
|
-
vector_similarity_threshold: Optional[float] = Field(
|
1874
|
-
default=None,
|
1875
|
-
description="""Optional. Only returns contexts with vector similarity larger than the threshold.""",
|
1876
|
-
)
|
1877
|
-
|
1878
|
-
|
1879
|
-
class RagRetrievalConfigFilterDict(TypedDict, total=False):
|
1880
|
-
"""Config for filters."""
|
1881
|
-
|
1882
|
-
metadata_filter: Optional[str]
|
1883
|
-
"""Optional. String for metadata filtering."""
|
1884
|
-
|
1885
|
-
vector_distance_threshold: Optional[float]
|
1886
|
-
"""Optional. Only returns contexts with vector distance smaller than the threshold."""
|
1887
|
-
|
1888
|
-
vector_similarity_threshold: Optional[float]
|
1889
|
-
"""Optional. Only returns contexts with vector similarity larger than the threshold."""
|
1890
|
-
|
1891
|
-
|
1892
|
-
RagRetrievalConfigFilterOrDict = Union[
|
1893
|
-
RagRetrievalConfigFilter, RagRetrievalConfigFilterDict
|
1894
|
-
]
|
1895
|
-
|
1896
|
-
|
1897
|
-
class RagRetrievalConfigHybridSearch(_common.BaseModel):
|
1898
|
-
"""Config for Hybrid Search."""
|
1899
|
-
|
1900
|
-
alpha: Optional[float] = Field(
|
1901
|
-
default=None,
|
1902
|
-
description="""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally.""",
|
1903
|
-
)
|
1904
|
-
|
1905
|
-
|
1906
|
-
class RagRetrievalConfigHybridSearchDict(TypedDict, total=False):
|
1907
|
-
"""Config for Hybrid Search."""
|
1908
|
-
|
1909
|
-
alpha: Optional[float]
|
1910
|
-
"""Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally."""
|
1911
|
-
|
1912
|
-
|
1913
|
-
RagRetrievalConfigHybridSearchOrDict = Union[
|
1914
|
-
RagRetrievalConfigHybridSearch, RagRetrievalConfigHybridSearchDict
|
1915
|
-
]
|
1916
|
-
|
1917
|
-
|
1918
|
-
class RagRetrievalConfigRankingLlmRanker(_common.BaseModel):
|
1919
|
-
"""Config for LlmRanker."""
|
1920
|
-
|
1921
|
-
model_name: Optional[str] = Field(
|
1922
|
-
default=None,
|
1923
|
-
description="""Optional. The model name used for ranking. Format: `gemini-1.5-pro`""",
|
1924
|
-
)
|
1925
|
-
|
1926
|
-
|
1927
|
-
class RagRetrievalConfigRankingLlmRankerDict(TypedDict, total=False):
|
1928
|
-
"""Config for LlmRanker."""
|
1929
|
-
|
1930
|
-
model_name: Optional[str]
|
1931
|
-
"""Optional. The model name used for ranking. Format: `gemini-1.5-pro`"""
|
1932
|
-
|
1933
|
-
|
1934
|
-
RagRetrievalConfigRankingLlmRankerOrDict = Union[
|
1935
|
-
RagRetrievalConfigRankingLlmRanker, RagRetrievalConfigRankingLlmRankerDict
|
1936
|
-
]
|
1937
|
-
|
1938
|
-
|
1939
|
-
class RagRetrievalConfigRankingRankService(_common.BaseModel):
|
1940
|
-
"""Config for Rank Service."""
|
1941
|
-
|
1942
|
-
model_name: Optional[str] = Field(
|
1943
|
-
default=None,
|
1944
|
-
description="""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`""",
|
1945
|
-
)
|
1946
|
-
|
1947
|
-
|
1948
|
-
class RagRetrievalConfigRankingRankServiceDict(TypedDict, total=False):
|
1949
|
-
"""Config for Rank Service."""
|
1950
|
-
|
1951
|
-
model_name: Optional[str]
|
1952
|
-
"""Optional. The model name of the rank service. Format: `semantic-ranker-512@latest`"""
|
1953
|
-
|
1954
|
-
|
1955
|
-
RagRetrievalConfigRankingRankServiceOrDict = Union[
|
1956
|
-
RagRetrievalConfigRankingRankService,
|
1957
|
-
RagRetrievalConfigRankingRankServiceDict,
|
1958
|
-
]
|
1959
|
-
|
1960
|
-
|
1961
|
-
class RagRetrievalConfigRanking(_common.BaseModel):
|
1962
|
-
"""Config for ranking and reranking."""
|
1963
|
-
|
1964
|
-
llm_ranker: Optional[RagRetrievalConfigRankingLlmRanker] = Field(
|
1965
|
-
default=None, description="""Optional. Config for LlmRanker."""
|
1966
|
-
)
|
1967
|
-
rank_service: Optional[RagRetrievalConfigRankingRankService] = Field(
|
1968
|
-
default=None, description="""Optional. Config for Rank Service."""
|
1969
|
-
)
|
1970
|
-
|
1971
|
-
|
1972
|
-
class RagRetrievalConfigRankingDict(TypedDict, total=False):
|
1973
|
-
"""Config for ranking and reranking."""
|
1974
|
-
|
1975
|
-
llm_ranker: Optional[RagRetrievalConfigRankingLlmRankerDict]
|
1976
|
-
"""Optional. Config for LlmRanker."""
|
1977
|
-
|
1978
|
-
rank_service: Optional[RagRetrievalConfigRankingRankServiceDict]
|
1979
|
-
"""Optional. Config for Rank Service."""
|
1980
|
-
|
1905
|
+
"""Optional. The value should be validated against any (one or more) of the subschemas in the list."""
|
1981
1906
|
|
1982
|
-
|
1983
|
-
|
1984
|
-
]
|
1907
|
+
default: Optional[Any]
|
1908
|
+
"""Optional. Default value of the data."""
|
1985
1909
|
|
1910
|
+
description: Optional[str]
|
1911
|
+
"""Optional. The description of the data."""
|
1986
1912
|
|
1987
|
-
|
1988
|
-
"""
|
1913
|
+
enum: Optional[list[str]]
|
1914
|
+
"""Optional. Possible values of the element of primitive type with enum format. Examples: 1. We can define direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} 2. We can define apartment number as : {type:INTEGER, format:enum, enum:["101", "201", "301"]}"""
|
1989
1915
|
|
1990
|
-
|
1991
|
-
|
1992
|
-
)
|
1993
|
-
hybrid_search: Optional[RagRetrievalConfigHybridSearch] = Field(
|
1994
|
-
default=None, description="""Optional. Config for Hybrid Search."""
|
1995
|
-
)
|
1996
|
-
ranking: Optional[RagRetrievalConfigRanking] = Field(
|
1997
|
-
default=None,
|
1998
|
-
description="""Optional. Config for ranking and reranking.""",
|
1999
|
-
)
|
2000
|
-
top_k: Optional[int] = Field(
|
2001
|
-
default=None,
|
2002
|
-
description="""Optional. The number of contexts to retrieve.""",
|
2003
|
-
)
|
1916
|
+
example: Optional[Any]
|
1917
|
+
"""Optional. Example of the object. Will only populated when the object is the root."""
|
2004
1918
|
|
1919
|
+
format: Optional[str]
|
1920
|
+
"""Optional. The format of the data. Supported formats: for NUMBER type: "float", "double" for INTEGER type: "int32", "int64" for STRING type: "email", "byte", etc"""
|
2005
1921
|
|
2006
|
-
|
2007
|
-
"""
|
1922
|
+
items: Optional['SchemaDict']
|
1923
|
+
"""Optional. SCHEMA FIELDS FOR TYPE ARRAY Schema of the elements of Type.ARRAY."""
|
2008
1924
|
|
2009
|
-
|
2010
|
-
"""Optional.
|
1925
|
+
max_items: Optional[int]
|
1926
|
+
"""Optional. Maximum number of the elements for Type.ARRAY."""
|
2011
1927
|
|
2012
|
-
|
2013
|
-
"""Optional.
|
1928
|
+
max_length: Optional[int]
|
1929
|
+
"""Optional. Maximum length of the Type.STRING"""
|
2014
1930
|
|
2015
|
-
|
2016
|
-
"""Optional.
|
1931
|
+
max_properties: Optional[int]
|
1932
|
+
"""Optional. Maximum number of the properties for Type.OBJECT."""
|
2017
1933
|
|
2018
|
-
|
2019
|
-
"""Optional.
|
1934
|
+
maximum: Optional[float]
|
1935
|
+
"""Optional. Maximum value of the Type.INTEGER and Type.NUMBER"""
|
2020
1936
|
|
1937
|
+
min_items: Optional[int]
|
1938
|
+
"""Optional. Minimum number of the elements for Type.ARRAY."""
|
2021
1939
|
|
2022
|
-
|
1940
|
+
min_length: Optional[int]
|
1941
|
+
"""Optional. SCHEMA FIELDS FOR TYPE STRING Minimum length of the Type.STRING"""
|
2023
1942
|
|
1943
|
+
min_properties: Optional[int]
|
1944
|
+
"""Optional. Minimum number of the properties for Type.OBJECT."""
|
2024
1945
|
|
2025
|
-
|
2026
|
-
"""
|
1946
|
+
minimum: Optional[float]
|
1947
|
+
"""Optional. SCHEMA FIELDS FOR TYPE INTEGER and NUMBER Minimum value of the Type.INTEGER and Type.NUMBER"""
|
2027
1948
|
|
2028
|
-
|
2029
|
-
|
2030
|
-
description="""Optional. Deprecated. Please use rag_resources instead.""",
|
2031
|
-
)
|
2032
|
-
rag_resources: Optional[list[VertexRagStoreRagResource]] = Field(
|
2033
|
-
default=None,
|
2034
|
-
description="""Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support.""",
|
2035
|
-
)
|
2036
|
-
rag_retrieval_config: Optional[RagRetrievalConfig] = Field(
|
2037
|
-
default=None,
|
2038
|
-
description="""Optional. The retrieval config for the Rag query.""",
|
2039
|
-
)
|
2040
|
-
similarity_top_k: Optional[int] = Field(
|
2041
|
-
default=None,
|
2042
|
-
description="""Optional. Number of top k results to return from the selected corpora.""",
|
2043
|
-
)
|
2044
|
-
vector_distance_threshold: Optional[float] = Field(
|
2045
|
-
default=None,
|
2046
|
-
description="""Optional. Only return results with vector distance smaller than the threshold.""",
|
2047
|
-
)
|
1949
|
+
nullable: Optional[bool]
|
1950
|
+
"""Optional. Indicates if the value may be null."""
|
2048
1951
|
|
1952
|
+
pattern: Optional[str]
|
1953
|
+
"""Optional. Pattern of the Type.STRING to restrict a string to a regular expression."""
|
2049
1954
|
|
2050
|
-
|
2051
|
-
"""
|
1955
|
+
properties: Optional[dict[str, 'SchemaDict']]
|
1956
|
+
"""Optional. SCHEMA FIELDS FOR TYPE OBJECT Properties of Type.OBJECT."""
|
2052
1957
|
|
2053
|
-
|
2054
|
-
"""Optional.
|
1958
|
+
property_ordering: Optional[list[str]]
|
1959
|
+
"""Optional. The order of the properties. Not a standard field in open api spec. Only used to support the order of the properties."""
|
2055
1960
|
|
2056
|
-
|
2057
|
-
"""Optional.
|
1961
|
+
required: Optional[list[str]]
|
1962
|
+
"""Optional. Required properties of Type.OBJECT."""
|
2058
1963
|
|
2059
|
-
|
2060
|
-
"""Optional. The
|
1964
|
+
title: Optional[str]
|
1965
|
+
"""Optional. The title of the Schema."""
|
2061
1966
|
|
2062
|
-
|
2063
|
-
"""Optional.
|
1967
|
+
type: Optional[Type]
|
1968
|
+
"""Optional. The type of the data."""
|
2064
1969
|
|
2065
|
-
vector_distance_threshold: Optional[float]
|
2066
|
-
"""Optional. Only return results with vector distance smaller than the threshold."""
|
2067
1970
|
|
1971
|
+
SchemaOrDict = Union[Schema, SchemaDict]
|
2068
1972
|
|
2069
|
-
VertexRagStoreOrDict = Union[VertexRagStore, VertexRagStoreDict]
|
2070
1973
|
|
1974
|
+
class FunctionDeclaration(_common.BaseModel):
|
1975
|
+
"""Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
|
2071
1976
|
|
2072
|
-
|
2073
|
-
|
1977
|
+
Included in this declaration are the function name, description, parameters
|
1978
|
+
and response type. This FunctionDeclaration is a representation of a block of
|
1979
|
+
code that can be used as a `Tool` by the model and executed by the client.
|
1980
|
+
"""
|
2074
1981
|
|
2075
|
-
|
1982
|
+
description: Optional[str] = Field(
|
2076
1983
|
default=None,
|
2077
|
-
description="""Optional.
|
1984
|
+
description="""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.""",
|
2078
1985
|
)
|
2079
|
-
|
1986
|
+
name: Optional[str] = Field(
|
2080
1987
|
default=None,
|
2081
|
-
description="""
|
1988
|
+
description="""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64.""",
|
2082
1989
|
)
|
2083
|
-
|
1990
|
+
parameters: Optional[Schema] = Field(
|
2084
1991
|
default=None,
|
2085
|
-
description="""
|
1992
|
+
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""",
|
1993
|
+
)
|
1994
|
+
response: Optional[Schema] = Field(
|
1995
|
+
default=None,
|
1996
|
+
description="""Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function.""",
|
2086
1997
|
)
|
2087
1998
|
|
1999
|
+
@classmethod
|
2000
|
+
def from_callable_with_api_option(
|
2001
|
+
cls,
|
2002
|
+
*,
|
2003
|
+
callable: Callable[..., Any],
|
2004
|
+
api_option: Literal['VERTEX_AI', 'GEMINI_API'] = 'GEMINI_API',
|
2005
|
+
) -> 'FunctionDeclaration':
|
2006
|
+
"""Converts a Callable to a FunctionDeclaration based on the API option.
|
2088
2007
|
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2008
|
+
Supported API option is 'VERTEX_AI' or 'GEMINI_API'. If api_option is unset,
|
2009
|
+
it will default to 'GEMINI_API'. If unsupported api_option is provided, it
|
2010
|
+
will raise ValueError.
|
2011
|
+
"""
|
2012
|
+
supported_api_options = ['VERTEX_AI', 'GEMINI_API']
|
2013
|
+
if api_option not in supported_api_options:
|
2014
|
+
raise ValueError(
|
2015
|
+
f'Unsupported api_option value: {api_option}. Supported api_option'
|
2016
|
+
f' value is one of: {supported_api_options}.'
|
2017
|
+
)
|
2018
|
+
from . import _automatic_function_calling_util
|
2094
2019
|
|
2095
|
-
|
2096
|
-
|
2020
|
+
parameters_properties = {}
|
2021
|
+
for name, param in inspect.signature(callable).parameters.items():
|
2022
|
+
if param.kind in (
|
2023
|
+
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
2024
|
+
inspect.Parameter.KEYWORD_ONLY,
|
2025
|
+
inspect.Parameter.POSITIONAL_ONLY,
|
2026
|
+
):
|
2027
|
+
schema = _automatic_function_calling_util._parse_schema_from_parameter(
|
2028
|
+
api_option, param, callable.__name__
|
2029
|
+
)
|
2030
|
+
parameters_properties[name] = schema
|
2031
|
+
declaration = FunctionDeclaration(
|
2032
|
+
name=callable.__name__,
|
2033
|
+
description=callable.__doc__,
|
2034
|
+
)
|
2035
|
+
if parameters_properties:
|
2036
|
+
declaration.parameters = Schema(
|
2037
|
+
type='OBJECT',
|
2038
|
+
properties=parameters_properties,
|
2039
|
+
)
|
2040
|
+
declaration.parameters.required = (
|
2041
|
+
_automatic_function_calling_util._get_required_fields(
|
2042
|
+
declaration.parameters
|
2043
|
+
)
|
2044
|
+
)
|
2045
|
+
if api_option == 'GEMINI_API':
|
2046
|
+
return declaration
|
2097
2047
|
|
2098
|
-
|
2099
|
-
|
2048
|
+
return_annotation = inspect.signature(callable).return_annotation
|
2049
|
+
if return_annotation is inspect._empty:
|
2050
|
+
return declaration
|
2100
2051
|
|
2052
|
+
declaration.response = (
|
2053
|
+
_automatic_function_calling_util._parse_schema_from_parameter(
|
2054
|
+
api_option,
|
2055
|
+
inspect.Parameter(
|
2056
|
+
'return_value',
|
2057
|
+
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
2058
|
+
annotation=return_annotation,
|
2059
|
+
),
|
2060
|
+
callable.__name__,
|
2061
|
+
)
|
2062
|
+
)
|
2063
|
+
return declaration
|
2101
2064
|
|
2102
|
-
|
2065
|
+
@classmethod
|
2066
|
+
def from_callable(
|
2067
|
+
cls,
|
2068
|
+
*,
|
2069
|
+
client: 'BaseApiClient',
|
2070
|
+
callable: Callable[..., Any],
|
2071
|
+
) -> 'FunctionDeclaration':
|
2072
|
+
"""Converts a Callable to a FunctionDeclaration based on the client."""
|
2073
|
+
if client.vertexai:
|
2074
|
+
return cls.from_callable_with_api_option(
|
2075
|
+
callable=callable, api_option='VERTEX_AI'
|
2076
|
+
)
|
2077
|
+
else:
|
2078
|
+
return cls.from_callable_with_api_option(
|
2079
|
+
callable=callable, api_option='GEMINI_API'
|
2080
|
+
)
|
2103
2081
|
|
2104
2082
|
|
2105
|
-
class
|
2106
|
-
"""
|
2083
|
+
class FunctionDeclarationDict(TypedDict, total=False):
|
2084
|
+
"""Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3).
|
2107
2085
|
|
2108
|
-
|
2109
|
-
|
2086
|
+
Included in this declaration are the function name, description, parameters
|
2087
|
+
and response type. This FunctionDeclaration is a representation of a block of
|
2088
|
+
code that can be used as a `Tool` by the model and executed by the client.
|
2110
2089
|
"""
|
2111
2090
|
|
2112
|
-
|
2113
|
-
|
2091
|
+
description: Optional[str]
|
2092
|
+
"""Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function."""
|
2114
2093
|
|
2115
|
-
|
2116
|
-
"""
|
2094
|
+
name: Optional[str]
|
2095
|
+
"""Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots and dashes, with a maximum length of 64."""
|
2117
2096
|
|
2118
|
-
|
2119
|
-
to this
|
2120
|
-
"""
|
2097
|
+
parameters: Optional[SchemaDict]
|
2098
|
+
"""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"""
|
2121
2099
|
|
2122
|
-
|
2100
|
+
response: Optional[SchemaDict]
|
2101
|
+
"""Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function."""
|
2123
2102
|
|
2124
2103
|
|
2125
|
-
|
2104
|
+
FunctionDeclarationOrDict = Union[FunctionDeclaration, FunctionDeclarationDict]
|
2126
2105
|
|
2127
2106
|
|
2128
2107
|
class Tool(_common.BaseModel):
|
2129
2108
|
"""Tool details of a tool that the model may use to generate a response."""
|
2130
2109
|
|
2131
|
-
function_declarations: Optional[list[FunctionDeclaration]] = Field(
|
2132
|
-
default=None,
|
2133
|
-
description="""List of function declarations that the tool supports.""",
|
2134
|
-
)
|
2135
2110
|
retrieval: Optional[Retrieval] = Field(
|
2136
2111
|
default=None,
|
2137
2112
|
description="""Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation.""",
|
@@ -2149,14 +2124,15 @@ class Tool(_common.BaseModel):
|
|
2149
2124
|
default=None,
|
2150
2125
|
description="""Optional. CodeExecution tool type. Enables the model to execute code as part of generation. This field is only used by the Gemini Developer API services.""",
|
2151
2126
|
)
|
2127
|
+
function_declarations: Optional[list[FunctionDeclaration]] = Field(
|
2128
|
+
default=None,
|
2129
|
+
description="""Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 128 function declarations can be provided.""",
|
2130
|
+
)
|
2152
2131
|
|
2153
2132
|
|
2154
2133
|
class ToolDict(TypedDict, total=False):
|
2155
2134
|
"""Tool details of a tool that the model may use to generate a response."""
|
2156
2135
|
|
2157
|
-
function_declarations: Optional[list[FunctionDeclarationDict]]
|
2158
|
-
"""List of function declarations that the tool supports."""
|
2159
|
-
|
2160
2136
|
retrieval: Optional[RetrievalDict]
|
2161
2137
|
"""Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation."""
|
2162
2138
|
|
@@ -2170,6 +2146,9 @@ class ToolDict(TypedDict, total=False):
|
|
2170
2146
|
code_execution: Optional[ToolCodeExecutionDict]
|
2171
2147
|
"""Optional. CodeExecution tool type. Enables the model to execute code as part of generation. This field is only used by the Gemini Developer API services."""
|
2172
2148
|
|
2149
|
+
function_declarations: Optional[list[FunctionDeclarationDict]]
|
2150
|
+
"""Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating FunctionCall in the response. User should provide a FunctionResponse for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 128 function declarations can be provided."""
|
2151
|
+
|
2173
2152
|
|
2174
2153
|
ToolOrDict = Union[Tool, ToolDict]
|
2175
2154
|
ToolListUnion = list[Union[Tool, Callable[..., Any]]]
|
@@ -5544,6 +5523,7 @@ ListModelsResponseOrDict = Union[ListModelsResponse, ListModelsResponseDict]
|
|
5544
5523
|
|
5545
5524
|
|
5546
5525
|
class UpdateModelConfig(_common.BaseModel):
|
5526
|
+
"""Configuration for updating a tuned model."""
|
5547
5527
|
|
5548
5528
|
http_options: Optional[HttpOptions] = Field(
|
5549
5529
|
default=None, description="""Used to override HTTP request options."""
|
@@ -5553,6 +5533,7 @@ class UpdateModelConfig(_common.BaseModel):
|
|
5553
5533
|
|
5554
5534
|
|
5555
5535
|
class UpdateModelConfigDict(TypedDict, total=False):
|
5536
|
+
"""Configuration for updating a tuned model."""
|
5556
5537
|
|
5557
5538
|
http_options: Optional[HttpOptionsDict]
|
5558
5539
|
"""Used to override HTTP request options."""
|
@@ -5568,12 +5549,14 @@ UpdateModelConfigOrDict = Union[UpdateModelConfig, UpdateModelConfigDict]
|
|
5568
5549
|
|
5569
5550
|
|
5570
5551
|
class _UpdateModelParameters(_common.BaseModel):
|
5552
|
+
"""Configuration for updating a tuned model."""
|
5571
5553
|
|
5572
5554
|
model: Optional[str] = Field(default=None, description="""""")
|
5573
5555
|
config: Optional[UpdateModelConfig] = Field(default=None, description="""""")
|
5574
5556
|
|
5575
5557
|
|
5576
5558
|
class _UpdateModelParametersDict(TypedDict, total=False):
|
5559
|
+
"""Configuration for updating a tuned model."""
|
5577
5560
|
|
5578
5561
|
model: Optional[str]
|
5579
5562
|
""""""
|
@@ -5588,6 +5571,7 @@ _UpdateModelParametersOrDict = Union[
|
|
5588
5571
|
|
5589
5572
|
|
5590
5573
|
class DeleteModelConfig(_common.BaseModel):
|
5574
|
+
"""Configuration for deleting a tuned model."""
|
5591
5575
|
|
5592
5576
|
http_options: Optional[HttpOptions] = Field(
|
5593
5577
|
default=None, description="""Used to override HTTP request options."""
|
@@ -5595,6 +5579,7 @@ class DeleteModelConfig(_common.BaseModel):
|
|
5595
5579
|
|
5596
5580
|
|
5597
5581
|
class DeleteModelConfigDict(TypedDict, total=False):
|
5582
|
+
"""Configuration for deleting a tuned model."""
|
5598
5583
|
|
5599
5584
|
http_options: Optional[HttpOptionsDict]
|
5600
5585
|
"""Used to override HTTP request options."""
|
@@ -5604,6 +5589,7 @@ DeleteModelConfigOrDict = Union[DeleteModelConfig, DeleteModelConfigDict]
|
|
5604
5589
|
|
5605
5590
|
|
5606
5591
|
class _DeleteModelParameters(_common.BaseModel):
|
5592
|
+
"""Parameters for deleting a tuned model."""
|
5607
5593
|
|
5608
5594
|
model: Optional[str] = Field(default=None, description="""""")
|
5609
5595
|
config: Optional[DeleteModelConfig] = Field(
|
@@ -5612,6 +5598,7 @@ class _DeleteModelParameters(_common.BaseModel):
|
|
5612
5598
|
|
5613
5599
|
|
5614
5600
|
class _DeleteModelParametersDict(TypedDict, total=False):
|
5601
|
+
"""Parameters for deleting a tuned model."""
|
5615
5602
|
|
5616
5603
|
model: Optional[str]
|
5617
5604
|
""""""
|
@@ -7585,7 +7572,7 @@ class _CreateCachedContentParameters(_common.BaseModel):
|
|
7585
7572
|
|
7586
7573
|
model: Optional[str] = Field(
|
7587
7574
|
default=None,
|
7588
|
-
description="""ID of the model to use. Example: gemini-
|
7575
|
+
description="""ID of the model to use. Example: gemini-2.0-flash""",
|
7589
7576
|
)
|
7590
7577
|
config: Optional[CreateCachedContentConfig] = Field(
|
7591
7578
|
default=None,
|
@@ -7598,7 +7585,7 @@ class _CreateCachedContentParametersDict(TypedDict, total=False):
|
|
7598
7585
|
"""Parameters for caches.create method."""
|
7599
7586
|
|
7600
7587
|
model: Optional[str]
|
7601
|
-
"""ID of the model to use. Example: gemini-
|
7588
|
+
"""ID of the model to use. Example: gemini-2.0-flash"""
|
7602
7589
|
|
7603
7590
|
config: Optional[CreateCachedContentConfigDict]
|
7604
7591
|
"""Configuration that contains optional parameters.
|
@@ -9603,6 +9590,10 @@ class LiveServerContent(_common.BaseModel):
|
|
9603
9590
|
default=None,
|
9604
9591
|
description="""If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue.""",
|
9605
9592
|
)
|
9593
|
+
grounding_metadata: Optional[GroundingMetadata] = Field(
|
9594
|
+
default=None,
|
9595
|
+
description="""Metadata returned to client when grounding is enabled.""",
|
9596
|
+
)
|
9606
9597
|
generation_complete: Optional[bool] = Field(
|
9607
9598
|
default=None,
|
9608
9599
|
description="""If true, indicates that the model is done generating. When model is
|
@@ -9645,6 +9636,9 @@ class LiveServerContentDict(TypedDict, total=False):
|
|
9645
9636
|
interrupted: Optional[bool]
|
9646
9637
|
"""If true, indicates that a client message has interrupted current model generation. If the client is playing out the content in realtime, this is a good signal to stop and empty the current queue."""
|
9647
9638
|
|
9639
|
+
grounding_metadata: Optional[GroundingMetadataDict]
|
9640
|
+
"""Metadata returned to client when grounding is enabled."""
|
9641
|
+
|
9648
9642
|
generation_complete: Optional[bool]
|
9649
9643
|
"""If true, indicates that the model is done generating. When model is
|
9650
9644
|
interrupted while generating there will be no generation_complete message
|
@@ -10757,8 +10751,10 @@ LiveConnectParametersOrDict = Union[
|
|
10757
10751
|
LiveConnectParameters, LiveConnectParametersDict
|
10758
10752
|
]
|
10759
10753
|
|
10760
|
-
|
10761
|
-
BlobImageUnion = Union[Blob,
|
10754
|
+
if _is_pillow_image_imported:
|
10755
|
+
BlobImageUnion = Union[Blob, PIL_Image]
|
10756
|
+
else:
|
10757
|
+
BlobImageUnion = Blob # type: ignore[misc]
|
10762
10758
|
|
10763
10759
|
|
10764
10760
|
BlobImageUnionDict = Union[BlobImageUnion, BlobDict]
|