@@ -2149,23 +2149,15 @@ def _convert_results_to_aoai_evaluation_results(
21492149 should_add_error_summary = True
21502150 for result in run_output_results :
21512151 if result .get ("name" , None ) == criteria_name and result .get ("metric" , None ) == metric :
2152+ rs_score = result .get ("score" , None )
2153+ rs_threshold = result .get ("threshold" , None )
2154+ rs_label = result .get ("label" , None )
2155+ rs_reason = result .get ("reason" , None )
21522156 if (
2153- (
2154- result .get ("score" , None ) == None
2155- or (
2156- isinstance (result .get ("score" , None ), float )
2157- and math .isnan (result .get ("score" , None ))
2158- )
2159- )
2160- and (
2161- result .get ("threshold" , None ) == None
2162- or (
2163- isinstance (result .get ("threshold" , None ), float )
2164- and math .isnan (result .get ("threshold" , None ))
2165- )
2166- )
2167- and (result .get ("label" , None ) == None or result .get ("label" , None ) == "NaN" )
2168- and (result .get ("reason" , None ) == None or result .get ("reason" , None ) == "NaN" )
2157+ _is_none_or_nan (rs_score )
2158+ and _is_none_or_nan (rs_threshold )
2159+ and _is_none_or_nan (rs_label )
2160+ and _is_none_or_nan (rs_reason )
21692161 ):
21702162 run_output_results .remove (result )
21712163 else :
@@ -2217,6 +2209,24 @@ def _convert_results_to_aoai_evaluation_results(
22172209 )
22182210
22192211
2212+ def _is_none_or_nan (value : Any ) -> bool :
2213+ """
2214+ Check if a value is None or NaN.
2215+
2216+ :param value: The value to check
2217+ :type value: Any
2218+ :return: True if the value is None or NaN, False otherwise
2219+ :rtype: bool
2220+ """
2221+ if value is None :
2222+ return True
2223+ if isinstance (value , float ) and math .isnan (value ):
2224+ return True
2225+ if isinstance (value , str ) and value .lower () in ["nan" , "null" , "none" ]:
2226+ return True
2227+ return False
2228+
2229+
22202230def _append_indirect_attachments_to_results (
22212231 current_result_dict : Dict [str , Any ],
22222232 result_name : str ,
0 commit comments