Skip to content

Commit

Permalink
Cleanup and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Facha committed Apr 9, 2023
1 parent 20ae88d commit 207015f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OPENAI_API_KEY=<your OpenAI API key>
GITLAB_TOKEN=<your GitLab API token>
GITLAB_URL=https://git.facha.dev/api/v4
EXPECTED_GITLAB_TOKEN=<your expected GitLab token>
GITLAB_URL=https://gitlab.com/api/v4
EXPECTED_GITLAB_TOKEN=<your expected GitLab token>
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# OpenAI-Gitlab-PR-Reviwer
# 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
```

2. Install the required Python packages:
```
pip install -r requirements.txt
```

3. 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>
```
4. Run the application:
```
python app.py
```


### Docker

Alternatively, you can use Docker to run the application:

1. Build the Docker image:
```
docker-compose build
```
2. 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](https://docs.gitlab.com/ee/user/project/integrations/webhooks.html).

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.
3 changes: 0 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import openai

app = Flask(__name__)
#openai.api_key = "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"
#gitlab_token = "2ZbZzgZPz9o_F7kfXusx"
#gitlab_url = "https://git.facha.dev/api/v4"
openai.api_key = os.environ.get("OPENAI_API_KEY")
gitlab_token = os.environ.get("GITLAB_TOKEN")
gitlab_url = os.environ.get("GITLAB_URL")
Expand Down

0 comments on commit 207015f

Please sign in to comment.