From 4132a6aa8dbb0167aa9b180c7092ec8644777e75 Mon Sep 17 00:00:00 2001 From: Graham Neubig Date: Fri, 30 Aug 2024 12:33:58 -0400 Subject: [PATCH] More comprehensive messages (#44) --- github_resolver/resolve_issues.py | 5 ++++- github_resolver/send_pull_request.py | 11 +++++++---- tests/test_send_pull_request.py | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/github_resolver/resolve_issues.py b/github_resolver/resolve_issues.py index 3319af4..973b308 100644 --- a/github_resolver/resolve_issues.py +++ b/github_resolver/resolve_issues.py @@ -215,7 +215,10 @@ def guess_success(issue: GithubIssue, history: ShortTermHistory, llm_config: LLM Last message from AI agent: {last_message} -Has the issue been successfully resolved? Answer in JSON in the format {{success: bool, explanation: str}}.""" +(1) has the issue been successfully resolved? +(2) If the issue has been resolved, please provide an explanation of what was done in the PR that can be sent to a human reviewer on github. If the issue has not been resolved, please provide an explanation of why. + +Answer in JSON in the format {{success: bool, explanation: str}}.""" response = completion( model=llm_config.model, diff --git a/github_resolver/send_pull_request.py b/github_resolver/send_pull_request.py index 922b088..df3a128 100644 --- a/github_resolver/send_pull_request.py +++ b/github_resolver/send_pull_request.py @@ -122,6 +122,7 @@ def send_pull_request( patch_dir: str, pr_type: str, fork_owner: str | None = None, + additional_message: str | None = None, ) -> str: if pr_type not in ["branch", "draft", "ready"]: raise ValueError(f"Invalid pr_type: {pr_type}") @@ -169,10 +170,11 @@ def send_pull_request( raise RuntimeError("Failed to push changes to the remote repository") pr_title = f"Fix issue #{github_issue.number}: {github_issue.title}" - pr_body = ( - f"This pull request fixes #{github_issue.number}." - "\n\nAutomatic fix generated by [OpenHands](https://github.com/All-Hands-AI/OpenHands/)." - ) + pr_body = f"This pull request fixes #{github_issue.number}." + if additional_message: + pr_body += f"\n\n{additional_message}" + pr_body += "\n\nAutomatic fix generated by [OpenHands](https://github.com/All-Hands-AI/OpenHands/)." + # If we are not sending a PR, we can finish early and return the # URL for the user to open a PR manually @@ -231,6 +233,7 @@ def process_single_issue( patch_dir=patched_repo_dir, pr_type=pr_type, fork_owner=fork_owner, + additional_message=resolver_output.success_explanation, ) diff --git a/tests/test_send_pull_request.py b/tests/test_send_pull_request.py index a53aa57..c3f9063 100644 --- a/tests/test_send_pull_request.py +++ b/tests/test_send_pull_request.py @@ -416,6 +416,7 @@ def test_process_single_issue( patch_dir=f"{mock_output_dir}/patches/issue_1", pr_type=pr_type, fork_owner=None, + additional_message=resolver_output.success_explanation, )