@@ -194,6 +194,24 @@ def _CustomCodeExecutionSpec_to_vertex(
194194 return to_object
195195
196196
197+ def _DeleteEvaluationMetricParameters_to_vertex (
198+ from_object : Union [dict [str , Any ], object ],
199+ parent_object : Optional [dict [str , Any ]] = None ,
200+ ) -> dict [str , Any ]:
201+ to_object : dict [str , Any ] = {}
202+ if getv (from_object , ["metric_resource_name" ]) is not None :
203+ setv (
204+ to_object ,
205+ ["_url" , "evaluation_metric" ],
206+ getv (from_object , ["metric_resource_name" ]),
207+ )
208+
209+ if getv (from_object , ["config" ]) is not None :
210+ setv (to_object , ["config" ], getv (from_object , ["config" ]))
211+
212+ return to_object
213+
214+
197215def _EvaluateInstancesRequestParameters_to_vertex (
198216 from_object : Union [dict [str , Any ], object ],
199217 parent_object : Optional [dict [str , Any ]] = None ,
@@ -1242,6 +1260,78 @@ def _create_evaluation_set(
12421260 self ._api_client ._verify_response (return_value )
12431261 return return_value
12441262
1263+ def _delete_evaluation_metric (
1264+ self ,
1265+ * ,
1266+ metric_resource_name : str ,
1267+ config : Optional [types .DeleteEvaluationMetricConfigOrDict ] = None ,
1268+ ) -> types .DeleteEvaluationMetricOperation :
1269+ """
1270+ Deletes an EvaluationMetric.
1271+ """
1272+
1273+ parameter_model = types ._DeleteEvaluationMetricParameters (
1274+ metric_resource_name = metric_resource_name ,
1275+ config = config ,
1276+ )
1277+
1278+ request_url_dict : Optional [dict [str , str ]]
1279+ if not self ._api_client .vertexai :
1280+ raise ValueError (
1281+ "This method is only supported in the Gemini Enterprise Agent Platform (previously known as Vertex AI) client."
1282+ )
1283+ else :
1284+ request_dict = _DeleteEvaluationMetricParameters_to_vertex (parameter_model )
1285+ request_url_dict = request_dict .get ("_url" )
1286+ if request_url_dict :
1287+ path = "{evaluation_metric}" .format_map (request_url_dict )
1288+ else :
1289+ path = "{evaluation_metric}"
1290+
1291+ query_params = request_dict .get ("_query" )
1292+ if query_params :
1293+ path = f"{ path } ?{ urlencode (query_params )} "
1294+ # TODO: remove the hack that pops config.
1295+ request_dict .pop ("config" , None )
1296+
1297+ http_options : Optional [types .HttpOptions ] = None
1298+ if (
1299+ parameter_model .config is not None
1300+ and parameter_model .config .http_options is not None
1301+ ):
1302+ http_options = parameter_model .config .http_options
1303+
1304+ request_dict = _common .convert_to_dict (request_dict )
1305+ request_dict = _common .encode_unserializable_types (request_dict )
1306+
1307+ response = self ._api_client .request ("delete" , path , request_dict , http_options )
1308+
1309+ response_dict = {} if not response .body else json .loads (response .body )
1310+
1311+ return_value = types .DeleteEvaluationMetricOperation ._from_response (
1312+ response = response_dict ,
1313+ kwargs = (
1314+ {
1315+ "config" : {
1316+ "response_schema" : getattr (
1317+ parameter_model .config , "response_schema" , None
1318+ ),
1319+ "response_json_schema" : getattr (
1320+ parameter_model .config , "response_json_schema" , None
1321+ ),
1322+ "include_all_fields" : getattr (
1323+ parameter_model .config , "include_all_fields" , None
1324+ ),
1325+ }
1326+ }
1327+ if getattr (parameter_model , "config" , None )
1328+ else {}
1329+ ),
1330+ )
1331+
1332+ self ._api_client ._verify_response (return_value )
1333+ return return_value
1334+
12451335 def _evaluate_instances (
12461336 self ,
12471337 * ,
@@ -2907,6 +2997,29 @@ def list_evaluation_metrics(
29072997 config = config ,
29082998 )
29092999
3000+ @_common .experimental_warning (
3001+ "The Vertex SDK GenAI evals.delete_evaluation_metric method is experimental, "
3002+ "and may change in future versions."
3003+ )
3004+ def delete_evaluation_metric (
3005+ self ,
3006+ * ,
3007+ metric_resource_name : str ,
3008+ config : Optional [types .DeleteEvaluationMetricConfigOrDict ] = None ,
3009+ ) -> None :
3010+ """Deletes an EvaluationMetric.
3011+
3012+ Args:
3013+ metric_resource_name: The resource name of the EvaluationMetric to delete.
3014+ Format:
3015+ `projects/{project}/locations/{location}/evaluationMetrics/{evaluation_metric}`
3016+ config: The optional configuration for the delete operation.
3017+ """
3018+ self ._delete_evaluation_metric (
3019+ metric_resource_name = metric_resource_name ,
3020+ config = config ,
3021+ )
3022+
29103023
29113024class AsyncEvals (_api_module .BaseModule ):
29123025
@@ -3234,6 +3347,80 @@ async def _create_evaluation_set(
32343347 self ._api_client ._verify_response (return_value )
32353348 return return_value
32363349
3350+ async def _delete_evaluation_metric (
3351+ self ,
3352+ * ,
3353+ metric_resource_name : str ,
3354+ config : Optional [types .DeleteEvaluationMetricConfigOrDict ] = None ,
3355+ ) -> types .DeleteEvaluationMetricOperation :
3356+ """
3357+ Deletes an EvaluationMetric.
3358+ """
3359+
3360+ parameter_model = types ._DeleteEvaluationMetricParameters (
3361+ metric_resource_name = metric_resource_name ,
3362+ config = config ,
3363+ )
3364+
3365+ request_url_dict : Optional [dict [str , str ]]
3366+ if not self ._api_client .vertexai :
3367+ raise ValueError (
3368+ "This method is only supported in the Gemini Enterprise Agent Platform (previously known as Vertex AI) client."
3369+ )
3370+ else :
3371+ request_dict = _DeleteEvaluationMetricParameters_to_vertex (parameter_model )
3372+ request_url_dict = request_dict .get ("_url" )
3373+ if request_url_dict :
3374+ path = "{evaluation_metric}" .format_map (request_url_dict )
3375+ else :
3376+ path = "{evaluation_metric}"
3377+
3378+ query_params = request_dict .get ("_query" )
3379+ if query_params :
3380+ path = f"{ path } ?{ urlencode (query_params )} "
3381+ # TODO: remove the hack that pops config.
3382+ request_dict .pop ("config" , None )
3383+
3384+ http_options : Optional [types .HttpOptions ] = None
3385+ if (
3386+ parameter_model .config is not None
3387+ and parameter_model .config .http_options is not None
3388+ ):
3389+ http_options = parameter_model .config .http_options
3390+
3391+ request_dict = _common .convert_to_dict (request_dict )
3392+ request_dict = _common .encode_unserializable_types (request_dict )
3393+
3394+ response = await self ._api_client .async_request (
3395+ "delete" , path , request_dict , http_options
3396+ )
3397+
3398+ response_dict = {} if not response .body else json .loads (response .body )
3399+
3400+ return_value = types .DeleteEvaluationMetricOperation ._from_response (
3401+ response = response_dict ,
3402+ kwargs = (
3403+ {
3404+ "config" : {
3405+ "response_schema" : getattr (
3406+ parameter_model .config , "response_schema" , None
3407+ ),
3408+ "response_json_schema" : getattr (
3409+ parameter_model .config , "response_json_schema" , None
3410+ ),
3411+ "include_all_fields" : getattr (
3412+ parameter_model .config , "include_all_fields" , None
3413+ ),
3414+ }
3415+ }
3416+ if getattr (parameter_model , "config" , None )
3417+ else {}
3418+ ),
3419+ )
3420+
3421+ self ._api_client ._verify_response (return_value )
3422+ return return_value
3423+
32373424 async def _evaluate_instances (
32383425 self ,
32393426 * ,
@@ -4548,3 +4735,26 @@ async def list_evaluation_metrics(
45484735 return await self ._list_evaluation_metrics (
45494736 config = config ,
45504737 )
4738+
4739+ @_common .experimental_warning (
4740+ "The Vertex SDK GenAI evals.delete_evaluation_metric method is experimental, "
4741+ "and may change in future versions."
4742+ )
4743+ async def delete_evaluation_metric (
4744+ self ,
4745+ * ,
4746+ metric_resource_name : str ,
4747+ config : Optional [types .DeleteEvaluationMetricConfigOrDict ] = None ,
4748+ ) -> None :
4749+ """Deletes an EvaluationMetric.
4750+
4751+ Args:
4752+ metric_resource_name: The resource name of the EvaluationMetric to delete.
4753+ Format:
4754+ `projects/{project}/locations/{location}/evaluationMetrics/{evaluation_metric}`
4755+ config: The optional configuration for the delete operation.
4756+ """
4757+ await self ._delete_evaluation_metric (
4758+ metric_resource_name = metric_resource_name ,
4759+ config = config ,
4760+ )
0 commit comments