From 93b5716e8c6226fa5a585478fced47673efb6fbc Mon Sep 17 00:00:00 2001 From: zhouhangeng Date: Thu, 5 Sep 2024 17:29:56 +0800 Subject: [PATCH] =?UTF-8?q?update:=20cr=E5=A2=9E=E5=8A=A0=E5=85=9C?= =?UTF-8?q?=E5=BA=95=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/ext/cr/actions/code_review.py | 1 - metagpt/tools/libs/cr.py | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/metagpt/ext/cr/actions/code_review.py b/metagpt/ext/cr/actions/code_review.py index 7ee452194..a9733531e 100644 --- a/metagpt/ext/cr/actions/code_review.py +++ b/metagpt/ext/cr/actions/code_review.py @@ -202,7 +202,6 @@ class CodeReview(Action): comments.extend(comments_batch) if valid_patch_count == 0: - await ThoughtReporter().async_report(value={"type": "limit", "classify": "language"}) raise ValueError("Only code reviews for Python and Java languages are supported.") return comments diff --git a/metagpt/tools/libs/cr.py b/metagpt/tools/libs/cr.py index 150f24bd5..0a53dd194 100644 --- a/metagpt/tools/libs/cr.py +++ b/metagpt/tools/libs/cr.py @@ -49,9 +49,11 @@ class CodeReview: async with aiofiles.open(point_file, "rb") as f: cr_point_content = await f.read() cr_points = [Point(**i) for i in json.loads(cr_point_content)] - - comments = await CodeReview_().run(patch, cr_points, output_file) - return f"The number of defects: {len(comments)} and the comments are stored in {output_file}" + try: + comments = await CodeReview_().run(patch, cr_points, output_file) + except ValueError as e: + return str(e) + return f"The number of defects: {len(comments)}, the comments are stored in {output_file}, and the checkpoints are stored in {str(point_file)}" async def fix( self,