AI Code Reviewer is a Python script that leverages OpenAI's GPT-3.5-turbo to automatically review code changes in GitLab repositories. It listens for push events, fetches the associated code changes, and provides feedback on the changes in a Markdown format.
- Automatically reviews code changes in GitLab repositories
- Provides feedback on code clarity, simplicity, bugs, and security issues
- Generates Markdown-formatted responses for easy readability in GitLab
- Python 3.8 or higher
- Docker (optional)
- An OpenAI API key
- A GitLab API token
- Clone the repository:
git https://github.com/takuya-o/OpenAI-Gitlab-PR-Review.git
cd OpenAI-Gitlab-PR-Review
- Install the required Python packages:
pip install -r requirements.txt
- Create a
.env
file and set the required environment variables:
OPENAI_API_KEY=<your OpenAI API key>
GITLAB_TOKEN=<your GitLab API token>
GITLAB_URL=https://gitlab.com/api/v4
EXPECTED_GITLAB_TOKEN=<your expected GitLab token>
- Run the application:
python app.py
Alternatively, you can use Docker to run the application:
- Build the Docker image:
docker compose build
- Run the Docker container:
docker compose up -d
-
Configure your GitLab repository to send webhook events to the AI Code Reviewer application by following GitLab's webhook documentation. Check only "Push Hook".
-
The AI Code Reviewer application will automatically review code changes in your GitLab repository and provide feedback as comments on merge requests and commit diffs.