@@ -101,20 +101,20 @@ def StepEfficiency(
101101 from validmind .scorers .llm .deepeval import _convert_to_tool_call_list
102102
103103 tools_called_value = _convert_to_tool_call_list (tools_called_value )
104-
104+
105105 trace_dict = row .get (agent_output_column , {})
106-
106+
107107 # StepEfficiencyMetric requires a properly structured trace
108108 # Ensure trace_dict has the necessary structure
109109 if not isinstance (trace_dict , dict ):
110110 trace_dict = {}
111-
111+
112112 # Ensure trace_dict has 'input' and 'output' for task extraction
113113 if "input" not in trace_dict :
114114 trace_dict ["input" ] = input_value
115115 if "output" not in trace_dict :
116116 trace_dict ["output" ] = actual_output_value
117-
117+
118118 test_case = LLMTestCase (
119119 input = input_value ,
120120 actual_output = actual_output_value ,
@@ -133,25 +133,29 @@ def StepEfficiency(
133133 # This can happen if the trace doesn't contain the required execution steps
134134 error_msg = str (e )
135135 if "prompt" in error_msg or "referenced before assignment" in error_msg :
136- results .append ({
137- "score" : 0.0 ,
138- "reason" : (
139- f"StepEfficiency evaluation failed: The agent trace may not contain "
140- f"sufficient execution steps for analysis. StepEfficiencyMetric requires "
141- f"a complete execution trace with step-by-step actions. "
142- f"Original error: { error_msg } "
143- )
144- })
136+ results .append (
137+ {
138+ "score" : 0.0 ,
139+ "reason" : (
140+ f"StepEfficiency evaluation failed: The agent trace may not contain "
141+ f"sufficient execution steps for analysis. StepEfficiencyMetric requires "
142+ f"a complete execution trace with step-by-step actions. "
143+ f"Original error: { error_msg } "
144+ ),
145+ }
146+ )
145147 else :
146148 raise
147149 except Exception as e :
148150 # Handle other potential errors gracefully
149- results .append ({
150- "score" : 0.0 ,
151- "reason" : (
152- f"StepEfficiency evaluation failed: { str (e )} . "
153- f"This metric requires a properly structured agent execution trace."
154- )
155- })
151+ results .append (
152+ {
153+ "score" : 0.0 ,
154+ "reason" : (
155+ f"StepEfficiency evaluation failed: { str (e )} . "
156+ f"This metric requires a properly structured agent execution trace."
157+ ),
158+ }
159+ )
156160
157161 return results
0 commit comments