GithubHelp home page GithubHelp logo

kevingarabedian / gpt_peer_review Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

This project leverages the power of GPT technology to perform peer reviews and integrates seamlessly with the GitHub API. Using advanced algorithms and natural language processing, this project can analyze code and provide insightful feedback to help improve code quality.

License: Apache License 2.0

C# 100.00%

gpt_peer_review's Introduction

GitHub GPT Pull Request Peer Reviewer

Demonstrates the use of GPT to generate comments for GitHub pull requests.

How to Use

To use this code, you'll need a personal access token from GitHub and an OpenAI API key.

Personal Access Token from GitHub

  1. Go to https://github.com/settings/tokens.
  2. Click on "Generate new token".
  3. Give the token a name.
  4. Select the "repo" scope.
  5. Click on "Generate token".
  6. Copy the token.

OpenAI API Key

  1. Go to https://beta.openai.com/docs/developer-quickstart/your-api-keys.
  2. Click on "Create a new API key".
  3. Give the API key a name.
  4. Click on "Create API key".
  5. Copy the API key.

Environment Variables

On Windows, you can set environment variables using the following command:

setx GITHUB_ACCESS_TOKEN "your personal access token from GitHub"
setx OPENAI_API_KEY "your OpenAI API key"

On Linux, you can set environment variables using the following command:

export GITHUB_ACCESS_TOKEN="your personal access token from GitHub"
export OPENAI_API_KEY="your OpenAI API key"

Code

Once you have your personal access token and OpenAI API key, you can create a new instance of the GitHubPullRequestReviewer class and call its methods to create pull requests and generate comments for existing pull requests.

Here's an example:

var reviewer = new GitHubPullRequestReviewer(
    Environment.GetEnvironmentVariable("GITHUB_ACCESS_TOKEN"),
    Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);

// If you want to create a pull request
var pullRequestUrl = await reviewer.CreatePullRequest(
    repositoryName: "your-repository-name",
    baseBranchName: "main",
    headBranchName: "new-feature-branch",
    title: "Add new feature",
    body: "This pull request adds a new feature.",
    diff: "The changes made in the new feature."
);

// Scan for pull requests to add review, you can set this to poll periodically, or you can implment a trigger such as pubsub, or webhook if desired.
await reviewer.CheckForNewPullRequestsAndPostComments("your-repository-name");

gpt_peer_review's People

Contributors

kevingarabedian avatar

Watchers

 avatar

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.