Skip to content

Commit

Permalink
chore: flag translateLanguage is changed to flag reviewLanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanAsadov committed Oct 31, 2024
1 parent 215a72a commit 761a38d
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 22 deletions.
5 changes: 3 additions & 2 deletions action.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: 'gpt-4o'
TRANSLATE_LANGUAGE: 'English'
REVIEW_LANGUAGE: 'English'
```
### Workflow yml option 2: Add a code review bot
Expand Down Expand Up @@ -61,7 +61,8 @@ jobs:
- name: Code Review GPT
uses: mattzcarey/[email protected]
with:
GITHUB_TOKEN: ${{ github.token }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: 'gpt-4o'
GITHUB_TOKEN: ${{ github.token }}
REVIEW_LANGUAGE: 'English'
```
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
description: 'The GPT model to use'
required: true
default: 'gpt-4o'
TRANSLATE_LANGUAGE:
REVIEW_LANGUAGE:
description: 'Target natural language for translation'
required: false
default: 'English'
Expand All @@ -31,11 +31,11 @@ runs:

- name: Run Code Review GPT
shell: bash
run: npx code-review-gpt review --ci=github --model=$MODEL --translateLanguage=$TRANSLATE_LANGUAGE
run: npx code-review-gpt review --ci=github --model=$MODEL --reviewLanguage=$REVIEW_LANGUAGE

env:
MODEL: ${{ inputs.MODEL }}
TRANSLATE_LANGUAGE: ${{ inputs.TRANSLATE_LANGUAGE }}
REVIEW_LANGUAGE: ${{ inputs.REVIEW_LANGUAGE }}
OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion packages/code-review-gpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ You can now run `code-review-gpt review` in the root directory of any git-enable

- `--reviewType` - Used with the 'review' command. The options are --reviewType=("changed" | "full" | "costOptimized). Defaults to "changed" if no option is specified. Specifies whether the review is for the full file or just the changed lines. costOptimized limits the context surrounding the changed lines to 5 lines.

- `--translateLanguage` - Specifies the target natural language for translation, such as "German", "Spanish", or "French". Use this parameter to set the language in which the utility will provide output.
- `--reviewLanguage` - Specifies the target natural language for translation, such as "German", "Spanish", or "French". Use this parameter to set the language in which the utility will provide output.

- `--remote` - Used with the 'review' command. Usage `--remote=mattzcarey/code-review-gpt#96`. Review a remote GitHub Pull Request.

Expand Down
2 changes: 1 addition & 1 deletion packages/code-review-gpt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"start": "ts-node ./src/index.ts",
"review": "ts-node ./src/index.ts review",
"configure": "ts-node ./src/index.ts configure",
"test": "ts-node ./src/index.ts test",
"test": "ts-node ./src/index.ts test --reviewLanguage=Korean",
"test-unit": "dotenv -e .env jest",
"build": "node ./utils/build.js",
"postbuild": "node ./utils/shebang.js && chmod +x ./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/code-review-gpt/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const getYargs = async (): Promise<ReviewArgs> => {
type: "string",
default: "changed",
})
.option("translateLanguage", {
.option("reviewLanguage", {
description: "Specifies the target natural language for translation",
type: "string",
})
Expand Down
2 changes: 1 addition & 1 deletion packages/code-review-gpt/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type ReviewArgs = {
commentPerFile: boolean;
model: string;
reviewType: string;
translateLanguage: string | undefined;
reviewLanguage: string | undefined;
org: string | undefined;
remote: string | undefined;
provider: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/code-review-gpt/src/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const review = async (
const reviewType = yargs.reviewType;
const organization = yargs.org;
const provider = yargs.provider;
const translateLanguage = yargs.translateLanguage;
const reviewLanguage = yargs.reviewLanguage;

const filteredFiles = filterFiles(files);

Expand All @@ -56,7 +56,7 @@ export const review = async (
filteredFiles,
maxPromptLength,
reviewType,
translateLanguage
reviewLanguage
);

logger.debug(`Prompts used:\n ${prompts.toString()}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const constructPromptsArray = (
files: ReviewFile[],
maxPromptLength: number,
reviewType: string,
translateLanguage = 'English',
reviewLanguage = 'English',
): string[] => {
const maxPromptPayloadLength = maxPromptLength - instructionPrompt.length;
let promptPayloads: PromptFile[][];
Expand All @@ -36,7 +36,7 @@ export const constructPromptsArray = (

const languageToInstructionPrompt = instructionPrompt
.replace("{ProgrammingLanguage}", getLanguageName(files[0].fileName))
.replace("{TranslateLanguage}", translateLanguage);
.replace("{ReviewLanguage}", reviewLanguage);

const prompts = promptPayloads.map((payload) => {
return languageToInstructionPrompt + JSON.stringify(payload);
Expand Down
2 changes: 1 addition & 1 deletion packages/code-review-gpt/src/review/prompt/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Do not comment on breaking functions down into smaller, more manageable function
Use markdown formatting for the feedback details. Also do not include the filename or risk level in the feedback details.
Ensure the feedback details are brief, concise, accurate, and in {TranslateLanguage}. If there are multiple similar issues, only comment on the most critical.
Ensure the feedback details are brief, concise, accurate, and in {ReviewLanguage}. If there are multiple similar issues, only comment on the most critical.
Include brief example code snippets in the feedback details for your suggested changes when you're confident your suggestions are improvements. Use the same programming language as the file under review.
If there are multiple improvements you suggest in the feedback details, use an ordered list to indicate the priority of the changes.
Expand Down
4 changes: 2 additions & 2 deletions packages/code-review-gpt/src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { loadOrGenerateCodeSnippets } from "./load/loadTestCodeSnippets";
import { runTests } from "./run/runTest";

export const test = async (
{ ci, model, reviewType, translateLanguage }: ReviewArgs,
{ ci, model, reviewType, reviewLanguage }: ReviewArgs,
openAIApiKey: string
): Promise<void> => {
const maxPromptLength = getMaxPromptLength(model);
Expand Down Expand Up @@ -46,7 +46,7 @@ export const test = async (
maxPromptLength,
vectorStore,
reviewType,
translateLanguage,
reviewLanguage,
);

if (ci === PlatformOptions.GITHUB) {
Expand Down
12 changes: 6 additions & 6 deletions packages/code-review-gpt/src/test/run/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
* @param maxPromptLength The maximum prompt length.
* @param vectorStore The vector store.
* @param reviewType The review type.
* @param translateLanguage Target natural language for translation.
* @param reviewLanguage Target natural language for translation.
* @returns The test result.
*/
const runTest = async (
Expand All @@ -29,7 +29,7 @@ const runTest = async (
maxPromptLength: number,
vectorStore: MemoryVectorStore,
reviewType: string,
translateLanguage?: string,
reviewLanguage?: string,
// eslint-disable-next-line max-params
): Promise<testResult> => {
if (!testCase.snippet) {
Expand All @@ -43,7 +43,7 @@ const runTest = async (
[testCase.snippet],
maxPromptLength,
reviewType,
translateLanguage
reviewLanguage
);

const { markdownReport: reviewResponse } = await askAI(
Expand Down Expand Up @@ -85,7 +85,7 @@ const runTest = async (
* @param maxPromptLength The maximum prompt length.
* @param vectorStore The vector store.
* @param reviewType The review type.
* @param translateLanguage Target natural language for translation.
* @param reviewLanguage Target natural language for translation.
* @returns The test results.
*/
export const runTests = async (
Expand All @@ -95,7 +95,7 @@ export const runTests = async (
maxPromptLength: number,
vectorStore: MemoryVectorStore,
reviewType: string,
translateLanguage?: string,
reviewLanguage?: string,
// eslint-disable-next-line max-params
): Promise<string> => {
if (testCases.length === 0) {
Expand All @@ -116,7 +116,7 @@ export const runTests = async (
maxPromptLength,
vectorStore,
reviewType,
translateLanguage
reviewLanguage
);
testResults[testCase.name] = result;
} catch (error) {
Expand Down

0 comments on commit 761a38d

Please sign in to comment.