From cf3ec6c3e2514250e08d3503988512a1274271d6 Mon Sep 17 00:00:00 2001 From: Will Hohyon Ryu Date: Thu, 7 Mar 2024 19:24:32 -0800 Subject: [PATCH 1/3] chore: add language option to action.yml and use it in createPrompt.ts --- action.yml | 4 ++++ src/createPrompt.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 976aed7..b4619d9 100644 --- a/action.yml +++ b/action.yml @@ -11,6 +11,10 @@ inputs: description: "OpenAI API model." required: false default: "gpt-4" + language: + description: "Natural language for the code review comments." + required: false + default: "english" exclude: description: "Glob patterns to exclude files from the diff analysis" required: false diff --git a/src/createPrompt.ts b/src/createPrompt.ts index d5fd302..5d4abdc 100644 --- a/src/createPrompt.ts +++ b/src/createPrompt.ts @@ -1,4 +1,5 @@ import {Chunk, File} from "parse-diff"; +import * as core from "@actions/core"; export interface PRDetails { owner: string; @@ -8,11 +9,13 @@ export interface PRDetails { description: string; } +const language: string = core.getInput("language"); + export function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string { return `Your task is to review pull requests. Instructions: - Provide the response in following JSON format: {"reviews": [{"lineNumber": , "reviewComment": ""}]} - Do not give positive comments or compliments. -- Provide review in Korean language. +- Provide review in ${language} language. - Provide comments and suggestions ONLY if there is something to improve, otherwise "reviews" should be an empty array. - Write the comment in GitHub Markdown format. - Use the given description only for the overall context and only comment the code. From 5d1160716dbc193a84ca6718e010ff87ef2078d1 Mon Sep 17 00:00:00 2001 From: Will Hohyon Ryu Date: Thu, 7 Mar 2024 19:28:57 -0800 Subject: [PATCH 2/3] chore: Update code_review.yml and README.md with language options for AI Code Reviewer plugin --- .github/workflows/code_review.yml | 3 ++- README.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_review.yml b/.github/workflows/code_review.yml index 3edcf77..02b15e4 100644 --- a/.github/workflows/code_review.yml +++ b/.github/workflows/code_review.yml @@ -12,9 +12,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - name: Code Review - uses: freeedcom/ai-codereviewer@main + uses: hohyon-ryu/ai-codereviewer@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_MODEL: "gpt-4-1106-preview" exclude: "yarn.lock,dist/**" + language: "Korean" diff --git a/README.md b/README.md index 566a3ea..aa454a5 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4" exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas + language: "english" # Optional: defaults to "english" ``` 4. Replace `your-username` with your GitHub username or organization name where the AI Code Reviewer repository is From c6390a649cf3a2ae8fbb86609276c19267c8554b Mon Sep 17 00:00:00 2001 From: Will Hohyon Ryu Date: Thu, 7 Mar 2024 19:30:47 -0800 Subject: [PATCH 3/3] chore(createPrompt): add default language value for user input --- src/createPrompt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/createPrompt.ts b/src/createPrompt.ts index 5d4abdc..ae345a0 100644 --- a/src/createPrompt.ts +++ b/src/createPrompt.ts @@ -9,7 +9,7 @@ export interface PRDetails { description: string; } -const language: string = core.getInput("language"); +const language: string = core.getInput("language") || 'English'; export function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string { return `Your task is to review pull requests. Instructions: