diff --git a/README.md b/README.md index fb7a0b64..b735dbaf 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull ‣ **Code Suggestions (`/improve`)**: [Committable code suggestions](https://github.com/Codium-ai/pr-agent/pull/229#discussion_r1306919276) for improving the PR. \ ‣ **Update Changelog (`/update_changelog`)**: Automatically updating the CHANGELOG.md file with the [PR changes](https://github.com/Codium-ai/pr-agent/pull/168#discussion_r1282077645). +\ +‣ **Find similar issue (`/similar_issue`)**: Automatically retrieves and presents [similar issues](https://github.com/Alibaba-MIIL/ASL/issues/107). See the [usage guide](./Usage.md) for instructions how to run the different tools from [CLI](./Usage.md#working-from-a-local-repo-cli), or by [online usage](./Usage.md#online-usage), as well as additional details on optional commands and configurations. @@ -105,6 +107,7 @@ See the [usage guide](./Usage.md) for instructions how to run the different tool | | ⮑ Extended | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | Reflect and Review | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | Update CHANGELOG.md | :white_check_mark: | | :white_check_mark: | | | | +| | Find similar issue | :white_check_mark: | | | | | | | | | | | | | | | USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | App / webhook | :white_check_mark: | :white_check_mark: | | | | @@ -182,7 +185,7 @@ Here are some advantages of PR-Agent: - [x] Support additional models, as a replacement for OpenAI (see [here](https://github.com/Codium-ai/pr-agent/pull/172)) - [x] Develop additional logic for handling large PRs (see [here](https://github.com/Codium-ai/pr-agent/pull/229)) - [ ] Add additional context to the prompt. For example, repo (or relevant files) summarization, with tools such a [ctags](https://github.com/universal-ctags/ctags) -- [ ] PR-Agent for issues, and just for pull requests +- [x] PR-Agent for issues - [ ] Adding more tools. Possible directions: - [x] PR description - [x] Inline code suggestions diff --git a/Usage.md b/Usage.md index 03b5f54b..b728b0bb 100644 --- a/Usage.md +++ b/Usage.md @@ -247,4 +247,26 @@ And use the following settings (you have to replace the values) in .secrets.toml [azure_devops] org = "https://dev.azure.com/YOUR_ORGANIZATION/" pat = "YOUR_PAT_TOKEN" -``` \ No newline at end of file +``` + +#### Similar issue tool + +Example usage: + + + +To enable usage of the '**similar issue**' tool, you need to set the following keys in `.secrets.toml` (or in the relevant environment variables): +``` +[pinecone] +api_key = "..." +environment = "..." +``` +These parameters can be obtained by registering to [Pinecone](https://app.pinecone.io/?sessionType=signup/). + +- To invoke the 'similar issue' tool from **CLI**, run: +`python3 cli.py --issue_url=... similar_issue` + +- To invoke the 'similar' issue tool via online usage, [comment](https://github.com/Codium-ai/pr-agent/issues/178#issuecomment-1716934893) on a PR: +`/similar_issue` + +- You can also enable the 'similar issue' tool to run automatically when a new issue is opened, by adding it to the [pr_commands list in the github_app section](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L66) \ No newline at end of file diff --git a/pics/debugger.png b/pics/debugger.png deleted file mode 100644 index 7d8f201f..00000000 Binary files a/pics/debugger.png and /dev/null differ diff --git a/pics/similar_issue_tool.png b/pics/similar_issue_tool.png new file mode 100644 index 00000000..4ec51c81 Binary files /dev/null and b/pics/similar_issue_tool.png differ diff --git a/pr_agent/tools/pr_similar_issue.py b/pr_agent/tools/pr_similar_issue.py index 1042c3ea..d7b6a799 100644 --- a/pr_agent/tools/pr_similar_issue.py +++ b/pr_agent/tools/pr_similar_issue.py @@ -114,21 +114,30 @@ class PRSimilarIssue: filter={"repo": self.repo_name_for_index}, include_metadata=True).to_dict() relevant_issues_number_list = [] + relevant_comment_number_list = [] + score_list = [] for r in res['matches']: issue_number = int(r["id"].split('.')[0].split('_')[-1]) if original_issue_number == issue_number: continue if issue_number not in relevant_issues_number_list: relevant_issues_number_list.append(issue_number) + if 'comment' in r["id"]: + relevant_comment_number_list.append(int(r["id"].split('.')[1].split('_')[-1])) + else: + relevant_comment_number_list.append(-1) + score_list.append(str("{:.2f}".format(r['score']))) logging.info('Done') logging.info('Publishing response...') - similar_issues_str = "Similar Issues:\n\n" + similar_issues_str = "### Similar Issues\n___\n\n" for i, issue_number_similar in enumerate(relevant_issues_number_list): issue = self.git_provider.repo_obj.get_issue(issue_number_similar) title = issue.title url = issue.html_url - similar_issues_str += f"{i + 1}. [{title}]({url})\n\n" + if relevant_comment_number_list[i] != -1: + url = list(issue.get_comments())[relevant_comment_number_list[i]].html_url + similar_issues_str += f"{i + 1}. **[{title}]({url})** (score={score_list[i]})\n\n" if get_settings().config.publish_output: response = issue_main.create_comment(similar_issues_str) logging.info(similar_issues_str)