Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit d3d4126

Browse files
committed
don't send large files or diffs
1 parent bd9fc77 commit d3d4126

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,10 @@ inputs:
9090
default: |
9191
Next, I will send you a series of patches, each of them consists
9292
of a snippet, and you need to do a brief code review for every message, and tell me any
93-
bug risk and improvement suggestion. If the patch is looks good and acceptable, please
93+
bug risk or improvement suggestion. If the patch is looks good and acceptable, please
9494
reply "LGTM!" with a short comment with 30 words.
9595
96-
Your answer should be concise. Don't include the diff in your comment, and markdown
97-
format is preferred. Reply "OK" to confirm.
96+
Markdown format is preferred for your response. Reply "OK" to confirm.
9897
review_patch:
9998
required: false
10099
description: 'The prompt for each chunks/patches'

dist/index.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/review.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export const codeReview = async (
3737
if (context.payload.pull_request.body) {
3838
inputs.description = context.payload.pull_request.body
3939
}
40+
// as gpt-3.5-turbo isn't paying attention to system message, add to inputs for now
41+
inputs.system_message = options.system_message
4042

4143
// collect diff chunks
4244
const diff = await octokit.repos.compareCommits({
@@ -100,9 +102,6 @@ export const codeReview = async (
100102
if (files_to_review.length > 0) {
101103
const commenter: Commenter = new Commenter()
102104

103-
// as gpt-3.5-turbo isn't paying attention to system message, add to inputs for now
104-
inputs.system_message = options.system_message
105-
106105
const [, review_begin_ids] = await bot.chat(
107106
prompts.render_review_beginning(inputs),
108107
{}
@@ -122,10 +121,13 @@ export const codeReview = async (
122121
patches
123122
] of files_to_review) {
124123
inputs.filename = filename
125-
// reset session for each file while reviewing
124+
inputs.file_content = file_content
125+
inputs.file_diff = file_diff
126+
127+
// reset chat session for each file while reviewing
126128
next_review_ids = review_begin_ids
127-
if (file_content.length > 0) {
128-
inputs.file_content = file_content
129+
130+
if (file_content.length > 0 && file_content.length < 3000) {
129131
// review file
130132
const [resp, review_file_ids] = await bot.chat(
131133
prompts.render_review_file(inputs),
@@ -138,8 +140,7 @@ export const codeReview = async (
138140
}
139141
}
140142

141-
if (file_diff.length > 0) {
142-
inputs.file_diff = file_diff
143+
if (file_diff.length > 0 && file_diff.length < 3000) {
143144
// review diff
144145
const [resp, review_diff_ids] = await bot.chat(
145146
prompts.render_review_file_diff(inputs),

0 commit comments

Comments
 (0)