File tree Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " code-review-gpt" ,
3
- "version" : " 0.0.14 " ,
3
+ "version" : " 0.0.15 " ,
4
4
"description" : " Your AI code reviewer" ,
5
5
"bin" : {
6
6
"code-review-gpt" : " ./dist/index.js"
Original file line number Diff line number Diff line change 1
1
import { OpenAIChat } from "langchain/llms/openai" ;
2
- import { completionPrompt } from "./constants" ;
2
+ import { completionPrompt , signOff } from "./constants" ;
3
3
import { openAIApiKey } from "./args" ;
4
4
5
5
const model = new OpenAIChat ( {
@@ -18,7 +18,9 @@ const createSummary = async (feedbacks: string[]): Promise<string> => {
18
18
feedbacks . join ( "\n---\n" )
19
19
) ;
20
20
21
- const summary = await callModel ( finalPrompt ) ;
21
+ const emojis = await callModel ( finalPrompt ) ;
22
+
23
+ const summary = `\n${ emojis } ${ signOff } ` ;
22
24
console . log ( summary ) ;
23
25
24
26
return summary ;
@@ -44,7 +46,6 @@ export const askAI = async (prompts: string[]): Promise<string> => {
44
46
}
45
47
} ;
46
48
47
-
48
49
await Promise . allSettled ( feedbackPromises . map ( collectAndLogFeedback ) ) ;
49
50
const summary = await createSummary ( feedbacks ) ;
50
51
Original file line number Diff line number Diff line change 1
1
import { context , getOctokit } from "@actions/github" ;
2
2
import { getGitHubEnvVariables } from "./args" ;
3
3
4
+ const getToken = ( ) => {
5
+ const { githubToken } = getGitHubEnvVariables ( ) ;
6
+ if ( ! githubToken ) {
7
+ throw new Error ( "GITHUB_TOKEN is not set" ) ;
8
+ }
9
+ return githubToken ;
10
+ } ;
11
+
4
12
export const commentOnPR = async ( comment : string ) => {
5
13
try {
6
- const { githubToken } = getGitHubEnvVariables ( ) ;
14
+ const githubToken = getToken ( ) ;
7
15
const { payload, issue } = context ;
8
16
9
- if ( ! githubToken ) {
10
- throw new Error ( "GITHUB_TOKEN is not set" ) ;
11
- }
12
-
13
-
14
17
if ( ! payload . pull_request ) {
15
18
console . warn ( "Not a pull request. Skipping commenting on PR..." ) ;
16
19
return ;
17
20
}
18
21
19
22
const octokit = getOctokit ( githubToken ) ;
23
+
20
24
const { owner, repo, number : pull_number } = issue ;
21
25
22
26
await octokit . rest . issues . createComment ( {
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ You are a senior developer and have just reviewed a pull request. This was your
25
25
Please summarise the review using 3 emojis.
26
26
` ;
27
27
28
+ export const signOff = `\n---\n#### Powered by [Code Review GPT](https://github.com/mattzcarey/code-review-gpt)` ;
29
+
28
30
export const maxPromptLength = 30000 ; //max is 8k tokens which is about 40k characters
29
31
30
32
export const supportedFiles = new Set ( [
You can’t perform that action at this time.
0 commit comments