A code review robot powered by Groq's Compound Beta model for automated pull request reviews
- Go to https://github.com/settings/apps/new
- Set the webhook URL to your deployed server (e.g.,
https://your-app-url/api/github/webhooks) - Set permissions:
- Repository: Contents (Read), Pull requests (Read & Write), Issues (Read & Write), Actions (Read)
- Subscribe to Pull request events
- Download your private key after creation
- Note your App ID, Client Secret, and Webhook Secret
Create a .env file in your project root:
APP_ID=your_app_id
PRIVATE_KEY=your_private_key_contents
WEBHOOK_SECRET=your_webhook_secret
GROQ_API_KEY=your_groq_api_key
GROQ_MODEL=compound-beta
npm install
npm run buildnpm startVisit http://localhost:3000 for setup instructions.
Deploy to your preferred platform (Vercel, Heroku, AWS, etc.) and set the environment variables in your host's dashboard.
- Go to your app's page on GitHub and install it on your target repository.
- Create a pull request in your repository. The bot will automatically review the PR and post comments.
- The bot only works as a GitHub App (not as a GitHub Action).
- Make sure your webhook URL is accessible from GitHub.
- For more details, see the Probot documentation: https://probot.github.io/docs/
❗️Due to cost considerations, BOT is only used for testing purposes and is currently deployed on AWS Lambda with ratelimit restrictions. Therefore, unstable situations are completely normal. It is recommended to deploy an app by yourself.
Install: apps/compound-reviewer;
- Go to the repo homepage which you want integrate this bot
- click
settings - click
actionsundersecrets and variables - Change to
Variablestab, create a new variableGROQ_API_KEYwith the value of your Groq API key (For Github Action integration, set it in secrets)
- The robot will automatically do the code review when you create a new Pull request, the review information will show in the pr timeline / file changes part.
- After
git pushupdate the pull request, cr bot will re-review the changed files
example:
- add the
GROQ_API_KEYto your github actions secrets - create
.github/workflows/cr.ymladd bellow content
name: Code Review
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: your-username/compound-reviewer@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
# Optional
LANGUAGE: Chinese
GROQ_API_ENDPOINT: https://api.groq.com/openai/v1
GROQ_MODEL: compound-beta # Default is 'compound-beta', can be changed to any available Groq model
PROMPT: # example: Please check if there are any confusions or irregularities in the following code diff:
top_p: 1
temperature: 1
max_tokens: 10000
MAX_PATCH_LENGTH: 10000
IGNORE_PATTERNS: /node_modules/**/*,*.md
INCLUDE_PATTERNS: *.js,*.ts
- clone code
- copy
.env.exampleto.env, and fill the env variables - install deps and run
npm i
npm i -g pm2
npm run build
pm2 start pm2.config.cjsNote: This bot is now powered by Groq and uses the compound-beta model by default.
probot for more detail
# Install dependencies
npm install
# Build code
npm run build
# Run the bot
npm run start# 1. Build container
docker build -t cr-bot .
# 2. Start container
docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> cr-botIf you have suggestions for how cr-bot could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the Contributing Guide.
this project is inpired by codereview.gpt
ISC © 2023 anc95
