cirolini / genai-code-review

MIT License
321 stars 51 forks source link

New way to generate description for PR #10

Closed glauberborges closed 1 year ago

glauberborges commented 1 year ago

A new way to capture PR changes and send them to OpenAI's AI was created.

The patch file that is read, and like this file, is parsed per file and sent to the AI to be interpreted.

-[x] Added new 'mode' parameter to have the option to generate the PR description -[x] Separate modes into functions -[x] Update readme

github-actions[bot] commented 1 year ago

ChatGPT's response about .gitignore:

This is a Python-specific gitignore file which excludes common Python files and folders from being tracked by git. This is useful for avoiding clutter in the git repository, and also ensures that sensitive information is not accidentally committed.

github-actions[bot] commented 1 year ago

ChatGPT's response about README.md:

This code is written in Python and uses the OpenAI API to automatically send code review requests to ChatGPT for an explanation. It also uses the Github Actions platform to automate the process.

github-actions[bot] commented 1 year ago

ChatGPT's response about action.yml:

This code is written in YAML, and it is a configuration file for a Github Action. This Action will run a code review using ChatGPT with Github Actions integration on PRs for code explanations. The inputs to this Action are an OpenAI API key, a Github API key, a Github PR ID, and optional parameters for the OpenAI engine, temperature, and maximum tokens. The mode parameter specifies how to capture PR changes, and the default is 'files'.

github-actions[bot] commented 1 year ago

ChatGPT's response about entrypoint.sh:

This is a Python script that is meant to be run from the command line. It takes in seven arguments:

  1. The OpenAI API key
  2. The GitHub token
  3. The GitHub PR ID
  4. The OpenAI engine
  5. The OpenAI temperature
  6. The OpenAI max tokens
  7. The mode
github-actions[bot] commented 1 year ago

ChatGPT's response about main.py:

This code is for an automated code review using the ChatGPT language model. It starts by importing argparse, openai, os, requests, and Github. Next, it adds command-line arguments for the OpenAI API key, Github token, Github PR ID, OpenAI engine, OpenAI temperature, and OpenAI max tokens. Then, it authenticates with the OpenAI API and the Github API.

After that, it has a function for files mode and a function for patch mode. In files mode, it loops through the commits in the pull request and gets the modified files in each commit. For each file, it sends the code to ChatGPT and adds a comment to the pull request with ChatGPT's response. In patch mode, it gets the content of the patch file and sends it to ChatGPT. It then adds a comment to the pull request with ChatGPT's response.

github-actions[bot] commented 1 year ago

ChatGPT's response about requirements.txt:

This code is a list of dependencies for the openai library. The b' in front of the code indicates that it is in bytes form. The ~= symbols indicate that these are compatible versions of the dependencies.