kikocis/auto-code-rover public
Changesets · Branches · Tags · Compare
| Changeset | fd06fcc9577a72e68f9c15cc94cd3f0893004d3c7e1191561e2bee506e4da02b |
|---|---|
| Author | Martin Mirchev <mirchevmartin2203@gmail.com> · 2024-09-10 12:23 +08:00 |
| Committer | Martin Mirchev <mirchevmartin2203@gmail.com> · 2024-09-10 12:23 +08:00 |
| Parents | c354dbc7a0ea |
3 files changed
modified app/main.py +12 −1
| @@ -106,7 +106,12 @@ | ||
| 106 | 106 | setup_dir = abspath(setup_dir) |
| 107 | 107 | |
| 108 | 108 | task = RawGithubTask( |
| 109 | - args.task_id, args.clone_link, args.commit_hash, args.issue_link, setup_dir | |
| 109 | + args.task_id, | |
| 110 | + args.clone_link, | |
| 111 | + args.commit_hash, | |
| 112 | + args.issue_link, | |
| 113 | + setup_dir, | |
| 114 | + args.use_comments, | |
| 110 | 115 | ) |
| 111 | 116 | groups = {"github": [task]} |
| 112 | 117 | run_task_groups(groups, num_processes) |
| @@ -160,6 +165,12 @@ | ||
| 160 | 165 | type=str, |
| 161 | 166 | help="The commit hash to checkout. If not specified, the latest commit on default branch will be used.", |
| 162 | 167 | ) |
| 168 | + parser.add_argument( | |
| 169 | + "--use-comments", | |
| 170 | + action="store_true", | |
| 171 | + default=False, | |
| 172 | + help="Include the comments of the issue.", | |
| 173 | + ) | |
| 163 | 174 | parser.add_argument("--issue-link", type=str, help="The link to the issue.") |
| 164 | 175 | parser.add_argument( |
| 165 | 176 | "--setup-dir", |
modified app/model/common.py +1 −1
| @@ -206,7 +206,7 @@ | ||
| 206 | 206 | completion_tokens=completion_tokens, |
| 207 | 207 | ) |
| 208 | 208 | ) |
| 209 | - litellm.set_verbose = True | |
| 209 | + # litellm.set_verbose = True | |
| 210 | 210 | SELECTED_MODEL = LiteLLMGeneric( |
| 211 | 211 | real_model_name, |
| 212 | 212 | prompt_tokens_cost_usd_dollar, |
modified app/raw_tasks.py +33 −6
| @@ -95,6 +95,7 @@ | ||
| 95 | 95 | commit_hash: str | None, |
| 96 | 96 | issue_link: str, |
| 97 | 97 | setup_dir: str, |
| 98 | + use_comments: bool = False, | |
| 98 | 99 | ): |
| 99 | 100 | self._task_id = task_id |
| 100 | 101 | self.clone_link = clone_link |
| @@ -102,6 +103,7 @@ | ||
| 102 | 103 | self.commit_hash = commit_hash |
| 103 | 104 | self.issue_link = issue_link |
| 104 | 105 | self.setup_dir = setup_dir |
| 106 | + self.use_comments = use_comments | |
| 105 | 107 | self.clone_path = pjoin(self.setup_dir, self.task_id) |
| 106 | 108 | self.problem_statement, self.created_at = self.fetch_issue() |
| 107 | 109 | self.clone_repo() |
| @@ -144,7 +146,7 @@ | ||
| 144 | 146 | if "github.com" not in self.issue_link: |
| 145 | 147 | raise NotImplementedError("Only GitHub issues are supported for now.") |
| 146 | 148 | |
| 147 | - retrieved_issue = self.fetch_github_issue(self.issue_link) | |
| 149 | + retrieved_issue = self.fetch_github_issue(self.issue_link, self.use_comments) | |
| 148 | 150 | |
| 149 | 151 | if retrieved_issue is None: |
| 150 | 152 | raise RuntimeError( |
| @@ -185,7 +187,9 @@ | ||
| 185 | 187 | return body |
| 186 | 188 | |
| 187 | 189 | @classmethod |
| 188 | - def fetch_github_issue(cls, issue_url: str) -> tuple[str, str, str]: | |
| 190 | + def fetch_github_issue( | |
| 191 | + cls, issue_url: str, use_comments: bool = False | |
| 192 | + ) -> tuple[str, str, str]: | |
| 189 | 193 | """Extract owner, repo, and issue number from the URL""" |
| 190 | 194 | |
| 191 | 195 | # Example issue URL: https://github.com/owner/repo/issues/123 |
| @@ -193,17 +197,40 @@ | ||
| 193 | 197 | _, owner, repo, _, issue_number = issue_url.rsplit("/", 4) |
| 194 | 198 | |
| 195 | 199 | api_url = f"https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}" |
| 196 | - response = httpx.get(api_url) | |
| 200 | + comments_url = f"https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/comments" | |
| 197 | 201 | |
| 198 | - if response.status_code != 200: | |
| 202 | + issue_response = httpx.get(api_url) | |
| 203 | + | |
| 204 | + if issue_response.status_code != 200: | |
| 199 | 205 | raise RuntimeError( |
| 200 | - f"Failed to fetch issue information: {response.status_code}" | |
| 206 | + f"Failed to fetch issue information: {issue_response.status_code}" | |
| 201 | 207 | ) |
| 202 | 208 | |
| 203 | - issue_info = response.json() | |
| 209 | + issue_info = issue_response.json() | |
| 204 | 210 | |
| 205 | 211 | title = issue_info["title"] |
| 206 | 212 | body = issue_info["body"] |
| 213 | + | |
| 214 | + if use_comments: | |
| 215 | + comments_response = httpx.get(comments_url) | |
| 216 | + if comments_response.status_code != 200: | |
| 217 | + raise RuntimeError( | |
| 218 | + f"Failed to fetch comments information: {comments_response.status_code}" | |
| 219 | + ) | |
| 220 | + | |
| 221 | + comments_info = comments_response.json() | |
| 222 | + for comment in comments_info: | |
| 223 | + if ( | |
| 224 | + "user" not in comment | |
| 225 | + or comment["user"]["type"] == "Bot" | |
| 226 | + or comment["user"]["login"] == "acr-bot" | |
| 227 | + ): | |
| 228 | + continue | |
| 229 | + | |
| 230 | + body += ( | |
| 231 | + f"\nUser: {comment['user']['login']}\nComment: {comment['body']}" | |
| 232 | + ) | |
| 233 | + | |
| 207 | 234 | created_at = issue_info["created_at"] |
| 208 | 235 | |
| 209 | 236 | return title, body, created_at |