This is a Python program that uses OpenAI's ChatGPT to generate code review comments from diffs. The program reads the diff changes from the standard input, which allows piping from git diffs (or any other diff tool) directly into the program.
git diff master..branch | python3 chatgpt_code_reviewer.py
chatgpt_code_reviewer2.mp4
- Clone this repository and navigate to the ChatGPTCodeReviewer folder
git clone https://github.com/lusob/ChatGPTCodeReviewer.git
cd ChatGPTCodeReviewer
- Install Package
pip install -r requirements.txt
-
Export your OpenAI API key and Gilab key as an environments variables:
export OPENAI_KEY=<YOUR_OPENAI_API_KEY>
-
Pipe diffs directly into the program:
git diff master..branch | python3 chatgpt_code_reviewer.py
The program generates an HTML file that contains the AI generated code review comments for each diff file section, along with the diff sections themselves as code blocks with syntax highlighting. The HTML file is opened in the default web browser for the user to review.