GithubHelp home page GithubHelp logo

ankcorn / code-review-gpt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mattzcarey/code-review-gpt

0.0 0.0 0.0 165 KB

Your personal code reviewer powered by LLMs (OpenAI GPT-3.5/4, Llama, Falcon, Azure AI) & Embeddings ⚡️ Improve code quality and catch bugs before you break production 🚀

License: MIT License

JavaScript 7.10% TypeScript 92.90%

code-review-gpt's Introduction

Code Review GPT

Code Review GPT uses Large Language Models to review code in your CI/CD pipeline. It helps streamline the code review process by providing feedback on code that may have issues or areas for improvement.

It should pick up on common issues such as:

  • Dead code
  • Exposed secrets
  • Slow or inefficient code
  • Unreadable code

It can also be run locally in your command line to review staged files.

Just so you know, this is in alpha and should be used for fun only. It may provide helpful suggestions or they may be completely wrong.

Demo

code-review-gpt-3.mp4

Prerequisites

  • Node.js
  • Git
  • Github CLI (optional for setup tool)

Easy Setup (Github Actions)

In the root of your git repository run:

npm install code-review-gpt
npx code-review-gpt configure

Template CI Usage (GitHub Actions)

- name: Install code-review-gpt
   run: npm install code-review-gpt

- name: Run code review script
   run: npx code-review-gpt review --ci
   env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      BASE_SHA: ${{ github.event.pull_request.base.sha }}
      GITHUB_SHA: ${{ github.sha }}
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

See templates/pr.yml for an example.

Getting Started

  1. Clone the repository:

    git clone https://github.com/mattzcarey/code-review-gpt.git
    cd code-review-gpt
  2. Install dependencies:

    npm install
  3. Set up the API key:

    • Rename the .env.example file to .env.
    • Open the .env file and replace YOUR_API_KEY with your actual OPENAI API key.

When used globally you should run export OPENAI_API_KEY=YOUR_API_KEY (or similar for your operating system) in your terminal to set the API key.

  1. Run the application:

    npm start
  2. Install the application globally (optional):

    npm run build
    npm install -g

    This will allow you to run the application from anywhere on your machine.

Usage

Not installed globally

Run npm i code-review-gpt && npx code-review-gpt in the root directory of a git repository.

Installed globally

Run code-review-gpt in the root directory of a git repository.

Commands

  • code-review-gpt review - Runs the code review on the staged files.
  • code-review-gpt configure - Runs a setup tool to configure the application.

Options

  • --ci - Runs the application in CI mode. This will use the BASE_SHA and GITHUB_SHA environment variables to determine which files to review. It will also use the GITHUB_TOKEN environment variable to create a comment on the pull request with the review results.

  • --model - The model to use for the review. Defaults to gpt-4. You can use any openai model you have access to.

Roadmap

  • Make a more clever way to find the exact code to review
  • VSCode extension
  • Use some embeddings and vector store to build a knowledge graph of the repo to make better suggestions
  • Prompt engineering to refine the prompt
  • Build a prompt analysis tool
  • Support different LLMs... Private, HuggingFace, Azure etc.
  • Build out the cloud offering

Sponsors ❤️

quivr logo aleios logo

code-review-gpt's People

Contributors

ankcorn avatar danigo99 avatar fabienzucchet avatar mattzcarey 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.