mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-20 17:46:47 +00:00
Merge pull request #2 from hohyon-ryu/will_ryu-refactor
chore: add language option to action.yml and use it in createPrompt.ts
This commit is contained in:
commit
ac6d0e04ee
4 changed files with 11 additions and 2 deletions
3
.github/workflows/code_review.yml
vendored
3
.github/workflows/code_review.yml
vendored
|
@ -12,9 +12,10 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Code Review
|
- name: Code Review
|
||||||
uses: freeedcom/ai-codereviewer@main
|
uses: hohyon-ryu/ai-codereviewer@main
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
OPENAI_API_MODEL: "gpt-4-1106-preview"
|
||||||
exclude: "yarn.lock,dist/**"
|
exclude: "yarn.lock,dist/**"
|
||||||
|
language: "Korean"
|
||||||
|
|
|
@ -44,6 +44,7 @@ jobs:
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
|
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
|
||||||
exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas
|
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
|
4. Replace `your-username` with your GitHub username or organization name where the AI Code Reviewer repository is
|
||||||
|
|
|
@ -11,6 +11,10 @@ inputs:
|
||||||
description: "OpenAI API model."
|
description: "OpenAI API model."
|
||||||
required: false
|
required: false
|
||||||
default: "gpt-4"
|
default: "gpt-4"
|
||||||
|
language:
|
||||||
|
description: "Natural language for the code review comments."
|
||||||
|
required: false
|
||||||
|
default: "english"
|
||||||
exclude:
|
exclude:
|
||||||
description: "Glob patterns to exclude files from the diff analysis"
|
description: "Glob patterns to exclude files from the diff analysis"
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {Chunk, File} from "parse-diff";
|
import {Chunk, File} from "parse-diff";
|
||||||
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
export interface PRDetails {
|
export interface PRDetails {
|
||||||
owner: string;
|
owner: string;
|
||||||
|
@ -8,11 +9,13 @@ export interface PRDetails {
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const language: string = core.getInput("language") || 'English';
|
||||||
|
|
||||||
export function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
export function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
||||||
return `Your task is to review pull requests. Instructions:
|
return `Your task is to review pull requests. Instructions:
|
||||||
- Provide the response in following JSON format: {"reviews": [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]}
|
- Provide the response in following JSON format: {"reviews": [{"lineNumber": <line_number>, "reviewComment": "<review comment>"}]}
|
||||||
- Do not give positive comments or compliments.
|
- 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.
|
- 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.
|
- Write the comment in GitHub Markdown format.
|
||||||
- Use the given description only for the overall context and only comment the code.
|
- Use the given description only for the overall context and only comment the code.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue