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

Support azure api #64

Merged
merged 15 commits into from
Sep 12, 2024
20 changes: 19 additions & 1 deletion .env.action.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Core view engine
# e.g. openai, azureopenai
ENGINE=

# OpenAI API key
# https://platform.openai.com/account/api-keys
OPENAI_API_KEY=

# Azure settings
# Azure base url
# e.g. https://openai.azure.com/openai/
AZURE_OPENAI_BASE_URL=
# Azure open AI API key
AZURE_OPENAI_API_KEY=
# Azure API version
# e.g. 2024-06-01
AZURE_API_VERSION=
# Azure deployment
# e.g. gpt-4o
AZURE_DEPLOYMENT=gpt-4o

# Optional settings for code review
# chatGPT model
# e.g. gpt-3.5-turbo (default), gpt-3.5-turbo-0301, gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314
Expand All @@ -25,4 +43,4 @@ MAX_FILE_PER_PR=20
# Customized code review prompt
# Not recommend to set up this. Instead, you can submit a PR to improve the default prompt.
# Any environment variables used in the default prompt will not work if a customized prompt is provided.
CUSTOMIZED_PROMPT="Please do code review for me"
CUSTOMIZED_PROMPT="Please do code review for me"
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ WEBHOOK_SECRET=

PORT=3600

# Core view engine
# e.g. openai, azureopenai
ENGINE=
# OpenAI API key
# https://platform.openai.com/account/api-keys
OPENAI_API_KEY=
Expand Down
42 changes: 9 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,23 @@ Let AI do code review for you! [Demo](https://github.com/Louis-7/ranking-board/p

This app is calling OpenAI chatGPT API to do code review for you.

[GitHub App](https://github.com/apps/ai-code-review) | [GitHub Action](https://github.com/marketplace/actions/quick-ai-code-review) | [Self-host Instruction](https://github.com/Louis-7/ai-code-review/tree/main#host-it-by-yourself)
[GitHub App](https://github.com/apps/ai-code-review) | [GitHub Action](https://github.com/marketplace/actions/quick-ai-code-review) | [Self-host Instruction](https://github.com/Louis-7/ai-code-review/tree/main#host-it-by-yourself)

## Install

### GitHub App
1. Go to **Settings** -> **Secrets and variables** -> **Actions** -> **New repository secret**

1. Install GitHub App for you repository - [GitHub App - AI Code Review](https://github.com/apps/ai-code-review)
2. Create a pull request in your repository
2. Create a repository secret named `OPENAI_API_KEY` and fill it with your API key

### GitHub Action
3. Add the configurations to `.github/workflows/pr-code-review.yml`

1. Go to **Settings** -> **Secrets and variables** -> **Actions** -> **New repository secret**
1. [OpenAI example](https://github.com/Louis-7/ai-code-review/blob/main/examples/open-ai-example.yml)

2. Create a repository secret named `OPENAI_API_KEY` and fill it with your API key
2. [Azure OpenAI example](https://github.com/Louis-7/ai-code-review/blob/main/examples/azure-open-ai-example.yml)

4. Get more details about the available environment variables in [.env.action.example](https://github.com/Louis-7/ai-code-review/blob/main/.env.action.example)

3. Add following configurtion in your `.github/workflows/pr-code-review.yml`

```
name: Code Review
permissions:
contents: read
pull-requests: write
on:
pull_request:
types: [opened, synchronize]
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: Louis-7/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PATH_TO_EXCLUDE: action/**/*, package-lock.json, package.json
MAX_PATCH_PER_FILE: 2000
MAX_FILE_PER_PR: 20
```

4. `GITHUB_TOKEN` and `OPENAI_API_KEY` are required parameter. Others are optional. You can get all available options in the [.env.action.example](https://github.com/Louis-7/ai-code-review/blob/main/.env.action.example)

5. Create a pull request in your repository
5. Create a pull request in your repository and let AI assistant you!

### Host it by yourself

Expand Down
4 changes: 4 additions & 0 deletions action/controllers/review-controller.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Context } from "probot";
export declare class ReviewController {
static reviewCodeOnPullRequestUpdates(context: Context<'pull_request.opened' | 'pull_request.synchronize' | 'pull_request.labeled'>): Promise<void>;
}
Loading
Loading