@@ -40,7 +40,7 @@ def completion_config(
4040 """
4141 self ._client .track ('$ld:ai:config:function:single' , context , key , 1 )
4242
43- model , provider , messages , instructions , tracker , enabled , judge_configuration = self .__evaluate (
43+ model , provider , messages , instructions , tracker , enabled , judge_configuration , _ = self .__evaluate (
4444 key , context , default_value .to_dict (), variables
4545 )
4646
@@ -94,31 +94,29 @@ def judge_config(
9494 """
9595 self ._client .track ('$ld:ai:judge:function:single' , context , key , 1 )
9696
97- model , provider , messages , instructions , tracker , enabled , judge_configuration = self .__evaluate (
97+ model , provider , messages , instructions , tracker , enabled , judge_configuration , variation = self .__evaluate (
9898 key , context , default_value .to_dict (), variables
9999 )
100100
101- variation = self ._client .variation (key , context , default_value .to_dict ())
102-
103101 def _extract_evaluation_metric_key (
104102 variation : Dict [str , Any ], default_value : AIJudgeConfigDefault
105103 ) -> Optional [str ]:
106104 """
107105 Extract evaluation_metric_key with backward compatibility.
108106
109- Priority: 1) evaluationMetricKey from variation, 2) evaluation_metric_key from default ,
110- 3) first from evaluationMetricKeys in variation , 4) first from evaluation_metric_keys in default
107+ Priority: 1) evaluationMetricKey from variation, 2) evaluationMetricKeys from variation ,
108+ 3) evaluation_metric_key from default , 4) evaluation_metric_keys from default
111109 """
112110 if evaluation_metric_key := variation .get ('evaluationMetricKey' ):
113111 return evaluation_metric_key
114112
115- if default_value .evaluation_metric_key :
116- return default_value .evaluation_metric_key
117-
118113 variation_keys = variation .get ('evaluationMetricKeys' )
119114 if isinstance (variation_keys , list ) and variation_keys :
120115 return variation_keys [0 ]
121116
117+ if default_value .evaluation_metric_key :
118+ return default_value .evaluation_metric_key
119+
122120 if default_value .evaluation_metric_keys :
123121 return default_value .evaluation_metric_keys [0 ]
124122
@@ -458,7 +456,7 @@ def __evaluate(
458456 variables : Optional [Dict [str , Any ]] = None ,
459457 ) -> Tuple [
460458 Optional [ModelConfig ], Optional [ProviderConfig ], Optional [List [LDMessage ]],
461- Optional [str ], LDAIConfigTracker , bool , Optional [Any ]
459+ Optional [str ], LDAIConfigTracker , bool , Optional [Any ], Dict [ str , Any ]
462460 ]:
463461 """
464462 Internal method to evaluate a configuration and extract components.
@@ -467,7 +465,7 @@ def __evaluate(
467465 :param context: The evaluation context.
468466 :param default_dict: Default configuration as dictionary.
469467 :param variables: Variables for interpolation.
470- :return: Tuple of (model, provider, messages, instructions, tracker, enabled).
468+ :return: Tuple of (model, provider, messages, instructions, tracker, enabled, judge_configuration, variation ).
471469 """
472470 variation = self ._client .variation (key , context , default_dict )
473471
@@ -536,7 +534,7 @@ def __evaluate(
536534 if judges :
537535 judge_configuration = JudgeConfiguration (judges = judges )
538536
539- return model , provider_config , messages , instructions , tracker , enabled , judge_configuration
537+ return model , provider_config , messages , instructions , tracker , enabled , judge_configuration , variation
540538
541539 def __evaluate_agent (
542540 self ,
@@ -554,7 +552,7 @@ def __evaluate_agent(
554552 :param variables: Variables for interpolation.
555553 :return: Configured AIAgentConfig instance.
556554 """
557- model , provider , messages , instructions , tracker , enabled , judge_configuration = self .__evaluate (
555+ model , provider , messages , instructions , tracker , enabled , judge_configuration , _ = self .__evaluate (
558556 key , context , default_value .to_dict (), variables
559557 )
560558
0 commit comments