/Summarize-Pull-Request

Perform automatic code reviews for GitHub pull requests (PR). The review is triggered when a PR is created and is triggered again for every subsequent commit in the PR. It will review each commit in the PR.

Primary LanguageRust

中文文档

ChatGPT/4 code reviewer for Github PR

flows.network Discord flows.network Twitter Create a flow

Deploy this function on flows.network, and you will get a GitHub 🤖 to review and summarize Pull Requests. It helps busy open source contributors understand and make decisions on PRs faster! A few examples below!

Still not convinced? See "potential problems 1" in this review, it identified an inefficient Rust implementation of an algorithm. 🤯

This bot summarizes commits in the PR. Alternatively, you can use this bot to review changed files in the PR.

How it works

This flow function (or 🤖) will be triggered when a new PR is raised in the designated GitHub repo. The flow function collects the content in the PR, and asks ChatGPT/4 to review and summarize it. The result is then posted back to the PR as a comment. The flow functions are written in Rust and run in hosted WasmEdge Runtimes on flows.network.

  • The code review comment is updated automatically every time a new commit is pushed to this PR.
  • A new code review could be triggered when someone says a magic trigger phrase in the PR's comments section. The default trigger phrase is "flows summarize".

Deploy your own code review bot in 3 simple steps

  1. Create a bot from a template
  2. Add your OpenAI API key
  3. Configure the bot to review PRs on a specified GitHub repo

0 Prerequisites

You will need to bring your own OpenAI API key. If you do not already have one, sign up here.

You will also need to sign into flows.network from your GitHub account. It is free.

1 Create a bot from a template

Just click here

Review the trigger_phrase variable. It is the magic words you type in a PR comment to manually summon the review bot.

Click on the Create and Build button.

2 Add your OpenAI API key

You will now set up OpenAI integration. Click on Connect, enter your key and give it a name.

image

Close the tab and go back to the flow.network page once you are done. Click on Continue.

3 Configure the bot to access GitHub

Next, you will tell the bot which GitHub repo it needs to monitor for upcoming PRs to review.

  • github_owner: GitHub org for the repo you want to deploy the 🤖 on.
  • github_repo : GitHub repo you want to deploy the 🤖 on.

Let's see an example. You would like to deploy the bot to review code in PRs on WasmEdge/wasmedge_hyper_demo repo. Here github_owner = WasmEdge and github_repo = wasmedge_hyper_demo.

Click on the Connect or + Add new authentication button to give the function access to the GitHub repo to deploy the 🤖. You'll be redirected to a new page where you must grant flows.network permission to the repo.

image

Close the tab and go back to the flow.network page once you are done. Click on Deploy.

Wait for the magic!

This is it! You are now on the flow details page waiting for the flow function to build. As soon as the flow's status became running, the bot is ready to give code reviews! The bot is summoned by every new PR, every new commit, as well as magic words (i.e., trigger_phrase) in PR comments.

image

FAQ

Customize the bot

The bot's source code is available in the GitHub repo you cloned from the template. Feel free to make changes to the source code (e.g., model, context length, API key and prompts) to fit your own needs. If you need help, ask in Discord!

Use GPT4

By default, the bot uses GPT3.5 for code review. If your OpenAI API key has access to GPT4, you can open the src/github-pr-review.rs file in your cloned source code repo, and change GPT35Turbo to GPT4 in the source code. Commit and push the change back to GitHub. The flows.network platform will automatically detect and rebuild the bot from your updated source code.

Use the bot on multiple repos

You can manually create a new flow and import the source code repo for the bot (i.e., the repo you cloned from the template). Then, you can use the flow config to specify the github_owner and github_repo to point to the target repo you need to deploy the bot on. Deploy and authorize access to that target repo.

You can repeat this for all target repos you would like to deploy this bot on.

You could have a single flow function repo deployed as the source code for multiple bots. When you update the source code in the repo, and push it to GitHub, it will change the behavior of all the bots.

Change the magic phrase

Go to the "Settings" tab of the running flow function for the bot, you can update the trigger_phrase config. The value of this config is the magic phrase the user will say to trigger a review from a PR comment.

Credits

This flow function is originally created by Jay Chen, and jinser made significant contributions to optimize the event triggers from GitHub.

GPT Nitro for Github PR - A ChatGPT-based reviewer for your GitHub pull requests | Product Hunt