@@ -1116,6 +1116,70 @@ def assess_tuning_validity(
11161116 response ["tuningValidationAssessmentResult" ],
11171117 )
11181118
1119+ def assess_batch_prediction_resources (
1120+ self ,
1121+ * ,
1122+ dataset_name : str ,
1123+ model_name : str ,
1124+ template_config : Optional [types .GeminiTemplateConfigOrDict ] = None ,
1125+ config : Optional [types .AssessDatasetConfigOrDict ] = None ,
1126+ ) -> types .BatchPredictionResourceUsageAssessmentResult :
1127+ """Assess the batch prediction resources required for a given model.
1128+
1129+ Args:
1130+ dataset_name:
1131+ Required. The name of the dataset to assess the batch prediction
1132+ resources.
1133+ model_name:
1134+ Required. The name of the model to assess the batch prediction
1135+ resources.
1136+ template_config:
1137+ Optional. The template config used to assemble the dataset
1138+ before assessing the batch prediction resources. If not provided,
1139+ the template config attached to the dataset will be used. Required
1140+ if no template config is attached to the dataset.
1141+ template_config:
1142+ Optional. The template config used to assemble the dataset
1143+ before assessing the batch prediction resources. If not provided, the
1144+ template config attached to the dataset will be used. Required
1145+ if no template config is attached to the dataset.
1146+ config:
1147+ Optional. A configuration for assessing the batch prediction
1148+ resources. If not provided, the default configuration will be
1149+ used.
1150+
1151+ Returns:
1152+ A types.BatchPredictionResourceUsageAssessmentResult object
1153+ representing the batch prediction resource usage assessment result.
1154+ It contains the following keys:
1155+ - token_count: The number of tokens in the dataset.
1156+ - audio_token_count: The number of audio tokens in the dataset.
1157+
1158+ """
1159+ if isinstance (config , dict ):
1160+ config = types .AssessDatasetConfig (** config )
1161+ elif not config :
1162+ config = types .AssessDatasetConfig ()
1163+
1164+ operation = self ._assess_multimodal_dataset (
1165+ name = dataset_name ,
1166+ batch_prediction_resource_usage_assessment_config = types .BatchPredictionResourceUsageAssessmentConfig (
1167+ model_name = model_name ,
1168+ ),
1169+ gemini_request_read_config = types .GeminiRequestReadConfig (
1170+ template_config = template_config ,
1171+ ),
1172+ config = config ,
1173+ )
1174+ response = self ._wait_for_operation (
1175+ operation = operation ,
1176+ timeout_seconds = config .timeout ,
1177+ )
1178+ result = response ["batchPredictionResourceUsageAssessmentResult" ]
1179+ return _datasets_utils .create_from_response (
1180+ types .BatchPredictionResourceUsageAssessmentResult , result
1181+ )
1182+
11191183
11201184class AsyncDatasets (_api_module .BaseModule ):
11211185
@@ -1999,3 +2063,67 @@ async def assess_tuning_validity(
19992063 types .TuningValidationAssessmentResult ,
20002064 response ["tuningValidationAssessmentResult" ],
20012065 )
2066+
2067+ async def assess_batch_prediction_resources (
2068+ self ,
2069+ * ,
2070+ dataset_name : str ,
2071+ model_name : str ,
2072+ template_config : Optional [types .GeminiTemplateConfigOrDict ] = None ,
2073+ config : Optional [types .AssessDatasetConfigOrDict ] = None ,
2074+ ) -> types .BatchPredictionResourceUsageAssessmentResult :
2075+ """Assess the batch prediction resources required for a given model.
2076+
2077+ Args:
2078+ dataset_name:
2079+ Required. The name of the dataset to assess the batch prediction
2080+ resources.
2081+ model_name:
2082+ Required. The name of the model to assess the batch prediction
2083+ resources.
2084+ template_config:
2085+ Optional. The template config used to assemble the dataset
2086+ before assessing the batch prediction resources. If not provided,
2087+ the template config attached to the dataset will be used. Required
2088+ if no template config is attached to the dataset.
2089+ template_config:
2090+ Optional. The template config used to assemble the dataset
2091+ before assessing the batch prediction resources. If not provided, the
2092+ template config attached to the dataset will be used. Required
2093+ if no template config is attached to the dataset.
2094+ config:
2095+ Optional. A configuration for assessing the batch prediction
2096+ resources. If not provided, the default configuration will be
2097+ used.
2098+
2099+ Returns:
2100+ A types.BatchPredictionResourceUsageAssessmentResult object
2101+ representing the batch prediction resource usage assessment result.
2102+ It contains the following keys:
2103+ - token_count: The number of tokens in the dataset.
2104+ - audio_token_count: The number of audio tokens in the dataset.
2105+
2106+ """
2107+ if isinstance (config , dict ):
2108+ config = types .AssessDatasetConfig (** config )
2109+ elif not config :
2110+ config = types .AssessDatasetConfig ()
2111+
2112+ operation = await self ._assess_multimodal_dataset (
2113+ name = dataset_name ,
2114+ batch_prediction_resource_usage_assessment_config = types .BatchPredictionResourceUsageAssessmentConfig (
2115+ model_name = model_name ,
2116+ ),
2117+ gemini_request_read_config = types .GeminiRequestReadConfig (
2118+ template_config = template_config ,
2119+ ),
2120+ config = config ,
2121+ )
2122+ response = await self ._wait_for_operation (
2123+ operation = operation ,
2124+ timeout_seconds = config .timeout ,
2125+ )
2126+ result = response ["batchPredictionResourceUsageAssessmentResult" ]
2127+ return _datasets_utils .create_from_response (
2128+ types .BatchPredictionResourceUsageAssessmentResult , result
2129+ )
0 commit comments