Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs, optional model name parameter. Defaults to gpt-3.5-turbo-16k #1

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# GitHub Pull Request Reviewer Action

This repository contains a GitHub Action that automates the process of reviewing pull requests using OpenAI's GPT model.

## Features

- Fetches the diff of the changes when a pull request is opened or updated.
- Submits the diff to the GPT model for review.
- Posts the model's response as a comment on the pull request.

## Usage

To use this action in your GitHub workflows, add a step to your workflow file that references this repository:

```yaml
- name: Run PR Reviewer
uses: hdvinsurance/gpt-code-review-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
```

## Inputs

The action accepts the following inputs:

- `github_token` (**required**): The GitHub token used to post comments on the pull request. This is a required input.

- `openai_api_key`: The OpenAI API key. This is required if the `OPENAI_API_KEY` environment variable is not set. This input is optional.

- `pr_review_prompt_template`: Provide a PR review prompt template to optionally override the default prompt template with your own. This input is optional and defaults to an empty string.

- `model_name`: Optional. Defaults to `gpt-3.5-turbo-16k`.

## Outputs

The action produces the following output:

- `pr_review`: The PR review text. Note: this is the raw output from the GPT model and may contain newlines and other formatting characters.

## Considerations and Limitations

Code Reviews performed by a generative AI process may not always be correct. Exercise caution when evaluating the suggestions of the model.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: 'Provide a PR review prompt template to optionally override the default prompt template with your own.'
required: false
default: ''
model_name:
description: 'Provide a model name to optionally override the default model name with your own. Defaults to gpt-3.5-turbo-16k.'
required: false
default: 'gpt-3.5-turbo-16k'
outputs:
pr_review:
description: 'The PR review text.'
Expand Down
4 changes: 2 additions & 2 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ async function run() {
try {
const githubToken = core.getInput('github_token') || process.env.GITHUB_TOKEN;
const openaiApiKey = core.getInput('openai_api_key') || process.env.OPENAI_API_KEY;
const prReviewPromptTemplate = core.getInput('pr_review_prompt_template');
const prReviewModel = process.env.PR_REVIEW_MODEL || 'gpt-3.5-turbo-16k';
const prReviewPromptTemplate = core.getInput('pr_review_prompt_template') || process.env.PR_REVIEW_PROMPT_TEMPLATE || DEFAULT_PR_REVIEW_PROMPT_TEMPLATE;
const prReviewModel = core.getInput('model_name') || process.env.PR_REVIEW_MODEL || 'gpt-3.5-turbo-16k';

// Set environment variables
process.env.GH_TOKEN = githubToken;
Expand Down