def extract_code()

in generate/evaluate.py [0:0]


    def extract_code(self, text: str) -> tuple[str, str]:
        """Extract code from the response between ```cpp and ``` markers."""
        try:
            parts = text.split("```cpp\n")
            if len(parts) > 1:
                code_block = parts[-1].split("```")[0]
                code = code_block.strip()
                if not code:
                    logger.warning("Empty code block found")
                    return "", "cpp"
                return code, "cpp"
            logger.warning("No code block found in the response")
            return "", "unknown"
        except Exception as e:
            logger.error(f"Failed to extract code: {str(e)}")
            return "", "unknown"