diff --git a/.github/workflows/code-review.yaml b/.github/workflows/code-review.yaml index e35666a..faeea9c 100644 --- a/.github/workflows/code-review.yaml +++ b/.github/workflows/code-review.yaml @@ -21,6 +21,8 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} openai_key: ${{ secrets.OPENAI_KEY }} + max_tokens: 900 exclude: "**/*.json, **/*.md, **/*.g.dart" append_prompt: | + - Give a minimum of 0 suggestions and a maximum of 5 suggestions. - Translate the comment in all "reviewComment" properties to portuguese (pt-br). \ No newline at end of file diff --git a/code-review/action.js b/code-review/action.js index 11460da..7ed435b 100644 --- a/code-review/action.js +++ b/code-review/action.js @@ -19,6 +19,7 @@ const OPENAI_API_KEY = core.getInput("openai_key"); const OPENAI_API_MODEL = core.getInput("openai_key_model"); const overridePrompt = core.getInput("override_prompt"); const appendPrompt = core.getInput("append_prompt"); +const maxTokens = core.getInput("max_tokens"); const excludePatterns = core .getInput("exclude") .split(",") @@ -132,12 +133,14 @@ ${chunk.changes async function getAIResponse(messages) { + logger.log(`Max tokens: ${maxTokens}`); + try { const chatCompletionParams = new ChatCompletionParams({ messages: messages, model: OPENAI_API_MODEL, temperature: 0, - max_tokens: 900, + max_tokens: parseInt(maxTokens), top_p: 1, frequency_penalty: 0, presence_penalty: 0, diff --git a/code-review/action.yml b/code-review/action.yml index 91fbcb4..771dafa 100644 --- a/code-review/action.yml +++ b/code-review/action.yml @@ -15,6 +15,10 @@ inputs: description: "OpenAI API model." required: false default: "gpt-3.5-turbo" + max_tokens: + description: "OpenAI API max tokens." + default: "900" + required: false exclude: description: "Glob patterns to exclude files from the diff analysis" required: false