fix: encode string before hashing

This commit is contained in:
Lucas Gomide
2025-07-11 10:42:28 -03:00
parent de425450d4
commit ee490a19fb
2 changed files with 2 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ class ExperimentRunner:
def _run_test_case(self, test_case: Dict[str, Any], crew: Crew) -> ExperimentResult:
inputs = test_case["inputs"]
expected_score = test_case["expected_score"]
identifier = test_case.get("identifier") or md5(str(test_case), usedforsecurity=False).hexdigest()
identifier = test_case.get("identifier") or md5(str(test_case).encode(), usedforsecurity=False).hexdigest()
try:
self.display.console.print(f"[dim]Running crew with input: {str(inputs)[:50]}...[/dim]")

View File

@@ -58,7 +58,6 @@ class TestExperimentRunner:
"expected_score": {"goal_alignment": 7}
},
{
"identifier": "test-case-3",
"inputs": {"query": "Test query 3"},
"expected_score": {"tool_selection": 9}
}
@@ -88,7 +87,7 @@ class TestExperimentRunner:
assert "goal_alignment" in result_2.expected_score
assert result_2.passed is True
assert result_3.identifier == "test-case-3"
assert result_3.identifier == "c2ed49e63aa9a83af3ca382794134fd5"
assert result_3.inputs == {"query": "Test query 3"}
assert isinstance(result_3.expected_score, dict)
assert "tool_selection" in result_3.expected_score