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 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..ae345a0 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") || 'English'; + 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.