Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@

CodeRabbit `ai-pr-reviewer` is an open-source project built on AI, designed to
enhance developer productivity and efficiency by performing automated reviews of
pull requests.
pull requests.

# Professional Version of CodeRabbit
# Professional Version of CodeRabbit

The professional version of our openai-pr-reviewer project is now live at
[coderabbit.ai](http://Coderabbit.ai). Building upon our open-source foundation,
CodeRabbit offers premium features including enhanced context and superior
noise reduction, dedicated support, and our ongoing commitment to improve code
CodeRabbit offers premium features including enhanced context and superior noise
reduction, dedicated support, and our ongoing commitment to improve code
reviews.


## Reviewer Features:

- **PR Summarization**: It generates a summary and release notes of the changes
in the pull request.
- **Line-by-line code change suggestions**: Reviews the changes line by line and
provides code change suggestions that can be directly committed from the
GitHub UI.
provides code change suggestions.
- **Continuous, incremental reviews**: Reviews are performed on each commit
within a pull request, rather than a one-time review on the entire pull
request.
Expand All @@ -56,7 +54,6 @@ configure the required environment variables, such as `GITHUB_TOKEN` and
`OPENAI_API_KEY`. For more information on usage, examples, contributing, and
FAQs, you can refer to the sections below.


- [Overview](#overview)
- [Professional Version of CodeRabbit](#professional-version-of-coderabbit)
- [Reviewer Features](#reviewer-features)
Expand All @@ -66,8 +63,6 @@ FAQs, you can refer to the sections below.
- [Contribute](#contribute)
- [FAQs](#faqs)



## Install instructions

`ai-pr-reviewer` runs as a GitHub Action. Add the below file to your repository
Expand Down Expand Up @@ -195,13 +190,10 @@ Some of the reviews done by ai-pr-reviewer

![PR Summary](./docs/images/PRSummary.png)


![PR Release Notes](./docs/images/ReleaseNotes.png)


![PR Review](./docs/images/section-1.png)


![PR Conversation](./docs/images/section-3.png)

Any suggestions or pull requests for improving the prompts are highly
Expand All @@ -212,7 +204,7 @@ appreciated.
### Developing

> First, you'll need to have a reasonably modern version of `node` handy, tested
> with node 16.
> with node 17+.

Install the dependencies

Expand Down
42 changes: 38 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ inputs:
!**/*.gz
!**/*.xz
!**/*.zip
!**/*.7z
!**/*.rar
!**/*.zst
!**/*.ico
!**/*.jar
Expand All @@ -56,18 +58,41 @@ inputs:
!**/*.lo
!**/*.log
!**/*.mp3
!**/*.wav
!**/*.wma
!**/*.mp4
!**/*.avi
!**/*.mkv
!**/*.wmv
!**/*.m4a
!**/*.m4v
!**/*.3gp
!**/*.3g2
!**/*.rm
!**/*.mov
!**/*.flv
!**/*.iso
!**/*.swf
!**/*.flac
!**/*.nar
!**/*.o
!**/*.ogg
!**/*.otf
!**/*.p
!**/*.pdf
!**/*.doc
!**/*.docx
!**/*.xls
!**/*.xlsx
!**/*.ppt
!**/*.pptx
!**/*.pkl
!**/*.pickle
!**/*.pyc
!**/*.pyd
!**/*.pyo
!**/*.pub
!**/*.pem
!**/*.rkt
!**/*.so
!**/*.ss
Expand All @@ -91,17 +116,26 @@ inputs:
!**/*.jpg
!**/*.png
!**/*.gif
!**/*.bmp
!**/*.tiff
!**/*.webm
!**/*.woff
!**/*.woff2
!**/*.dot
!**/*.md5sum
!**/*.wasm
!**/*.snap
!**/*.parquet
!**/gen/**
!**/_gen/**
!**/generated/**
!**/@generated/**
!**/vendor/**
!**/*.min.js
!**/*.min.js.map
!**/*.min.js.css
!**/*.tfstate
!**/*.tfstate.backup
disable_review:
required: false
description: 'Only provide the summary and skip the code review.'
Expand Down Expand Up @@ -195,10 +229,10 @@ inputs:
"New Feature: An integrations page was added to the UI". Keep your
response within 50-100 words. Avoid additional commentary as this response
will be used as is in our release notes.

Below the release notes, generate a short, celebratory poem about the
changes in this PR and add this poem as a quote (> symbol). You can
use emojis in the poem, where they are relevant.
language:
required: false
description: ISO code for the response language
default: en-US
runs:
using: 'node16'
main: 'dist/index.js'
62 changes: 35 additions & 27 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class Bot {
const currentDate = new Date().toISOString().split('T')[0]
const systemMessage = `${options.systemMessage}
Knowledge cutoff: ${openaiOptions.tokenLimits.knowledgeCutOff}
Current date: ${currentDate}`
Current date: ${currentDate}

IMPORTANT: Entire response must be in the language with ISO code: ${options.language}
`

this.api = new ChatGPTAPI({
apiBaseUrl: options.apiBaseUrl,
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ async function run(): Promise<void> {
getInput('openai_timeout_ms'),
getInput('openai_concurrency_limit'),
getInput('github_concurrency_limit'),
getInput('openai_base_url')
getInput('openai_base_url'),
getInput('language')
)

// print options
Expand Down
6 changes: 5 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Options {
lightTokenLimits: TokenLimits
heavyTokenLimits: TokenLimits
apiBaseUrl: string
language: string

constructor(
debug: boolean,
Expand All @@ -38,7 +39,8 @@ export class Options {
openaiTimeoutMS = '120000',
openaiConcurrencyLimit = '6',
githubConcurrencyLimit = '6',
apiBaseUrl = 'https://api.openai.com/v1'
apiBaseUrl = 'https://api.openai.com/v1',
language = 'en-US'
) {
this.debug = debug
this.disableReview = disableReview
Expand All @@ -58,6 +60,7 @@ export class Options {
this.lightTokenLimits = new TokenLimits(openaiLightModel)
this.heavyTokenLimits = new TokenLimits(openaiHeavyModel)
this.apiBaseUrl = apiBaseUrl
this.language = language
}

// print all options using core.info
Expand All @@ -80,6 +83,7 @@ export class Options {
info(`summary_token_limits: ${this.lightTokenLimits.string()}`)
info(`review_token_limits: ${this.heavyTokenLimits.string()}`)
info(`api_base_url: ${this.apiBaseUrl}`)
info(`language: ${this.language}`)
}

checkPath(path: string): boolean {
Expand Down
35 changes: 17 additions & 18 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,27 @@ implications. Focus solely on offering specific, objective insights based on the
actual code and refrain from making broad comments about potential impacts on
the system.

Use Markdown format for review comment text and fenced code blocks for code
snippets.

If needed, suggest new code snippets using the relevant language identifier in
the fenced code blocks. These snippets may be added to a different file (e.g.
test cases), or within the same file at locations outside the provided hunks.
Multiple new code snippets are allowed within a single review section.

If needed, provide a replacement snippet to fix an issue by using fenced code
blocks using the \`diff\` as the format, clearly marking the lines that need be
added or removed with \`+\` and \`-\` respectively. The line number range for
the review section that includes the replacement snippet must map exactly to the
line number range that has to be completely replaced within the new hunk.
If less than 10 lines of the hunk have to be replaced then you may alternatively
use the \`suggestion\` format. You must carefully include any lines of code that
remain unchanged in the replacement snippet to avoid issues when the replacement
snippet is committed as-is. Replacement snippet must be complete, correctly
formatted & indented and without the line number annotations.
Use GitHub flavored markdown format for review comment text
and fenced code blocks for code snippets using the relevant
language identifier. Do NOT annotate the code snippet with
line numbers. The code snippet must be correctly
formatted & indented.

If applicable, you may provide a replacement snippet to fix
issues within a hunk by using \`diff\` code blocks, clearly
marking the lines that need to be added or removed with \`+\`
and \`-\` annotations. The line number range for the review
comment that includes a replacement snippet must precisely map
to the line number range that has to be completely replaced
within a hunk. Do NOT use \`suggestion\` code blocks for
replacement snippets.

If there are no issues found on a line range, you MUST respond with the
text \`LGTM!\` for that line range in the review section.

Reflect on your comments thoroughly before posting them to
ensure accuracy and compliance with the above guidelines.

## Example

### Example changes
Expand Down