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@8 is used as follows and has the following options:

  - name: Generate A Second Opinion
    uses: wayneplural/second-opinion@v13
    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@v13
        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@v13
        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.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

second_opinion-2.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: second_opinion-2.2.0.tar.gz
  • Upload date:
  • Size: 4.9 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.2.0.tar.gz
Algorithm Hash digest
SHA256 4a42ad6959cf4997d84da566c078b08a740c23d0b59cda007df529e6f9a9baac
MD5 80aeb1b901b973366b161af3a811c566
BLAKE2b-256 690cdf12cabb78ff82b6c141f8f145bba3a9ebe33eb4ccb10b28ae8908a9f82a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for second_opinion-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30debb11b55ed8ec957a124f3b3377e3502c92efd9f4fe55bc826073972f26e3
MD5 40d67b042ae2e79a703ee82fbd10625f
BLAKE2b-256 1b7261fbd3debbc23c84bea6ebcab11a37c37126e1447b1a2ca7ff218aec0f06

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