mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-04-22 02:26:48 +00:00
Add support for desired language comments in PR
This commit is contained in:
parent
a9a064dfa1
commit
2b9cf1615c
3 changed files with 9 additions and 2 deletions
|
@ -42,6 +42,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
|
COMMENT_LANGUAGE: ${{ secrets.COMMENT_LANGUAGE }}
|
||||||
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
|
||||||
```
|
```
|
||||||
|
@ -51,7 +52,9 @@ jobs:
|
||||||
|
|
||||||
5. Customize the `exclude` input if you want to ignore certain file patterns from being reviewed.
|
5. Customize the `exclude` input if you want to ignore certain file patterns from being reviewed.
|
||||||
|
|
||||||
6. Commit the changes to your repository, and AI Code Reviewer will start working on your future pull requests.
|
6. Replace the `COMMENT_LANGUAGE` input if you want to add comments in your desired language.
|
||||||
|
|
||||||
|
7. Commit the changes to your repository, and AI Code Reviewer will start working on your future pull requests.
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ inputs:
|
||||||
description: "OpenAI API model."
|
description: "OpenAI API model."
|
||||||
required: false
|
required: false
|
||||||
default: "gpt-4"
|
default: "gpt-4"
|
||||||
|
COMMENT_LANGUAGE:
|
||||||
|
description: "input if you want to add comments in your desired language."
|
||||||
|
required: false
|
||||||
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
|
||||||
|
|
|
@ -8,6 +8,7 @@ import minimatch from "minimatch";
|
||||||
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
const GITHUB_TOKEN: string = core.getInput("GITHUB_TOKEN");
|
||||||
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
const OPENAI_API_KEY: string = core.getInput("OPENAI_API_KEY");
|
||||||
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
const OPENAI_API_MODEL: string = core.getInput("OPENAI_API_MODEL");
|
||||||
|
const COMMENT_LANGUAGE: string = core.getInput("COMMENT_LANGUAGE");
|
||||||
|
|
||||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ function createPrompt(file: File, chunk: Chunk, prDetails: PRDetails): string {
|
||||||
- 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.
|
||||||
- IMPORTANT: NEVER suggest adding comments to the code.
|
- IMPORTANT: NEVER suggest adding comments to the code.
|
||||||
|
${COMMENT_LANGUAGE ? `- Write the comments in ${COMMENT_LANGUAGE}.\n` : ''}
|
||||||
Review the following code diff in the file "${
|
Review the following code diff in the file "${
|
||||||
file.to
|
file.to
|
||||||
}" and take the pull request title and description into account when writing the response.
|
}" and take the pull request title and description into account when writing the response.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue