-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add experimental AI PR review #187
Conversation
3c516d0
to
e62488f
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
==========================================
- Coverage 98.34% 98.30% -0.04%
==========================================
Files 376 380 +4
Lines 28088 28366 +278
==========================================
+ Hits 27622 27886 +264
- Misses 466 480 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
This change has been scanned for critical changes. Learn more |
Codecov Report
@@ Coverage Diff @@
## main #187 +/- ##
==========================================
- Coverage 98.37% 98.34% -0.04%
==========================================
Files 347 351 +4
Lines 27443 27721 +278
==========================================
+ Hits 26998 27262 +264
- Misses 445 459 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
==========================================
- Coverage 98.37% 98.34% -0.04%
==========================================
Files 347 351 +4
Lines 27443 27721 +278
==========================================
+ Hits 26998 27262 +264
- Misses 445 459 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid. Interesting project, excited to see what comes out of it.
|
||
async def fetch_diff(self) -> str: | ||
async with self.torngit.get_client() as client: | ||
diff = await self.torngit.api( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you decided to implement this here instead of in torngit.
It's the same request from get_pull_request
(but I think you are using more of the data)
I understand that this feature is experimental so I think it's better to keep it as self-contained as possible. I'm not asking you to change anything, just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference here is the Accept
header below. By passing that header, GitHub will return the raw Git patch (which you can also get while logged in by appending .diff
to the end of a normal PR URL).
|
||
try: | ||
data = json.loads(res) | ||
except json.decoder.JSONDecodeError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have metrics for these errors so we can track how successful this thing is (in terms of delivering any response, obviously it wouldn't measure how effective the response is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 3de8687
Thanks for the review @giovanni-guidini! Would you mind taking a quick look at codecov/shared#87 as well so I can get the EDIT: nevermind - @joseph-sentry did it - thanks! |
Enable the feature in your
codecov.yml
and you'll start receiving GPT-4 powered PR reviews. The YAML is checked in thePullSyncTask
and, if that feature is enabled, then it spins off a newAiPrReviewTask
which handles the interactions with GitHub and OpenAI. This is GitHub only right now since the PR review API is a bit specific to GitHub (it's commenting on specific lines on code).The GPT-4 prompt could probably use a lot of work as I have very little experience with this. It's currently only passing in the Git patch and the comments received back from the OpenAI API have been somewhat lackluster. Providing additional context about the codebase could potentially help here but is out-of-scope for this initial POC.
Depends on codecov/shared#87 for the YAML schema update
TODO: updateshared
SHA once the PR linked above has been merged tomain