Giter VIP home page Giter VIP logo

openai-gitlab-pr-review's Introduction

AI Code Reviewer

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 merge request and push events, fetches the associated code changes, and provides feedback on the changes in a Markdown format.

Features

  • 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

Getting Started

Prerequisites

  • Python 3.8 or higher
  • Docker (optional)
  • An OpenAI API key
  • A GitLab API token

Installation

  1. Clone the repository:
https://git.facha.dev/facha/openai-gitlab-pr-review.git
cd ai-code-reviewer
  1. Install the required Python packages:
pip install -r requirements.txt
  1. 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>
  1. Run the application:
python app.py

Docker

Alternatively, you can use Docker to run the application:

  1. Build the Docker image:
docker-compose build
  1. Run the Docker container:
docker-compose up -d

Usage

  1. Configure your GitLab repository to send webhook events to the AI Code Reviewer application by following GitLab's webhook documentation.

  2. 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.

openai-gitlab-pr-review's People

Contributors

nfacha avatar takuya-o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openai-gitlab-pr-review's Issues

i have tried but in my python console log, get this error below:

[2023-11-26 22:25:49,540] ERROR in app: Exception on /webhook [POST]
Traceback (most recent call last):
File "/home/user/.local/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
File "/home/user/.local/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/user/.local/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/home/user/.local/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/home/user/openai-gitlab-pr-review/main.py", line 17, in webhook
if payload["object_attributes"]["action"] != "open":
KeyError: 'action'

Licence

Hiya, I am looking to create something similar and want to use this as a basis! (looks great)

Could you please add one, preferably MIT

Thanks
Ray

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.