def evaluate(
        self,
        query: str,
        results: List[Dict[str, Any]],
        expected_content_keywords: Optional[List[str]] = None,
        minimum_score: float = 0.7,
        minimum_relevant_results: int = 3,
    ) -> Dict[str, Any]:
        """Evaluate search results quality.

        Args:
            query: The search query
            results: List of search results
            expected_content_keywords: Keywords that should appear in good results
            minimum_score: Minimum acceptable quality score (0-1)
            minimum_relevant_results: Minimum number of relevant results expected

        Returns:
            Dict with evaluation metrics
        """
        expected_keywords = expected_content_keywords or []

        # Use LLM if API key is available, otherwise fall back to simple evaluation
        if self.llm_api_key:
            evaluation = self._evaluate_with_llm(query, results, expected_keywords)
        else:
            logger.warning("No LLM API key provided, falling back to simple evaluation.")
            evaluation = self._simple_evaluation(query, results, expected_keywords)

        # Add pass/fail status
        evaluation["passed"] = (
            evaluation["score"] >= minimum_score
            and evaluation["relevant_results"] >= minimum_relevant_results
        )

        return evaluation
Evaluate search results quality.

        Args:
            query: The search query
            results: List of search results
            expected_content_keywords: Keywords that should appear in good results
            minimum_score: Minimum acceptable quality score (0-1)
            minimum_relevant_results: Minimum number of relevant results expected

        Returns:
            Dict with evaluation metrics
        
backend/tests/helpers/llm_judge.py