-
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
Validation of pull requests using OpenAI #310
Conversation
…lidation by AI based on the response there will be left review and comment within PR
for (GHPullRequestCommitDetail commitDetail : | ||
pullRequest.listCommits().toList() | ||
.stream().filter(commit -> !commit.getCommit() | ||
.getAuthor().getName().equals("github-classroom[bot]")) |
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.
Extract please those huge parts of code to separate variables, and format the identation to make it bit more readable
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.
Extracted lists to separate variables
throw new RuntimeException(e); | ||
} | ||
} catch (JsonProcessingException exception) { | ||
requests.add(process); |
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 add explanation, why we are doing this
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 explanation to the Javadoc
GHRepository repository; | ||
try { | ||
repository = getGitHubConnection().getRepository(nameRepository); | ||
repository = getGitHubConnection().getRepository(repositoryName); |
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.
Try placing return statement here, so there is no need in repository variable.
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.
Removed variable to return repository on the spot
.stream().filter(Objects::nonNull).collect(Collectors.toList())) { | ||
fileList.add(new CommitFileDto(file.getFileName(), file.getPatch())); | ||
} | ||
String prompt = "Provide me with the code review where you point out lines of code " |
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.
Extract prompt to static final field
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.
Extracted to the prompt template variable
+ "The code will be provided in JSON format as " | ||
+ "[{filename: ${filename}, code: ${code}}]. Ignore git patch headers. " | ||
+ "The code to rate is:" | ||
+ objectMapper.writeValueAsString(fileList) |
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.
This you can replace with %s, then, when using prompt, use String.format()
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.
Used String.format() instead
…template variable. To create prompt used string format instead. Removed repository variable in the getGitHubRepositoryByName method to return it on the spot.
…dded explanation of JsonProcessingException to the Javadoc
public void validatePullRequest(String repositoryName) { | ||
GHRepository repository = gitService.getGitHubRepositoryByName(repositoryName); | ||
try { | ||
GHPullRequest pullRequest = repository.getPullRequest(1); |
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.
how should it work if we have 2 PR's opened?
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.
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.
Should we look for some specific PR or it always on the first place?
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.
Since we generate feedback PR with classroom repository it always will be by id 1
There has been created a service that validates PR with the help of OpenAi. After the validation there will be a review left based on the AI response and user will be notified as there are results. Notification logic will be added after it is merged.
The task