Skip to content

Commit

Permalink
feat: add max_tokens params
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuel-braz committed Nov 8, 2023
1 parent 4ea08b5 commit 28f6c09
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/code-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
5 changes: 4 additions & 1 deletion code-review/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions code-review/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 28f6c09

Please sign in to comment.