Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelbroseghini/gpt-pr-suggestions
GPT powered pull request(s) suggestions :writing_hand:
https://github.com/rafaelbroseghini/gpt-pr-suggestions
Last synced: 16 days ago
JSON representation
GPT powered pull request(s) suggestions :writing_hand:
- Host: GitHub
- URL: https://github.com/rafaelbroseghini/gpt-pr-suggestions
- Owner: RafaelBroseghini
- Created: 2023-05-13T19:51:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-18T18:43:09.000Z (over 1 year ago)
- Last Synced: 2024-06-21T18:11:56.458Z (5 months ago)
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gpt-pr-suggestions
## What is `gpt-pr-suggestions`?
This project leverages the power of OpenAI's models to review and suggest improvements on code changes in a GitHub pull request.
When an user comments `/suggest` on a pull request, the model then returns suggestions and improvements, which the bot automatically comments on the pull request.
## Installation
Before running the bot, you need to configure a few environment variables:
- `GITHUB_TOKEN`: Your GitHub API token.
- `OPEN_AI_TOKEN`: Your OpenAI API key to use the ChatGPT service.
- `OPEN_AI_MODEL`: OpenAI model, e.g., `gpt-3.5-turbo`.1. Clone the repository: `git clone https://github.com/RafaelBroseghini/gpt-pr-suggestions`
2. Install the required dependencies: `go mod download`### Testing Locally
To test this bot locally, you'll need to set up the `GITHUB_EVENT_PATH` environment variable. This variable should point to a file containing a JSON representation of the GitHub event.
One of the easiest ways to get a realistic JSON event is to extract it from a real GitHub workflow.
To get this event payload:
1. Set up a workflow on your repository that gets triggered on comments to a PR.
2. In the workflow run, add a step that prints the contents of the `GITHUB_EVENT_PATH` file (`cat $GITHUB_EVENT_PATH`).
3. Run the workflow that includes the event you want to test (e.g., a comment on issue event).Here's an example of such a step in a workflow:
```yaml
on:
issue_commentjobs:
show-event:
name: Print event
runs-on: ubuntu-latest
steps:
- name: Dump GitHub event
cat $GITHUB_EVENT_PATH
```4. Go to a PR in the target repository and comment `/suggest`.
5. Check the workflow logs to find the printed JSON event data.
6. Copy the JSON data into a local file, and set the `GITHUB_EVENT_PATH` environment variable to the path of this file before running your bot locally.For more detailed instructions, you can reference: [Stack Overflow question](https://stackoverflow.com/questions/63803136/how-to-get-my-own-github-events-payload-json-for-testing-github-actions-locally).
Once the environment variables are set, you can run the bot with:
```bash
go run main.go
```