@@ -73,6 +73,16 @@ def t_metrics(
7373 metric_payload_item ["custom_code_execution_spec" ] = {
7474 "evaluation_function" : metric .remote_custom_function
7575 }
76+ elif (
77+ isinstance (metric , types .CodeExecutionMetric )
78+ or (
79+ isinstance (metric , types .Metric )
80+ and isinstance (getattr (metric , "custom_function" , None ), str )
81+ )
82+ ) and getattr (metric , "custom_function" , None ):
83+ metric_payload_item ["custom_code_execution_spec" ] = {
84+ "evaluation_function" : metric .custom_function
85+ }
7686 # LLM-based metrics
7787 elif hasattr (metric , "prompt_template" ) and metric .prompt_template :
7888 llm_based_spec : dict [str , Any ] = {
@@ -177,27 +187,23 @@ def t_metric_for_registry(
177187 if metric_name :
178188 metric_name = metric_name .lower ()
179189
180- # Handle standard computation metrics
181- if metric_name == "exact_match" :
182- metric_payload_item ["exact_match_spec" ] = {}
183- elif metric_name == "bleu" :
184- metric_payload_item ["bleu_spec" ] = {}
185- elif metric_name and metric_name .startswith ("rouge" ):
186- rouge_type = metric_name .replace ("_" , "" )
187- metric_payload_item ["rouge_spec" ] = {"rouge_type" : rouge_type }
188- # API Pre-defined metrics
189- elif metric_name and metric_name in _evals_constant .SUPPORTED_PREDEFINED_METRICS :
190- metric_payload_item ["predefined_metric_spec" ] = {
191- "metric_spec_name" : metric_name ,
192- "metric_spec_parameters" : metric .metric_spec_parameters ,
193- }
194190 # Custom Code Execution Metric
195- elif hasattr (metric , "remote_custom_function" ) and metric .remote_custom_function :
191+ if hasattr (metric , "remote_custom_function" ) and metric .remote_custom_function :
196192 metric_payload_item ["custom_code_execution_spec" ] = {
197193 "evaluation_function" : metric .remote_custom_function
198194 }
195+ elif (
196+ isinstance (metric , types .CodeExecutionMetric )
197+ or (
198+ isinstance (metric , types .Metric )
199+ and isinstance (getattr (metric , "custom_function" , None ), str )
200+ )
201+ ) and getattr (metric , "custom_function" , None ):
202+ metric_payload_item ["custom_code_execution_spec" ] = {
203+ "evaluation_function" : metric .custom_function
204+ }
199205
200- # Map LLM-based metrics to the new llm_based_metric_spec
206+ # LLM-based metric
201207 elif (hasattr (metric , "prompt_template" ) and metric .prompt_template ) or (
202208 hasattr (metric , "rubric_group_name" ) and metric .rubric_group_name
203209 ):
0 commit comments