Skip to content

Commit

Permalink
feat(#87): post if not excellent
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed May 10, 2024
1 parent a4c8522 commit d2eba16
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 28 deletions.
87 changes: 66 additions & 21 deletions src/main/java/git/tracehub/codereview/action/AnalysisRoutine.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@
import git.tracehub.codereview.action.deep.CompleteJson;
import git.tracehub.codereview.action.deep.DeepInfraRequest;
import git.tracehub.codereview.action.deep.DeepModel;
import git.tracehub.codereview.action.deep.Model;
import git.tracehub.codereview.action.deep.Simple;
import git.tracehub.codereview.action.github.FeedbackInPull;
import git.tracehub.codereview.action.github.FixedReviews;
import git.tracehub.codereview.action.github.GhRequest;
import git.tracehub.codereview.action.github.JsonReviews;
import git.tracehub.codereview.action.github.PullChanges;
import git.tracehub.codereview.action.github.StartWithNickname;
import git.tracehub.codereview.action.github.WithScore;
import git.tracehub.codereview.action.github.WithComments;
import git.tracehub.codereview.action.prompt.AnalysisPrompt;
import git.tracehub.codereview.action.prompt.SuggestionPrompt;
import git.tracehub.codereview.action.prompt.SystemPrompt;
import git.tracehub.codereview.action.prompt.TextChanges;
import git.tracehub.codereview.action.prompt.TextPull;
import git.tracehub.codereview.action.prompt.TextReviews;
import java.util.Locale;
import javax.json.JsonArray;
import lombok.RequiredArgsConstructor;
import org.cactoos.BiProc;
Expand Down Expand Up @@ -84,28 +89,68 @@ public void exec(final Pull pull, final String model) throws Exception {
new TextReviews(reviews)
).asString();
Logger.info(this, "compiled user prompt: %s", prompt);
new FeedbackInPull(
new StartWithNickname(
this.approver,
new AnalyzedWith(
new DeepModel(
new DeepInfraRequest(
this.deepinfra,
new CompleteJson(
new Simple(
model,
0.7,
512
),
system,
prompt
)
)
final Model analysis = new DeepModel(
new DeepInfraRequest(
this.deepinfra,
new CompleteJson(
new Simple(
model,
0.7,
512
),
model
system,
prompt
)
),
pull
).deliver();
)
);
final String score = analysis.completion();
Logger.info(this, "Suggested review score is %s", score);
if (score.toLowerCase(Locale.ROOT).contains("excellent")) {
new FeedbackInPull(
new StartWithNickname(
this.approver,
new AnalyzedWith(
analysis,
model
)
),
pull
).deliver();
} else {
new FeedbackInPull(
new StartWithNickname(
this.approver,
new WithScore(
new AnalyzedWith(
new DeepModel(
new DeepInfraRequest(
this.deepinfra,
new CompleteJson(
new Simple(
model,
0.7,
512
),
system,
new SuggestionPrompt(
new TextReviews(reviews),
new TextPull(
pull,
new TextChanges(
new PullChanges(pull)
)
)
).asString()
)
)
),
model
),
score
)
),
pull
).deliver();
}
}
}
8 changes: 1 addition & 7 deletions src/test/java/it/AnalysisRoutineITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
/**
* Integration test case for {@link AnalysisRoutine}.
*
* @since 0.0.0
* @since 0.1.23
*/
final class AnalysisRoutineITCase {

Expand All @@ -59,12 +59,6 @@ void analyzesCodeReview() throws Exception {
.get(new Coordinates.Simple("h1alexbel/test"))
.pulls()
.get(783);
pull.comments().post(
"nice, I liked that!",
"24bb9d7c34ab84f69752c41a84b9059ef39c9c89",
".trace/jobs/test-for-response-with-new-pull-request.yml",
1
);
final String approver = "h1alexbel";
new AnalysisRoutine(token, approver, deep).exec(pull, model);
final String posted = new Comment.Smart(
Expand Down

0 comments on commit d2eba16

Please sign in to comment.