diff --git a/deepeval/metrics/utils.py b/deepeval/metrics/utils.py index ca648c73f..96a60db19 100644 --- a/deepeval/metrics/utils.py +++ b/deepeval/metrics/utils.py @@ -375,6 +375,15 @@ def trimAndLoadJson( input_string: str, metric: Optional[BaseMetric] = None, ) -> Any: + # Remove ... blocks (multiline-safe, non-greedy) + input_string = re.sub( + r".*?", + "", + input_string, + flags=re.DOTALL | re.IGNORECASE, + ) + + # JSON trimming logic start = input_string.find("{") end = input_string.rfind("}") + 1