Skip to main content

Generates AI Code Reviews

Project description

Second Opinion 🩺 (AI Code Review)

A Github Action which reviews your code.

This action is designed to run on pull request actions, specifically ones which change the code in the PR (open & synchronize). This action will take the latest changes and send them to a chat gpt model asking it to review the changes. The response is posted as a comment on the PR.

In order to run this you will need an Open AI key, or details for an Azure Open AI Deployment. It is recommended to store your API key as a secret in Github to avoid it being exposed to others https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions

The action wayneplural/second-opinion@v2 is used as follows and has the following options:

  - name: Generate A Second Opinion
    uses: wayneplural/second-opinion@v2
    with:
      openai-api-key: '<YOUR API KEY>' # Required - This can be either an Open AI key or Azure Open AI key if using Azure
      ai-model: '<API MODEL>' # Required - The GPT model to use or the deployment model if using an Azure deployment
      azure-openai-api-endpoint: '<AZURE OPEN AI ENDPOINT>' # Only required for Azure Open AI deployments
      azure-api-version: '<AZURE OPEN AI VERSION>' # Only required for Azure Open AI deployemnts
      custom-prompt: '<CUSTOM REVIEW PROMPT>' # Optional - a custom prompt to provide as the review prompt.

Before using the action you should use the checkout action to checkout your repo you will need to use a "fetch-depth" of at least 2 to get the last two commits:

  uses: actions/checkout@v4
  with:
    fetch-depth: 2

You will also need to provide pull request write permission and contents read permission to the job to allow the job to post a comment on your PR, and to checkout the repo.

jobs:
  second-opinion:
    permissions:
      pull-requests: write
      contents: read
    runs-on: ubuntu-latest

Example Usage

Open AI

name: Second Opinion - AI Code Review
run-name: Second Opinion - Diagnosing code 🩺
on: 
  pull_request:
    types: [opened, synchronize]

jobs:
  second-opinion:
    permissions:
      pull-requests: write
      contents: read
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Generate A Second Opinion
        uses: wayneplural/second-opinion@v2
        with:
          openai-api-key: ${{ secrets.AZURE_OPENAI_API_KEY }}
          ai-model: "gpt-3.5-turbo"
      

Azure Open AI

name: Second Opinion - AI Code Review
run-name: Second Opinion - Diagnosing code 🩺
on: 
  pull_request:
    types: [opened, synchronize]

jobs:
  second-opinion:
    permissions:
      pull-requests: write
      contents: read
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: Generate A Second Opinion
        uses: wayneplural/second-opinion@v2
        with:
          azure-openai-api-endpoint: "https://openaiplural.openai.azure.com/"
          azure-api-version: "2024-05-01-preview"
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}
          ai-model: "second-opinion"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

second_opinion-2.0.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

second_opinion-2.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file second_opinion-2.0.1.tar.gz.

File metadata

  • Download URL: second_opinion-2.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for second_opinion-2.0.1.tar.gz
Algorithm Hash digest
SHA256 6c0234bd020e0fb3aafae6a7ea140b541dddb623825258aaa36e5aef4186561a
MD5 19a14c0b8e725e9a565aac9799ba83f1
BLAKE2b-256 c3111403b3c87b028d88b1bc82f980fe8867f9075e03868dfb4058d4bda37583

See more details on using hashes here.

Provenance

File details

Details for the file second_opinion-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for second_opinion-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 990e4c6b5a0f69a316eb519f0dc814326351d4cbe5b89156513a90031843009b
MD5 252d2df5f5292a2c612572680745ae4a
BLAKE2b-256 1c951d1186124a03b8b445565c0cb4c1b1bc679208b65e9e192d80caab88ffc5

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page