GitMRAI is a Work In Progress hobby project designed to automate the creation of reviews and summaries for Gitlab Merge Requests. The goal is to replicate some of the features 'Gitlab DUO' offers, but with a completely Open Source and free-to-use approach. Note that there are still some bugs to iron out! 🐞
At this moment, GitMRAI offers three endpoints that can be triggered by Gitlab webhooks on Merge Request push events:
-
Summarize the changes in a new comment within the Merge Request:
/api/v1/mr_summarize
-
Update the current description of the Merge Request with a summary:
/api/v1/mr_description
-
Create a comment on a specific part of the Merge Request diff/changes:
/api/v1/mr_comment_on_diff
- Python 3.10+
- Gitlab account with access to the repository or group
- Mistral AI API key
-
Clone the repository:
git clone https://github.com/ethux/GitMRAI.git cd GitlabMRAI
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.env
file in the root directory and add the following variables:
MODEL=<mistral_ai_model> API_KEY=<mistral_api_key> GITLAB_URL=<gitlab_url> GITLAB_TOKEN=<gitlab_access_token_for_repo_or_group> SECRET_TOKEN=<secret_token_for_api_auth> # This token should be added to the Gitlab webhook config as the Gitlab secret auth token.
- Create a
-
Run the application:
uvicorn main:app --host 0.0.0.0 --port 8080
- Navigate to your Gitlab repository or group settings.
- Go to Webhooks.
- Add a new webhook:
- URL:
http://your-server-ip:8080/api/v1/mr_summarize
(or the respective endpoint) - Secret Token: Use the
SECRET_TOKEN
from your.env
file. - Trigger: Select Merge Request events.
- URL:
Once the webhook is set up, any push event on a Merge Request will trigger the respective endpoint, generating a summary or comment based on the changes.
You can also change the prompts within the json files to adjust the summarize style or prompt to your wishes.
system_prompt_summarize.json
OR
system_prompt.json
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.