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.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: second_opinion-2.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 39e4d032cace6ff130bd7f091dab81ffd063a0e27fb6c5eccd5395e2bd4ee896
MD5 d700b21b44b816802c9edea59d115767
BLAKE2b-256 c377d95d5a47a4404aaadbbddae43e2281d98094f5bc469e250e333ec8dd7690

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for second_opinion-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1e7234327b5b2c7d0bbb692f62ed117016221e1d1cec1f3137a21ba7dde98b7a
MD5 ed2a3f5930af77a3bf0527d46841d83b
BLAKE2b-256 5dd8169c0259da3c302ad5a3fc9281863da23f67781b98e2986027ceb8414411

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