@@ -288,6 +288,7 @@ class MetricHandler(abc.ABC, Generic[T]):
288288 def __init__ (self , module : "evals.Evals" , metric : T ):
289289 self .module = module
290290 self .metric : T = metric
291+ self .allow_cross_region_model : Optional [bool ] = None
291292
292293 @property
293294 @abc .abstractmethod
@@ -761,6 +762,7 @@ def get_metric_result(
761762 lambda : self .module ._evaluate_instances (
762763 metrics = [self .metric ],
763764 instance = instance ,
765+ allow_cross_region_model = self .allow_cross_region_model ,
764766 ),
765767 self .metric_name ,
766768 )
@@ -981,15 +983,16 @@ def __init__(self, module: "evals.Evals", metric: types.Metric):
981983 raise ValueError (
982984 f"Metric '{ self .metric .name } ' is not a supported predefined metric."
983985 )
984- if (
986+ if self . metric . name . startswith ( "multi_turn" ) and (
985987 self .metric .judge_model
986988 or self .metric .judge_model_generation_config
987989 or self .metric .judge_model_sampling_count
988990 ):
989991 logger .warning (
990992 "Autorater config settings (judge_model, "
991993 "judge_model_generation_config, judge_model_sampling_count) "
992- "are ignored for predefined metric '%s'." ,
994+ "are ignored for multi-turn metric '%s'. Use "
995+ "judge_model_step_configs to set its judges." ,
993996 self .metric .name ,
994997 )
995998
@@ -1071,6 +1074,7 @@ def get_metric_result(
10711074 metrics = [self .metric ],
10721075 instance = payload .get ("instance" ),
10731076 autorater_config = payload .get ("autorater_config" ),
1077+ allow_cross_region_model = self .allow_cross_region_model ,
10741078 ),
10751079 metric_name ,
10761080 )
@@ -1318,6 +1322,7 @@ def get_metric_result(
13181322 metric_sources = [metric_source ],
13191323 instance = payload .get ("instance" ),
13201324 autorater_config = payload .get ("autorater_config" ),
1325+ allow_cross_region_model = self .allow_cross_region_model ,
13211326 ),
13221327 metric_name ,
13231328 )
@@ -1404,12 +1409,16 @@ def aggregate(
14041409
14051410
14061411def get_handler_for_metric (
1407- module : "evals.Evals" , metric : types .Metric
1412+ module : "evals.Evals" ,
1413+ metric : types .Metric ,
1414+ allow_cross_region_model : Optional [bool ] = None ,
14081415) -> Union [MetricHandlerType , Any ]:
14091416 """Returns a metric handler for the given metric."""
14101417 for condition , handler_class in _METRIC_HANDLER_MAPPING :
14111418 if condition (metric ): # type: ignore[no-untyped-call]
1412- return handler_class (module = module , metric = metric )
1419+ handler = handler_class (module = module , metric = metric )
1420+ handler .allow_cross_region_model = allow_cross_region_model
1421+ return handler
14131422 raise ValueError (f"Unsupported metric: { metric .name } " )
14141423
14151424
@@ -1548,6 +1557,7 @@ def _rate_limited_get_metric_result(
15481557def compute_metrics_and_aggregate (
15491558 evaluation_run_config : EvaluationRunConfig ,
15501559 evaluation_service_qps : Optional [float ] = None ,
1560+ allow_cross_region_model : Optional [bool ] = None ,
15511561) -> types .EvaluationResult :
15521562 """Computes metrics and aggregates them for a given evaluation run config.
15531563
@@ -1556,6 +1566,8 @@ def compute_metrics_and_aggregate(
15561566 evaluation_service_qps: Optional QPS limit for the evaluation service.
15571567 Defaults to _DEFAULT_EVAL_SERVICE_QPS (10). Users with higher
15581568 quotas can increase this value.
1569+ allow_cross_region_model: Opt-in flag to authorize cross-region
1570+ routing for judge models.
15591571 """
15601572 metric_handlers = []
15611573 all_futures = []
@@ -1574,7 +1586,11 @@ def compute_metrics_and_aggregate(
15741586
15751587 for eval_metric in evaluation_run_config .metrics :
15761588 metric_handlers .append (
1577- get_handler_for_metric (evaluation_run_config .evals_module , eval_metric )
1589+ get_handler_for_metric (
1590+ evaluation_run_config .evals_module ,
1591+ eval_metric ,
1592+ allow_cross_region_model = allow_cross_region_model ,
1593+ )
15781594 )
15791595
15801596 eval_case_count = len (evaluation_run_config .dataset .eval_cases )
0 commit comments