anc95 / ChatGPT-CodeReview

🐥 A code review bot powered by ChatGPT
https://github.com/apps/cr-gpt
ISC License
3.77k stars 360 forks source link

max_token & API key #139

Closed kangjehun closed 4 months ago

kangjehun commented 4 months ago

Thank you for sharing your useful code. I encountered two issues while using your code:

Firstly, following the readme.md in your GitHub repository led to an error. Specifically, an error occurred stating that the model's maximum token count of 4096 was exceeded when max_tokens was set to 10,000. This seems to be the maximum token count for the gpt-3.5-turbo model. I resolved this issue by updating to the latest git action settings (name, uses) and modifying max_tokens to 4000.

Secondly, I have a question: the yaml file mentions using OPENAI_API_KEY as secrets.OPENAI_API_KEY, but I'm curious why the key needs to be placed in the repository variables instead of as a secret.

I'm not familiar with the git community and using the gpt app, so I'm not sure if sharing information here in the issue is correct. If there's anything wrong, I would appreciate your guidance.

Below is the cr.yaml file I used. I'm sharing this in case it helps others who might encounter similar issues.


name: ChatGPT CodeReviewer

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
test:
# if: ${{ contains(github.event..labels..name, 'gpt review') }} # Optional; to run only when a label is attached
runs-on: ubuntu-latest
steps:
- uses: anc95/ChatGPT-CodeReview@v1.0.12
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Optional
LANGUAGE: Korean
OPENAI_API_ENDPOINT: https://api.openai.com/v1
MODEL: gpt-3.5-turbo # https://platform.openai.com/docs/models
PROMPT: Please check if there are any confusions or irregularities in the following code diff
top_p: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p
temperature: 1 # https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature
max_tokens: 4000
MAX_PATCH_LENGTH: 10000 # if the patch/diff length is larger than MAX_PATCH_LENGTH, it will be ignored and won't be reviewed. By default, with no MAX_PATCH_LENGTH set, there is also no limit for the patch/diff length."

anc95 commented 4 months ago

HI @kangjehun first one, you could use gpt-3.5-turbo-16k to have more context. second one, there are two ways to use this code review, 1. GitHub Bot (As the limit by GitHub API, bot can't access the content in secrets, so as a trade-off, use variable). 2. Github Action, this also is the way you are using, be sure to set OPEN_API_KEY in secret, it's more secure.

kangjehun commented 4 months ago

thank you for your replying!