Giter Site home page Giter Site logo

coderabbitai / ai-pr-reviewer Goto Github PK

View Code? Open in Web Editor NEW
1.4K 11.0 250.0 23.63 MB

AI-based Pull Request Summarizer and Reviewer with Chat Capabilities.

Home Page: https://coderabbit.ai

License: MIT License

TypeScript 99.71% JavaScript 0.29%
code-review github-action gpt-4 openai

ai-pr-reviewer's Introduction

CodeRabbit Pro

This is an old version of CodeRabbit and is now in the maintenance mode. We recommend installing the Pro version from CodeRabbit. The Pro version is a total redesign and offers significantly better reviews that learn from your usage and improve over time. CodeRabbit Pro is free for open source projects.

Discord

AI-based PR reviewer and summarizer

License: MIT GitHub

Overview

CodeRabbit ai-pr-reviewer is an AI-based code reviewer and summarizer for GitHub pull requests using OpenAI's gpt-3.5-turbo and gpt-4 models. It is designed to be used as a GitHub Action and can be configured to run on every pull request and review comments

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.
  • Continuous, incremental reviews: Reviews are performed on each commit within a pull request, rather than a one-time review on the entire pull request.
  • Cost-effective and reduced noise: Incremental reviews save on OpenAI costs and reduce noise by tracking changed files between commits and the base of the pull request.
  • "Light" model for summary: Designed to be used with a "light" summarization model (e.g. gpt-3.5-turbo) and a "heavy" review model (e.g. gpt-4). For best results, use gpt-4 as the "heavy" model, as thorough code review needs strong reasoning abilities.
  • Chat with bot: Supports conversation with the bot in the context of lines of code or entire files, useful for providing context, generating test cases, and reducing code complexity.
  • Smart review skipping: By default, skips in-depth review for simple changes (e.g. typo fixes) and when changes look good for the most part. It can be disabled by setting review_simple_changes and review_comment_lgtm to true.
  • Customizable prompts: Tailor the system_message, summarize, and summarize_release_notes prompts to focus on specific aspects of the review process or even change the review objective.

To use this tool, you need to add the provided YAML file to your repository and 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.

Install instructions

ai-pr-reviewer runs as a GitHub Action. Add the below file to your repository at .github/workflows/ai-pr-reviewer.yml

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
  pull_request_review_comment:
    types: [created]

concurrency:
  group:
    ${{ github.repository }}-${{ github.event.number || github.head_ref ||
    github.sha }}-${{ github.workflow }}-${{ github.event_name ==
    'pull_request_review_comment' && 'pr_comment' || 'pr' }}
  cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: coderabbitai/ai-pr-reviewer@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        with:
          debug: false
          review_simple_changes: false
          review_comment_lgtm: false

Environment variables

  • GITHUB_TOKEN: This should already be available to the GitHub Action environment. This is used to add comments to the pull request.
  • OPENAI_API_KEY: use this to authenticate with OpenAI API. You can get one here. Please add this key to your GitHub Action secrets.
  • OPENAI_API_ORG: (optional) use this to use the specified organization with OpenAI API if you have multiple. Please add this key to your GitHub Action secrets.

Models: gpt-4 and gpt-3.5-turbo

Recommend using gpt-3.5-turbo for lighter tasks such as summarizing the changes (openai_light_model in configuration) and gpt-4 for more complex review and commenting tasks (openai_heavy_model in configuration).

Costs: gpt-3.5-turbo is dirt cheap. gpt-4 is orders of magnitude more expensive, but the results are vastly superior. We are typically spending $20 a day for a 20 developer team with gpt-4 based review and commenting.

Prompts & Configuration

See: action.yml

Tip: You can change the bot personality by configuring the system_message value. For example, to review docs/blog posts, you can use the following prompt:

Blog Reviewer Prompt
system_message: |
  You are `@coderabbitai` (aka `github-actions[bot]`), a language model
  trained by OpenAI. Your purpose is to act as a highly experienced
  DevRel (developer relations) professional with focus on cloud-native
  infrastructure.

  Company context -
  CodeRabbit is an AI-powered Code reviewer.It boosts code quality and cuts manual effort. Offers context-aware, line-by-line feedback, highlights critical changes,
  enables bot interaction, and lets you commit suggestions directly from GitHub.

  When reviewing or generating content focus on key areas such as -
  - Accuracy
  - Relevance
  - Clarity
  - Technical depth
  - Call-to-action
  - SEO optimization
  - Brand consistency
  - Grammar and prose
  - Typos
  - Hyperlink suggestions
  - Graphics or images (suggest Dall-E image prompts if needed)
  - Empathy
  - Engagement

Conversation with CodeRabbit

You can reply to a review comment made by this action and get a response based on the diff context. Additionally, you can invite the bot to a conversation by tagging it in the comment (@coderabbitai).

Example:

@coderabbitai Please generate a test plan for this file.

Note: A review comment is a comment made on a diff or a file in the pull request.

Ignoring PRs

Sometimes it is useful to ignore a PR. For example, if you are using this action to review documentation, you can ignore PRs that only change the documentation. To ignore a PR, add the following keyword in the PR description:

@coderabbitai: ignore

Examples

Some of the reviews done by ai-pr-reviewer

PR Summary

PR Release Notes

PR Review

PR Conversation

Any suggestions or pull requests for improving the prompts are highly appreciated.

Contribute

Developing

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

Install the dependencies

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run package

FAQs

Review pull requests from forks

GitHub Actions limits the access of secrets from forked repositories. To enable this feature, you need to use the pull_request_target event instead of pull_request in your workflow file. Note that with pull_request_target, you need extra configuration to ensure checking out the right commit:

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request_target:
    types: [opened, synchronize, reopened]
  pull_request_review_comment:
    types: [created]

concurrency:
  group:
    ${{ github.repository }}-${{ github.event.number || github.head_ref ||
    github.sha }}-${{ github.workflow }}-${{ github.event_name ==
    'pull_request_review_comment' && 'pr_comment' || 'pr' }}
  cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: coderabbitai/ai-pr-reviewer@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        with:
          debug: false
          review_simple_changes: false
          review_comment_lgtm: false

See also: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target

Inspect the messages between OpenAI server

Set debug: true in the workflow file to enable debug mode, which will show the messages

Disclaimer

  • Your code (files, diff, PR title/description) will be sent to OpenAI's servers for processing. Please check with your compliance team before using this on your private code repositories.
  • OpenAI's API is used instead of ChatGPT session on their portal. OpenAI API has a more conservative data usage policy compared to their ChatGPT offering.
  • This action is not affiliated with OpenAI.

ai-pr-reviewer's People

Contributors

asafmah avatar aschelch avatar dependabot[bot] avatar github-actions[bot] avatar grossjo avatar gurinder39 avatar guritfaq avatar harjotgill avatar hyunggyujang avatar imgbot[bot] avatar karansohi avatar legalhustler1 avatar riya-amemiya avatar sighingnow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ai-pr-reviewer's Issues

429 error

Greetings!

I am getting a 429 error, even though i have an upgraded account.

It seemed to have errored out the first try: I can provide more context if needed.

summary_token_limits: max_tokens=3900, request_tokens=2900, response_tokens=1000
review_token_limits: max_tokens=3900, request_tokens=2900, response_tokens=1000
api_base_url: https://api.openai.com/v1
Will review from the base commit: 602751d56e098eb78f2979002523f50f9ec31aee
checking path: src/bots/mean-reversion.ts => true
checking path: src/index.ts => true
checking path: src/live-trader.ts => true
checking path: types/common/index.d.ts => true
Warning: Function failed on try 1, retrying...
Warning: Function failed on try 2, retrying...
Warning: Function failed on try 3, retrying...
Warning: Function failed on try 4, retrying...
response: undefined, failed to send message to openai: Error: OpenAI error 429: {
    "error": {
        "message": "Rate limit reached for default-gpt-3.5-turbo in organization org-QXJc6SeBWFeCFjGmKVlmbaI1 on requests per min. Limit: 3 / min. Please try again in 20s. Contact [email protected] if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://platform.openai.com/account/billing to add a payment method.",
        "type": "requests",
        "param": null,
        "code": null
    }
}

Personality through the action

Hi

Thanks for the actions, it is nice!

Is it possible to change the personality through the props available in the actions? Would be nice to have this kind of control :)

Thanks!

like:

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: fluxninja/openai-pr-reviewer@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        with:
          debug: false
          review_comment_lgtm: false
		 system_message: |
  You are `@openai` (aka `github-actions[bot]`), a language model
  trained by OpenAI. Your purpose is to act as a highly experienced
  DevRel (developer relations) professional with focus on cloud-native
  infrastructure.

  Company context -
  FluxNinja is a cloud-native intelligent load management platform.
  The platform is powered by Aperture, an open-source project, which
  provides a control systems inspired policy language for defining
  observability driven control loop. FluxNinja's load management,
  such as prioritized load shedding and load-based autoscaling,
  ensures system stability. FluxNinja ARC, the commercial solution,
  offers advanced analytics, intelligent alerting, and policy
  visualization.

  When reviewing or generating content focus on key areas such as -
  - Accuracy
  - Relevance
  - Clarity
  - Technical depth
  - Call-to-action
  - SEO optimization
  - Brand consistency
  - Grammar and prose
  - Typos
  - Hyperlink suggestions
  - Graphics or images (suggest Dall-E image prompts if needed)
  - Empathy
  - Engagement

Gitlab

Hi, is it possible to use this workflow/action on a self-hosted GitLab instance?

Removed the ignore keyword and executed Github Actions, but the review did not run

Right after creating the PR, it was marked as a work in progress (Draft), so I launched the PR with @coderabbitai: ignore attached. Later, I removed @coderabbitai: ignore from the description and re-executed Github Actions with Re-run all jobs, but it was skipped with the message Skipped: description contains ignore_keyword.

Is this the intended behavior?

API Secrets during a merge from fork

When a pull request is opened from a fork, the action does not create a bot successfully. It seems that this is because the API key, which is stored in the upstream repository secrets, is not available in the context of a PR from a fork. As a result, the action throws the following error message:

Warning: Skipped: failed to create bot, please check your openai_api_key: Error: Unable to initialize the OpenAI API, both 'OPENAI_API_KEY' environment variable are not available, backtrace: Error: Unable to initialize the OpenAI API, both 'OPENAI_API_KEY' environment variable are not available

Steps to reproduce:

  1. Set up the action in a repository, following the configuration instructions in the documentation.
  2. Store the API key as a secret in the repository.
  3. Create a fork of the repository.
  4. Make changes in the fork and open a PR against the original repository.

Expected behaviour:

Openai bot runs on pull requests regardless of origin.

Actual behavior:

The action fails to create a bot on PRs opened from forks, as the API key stored in the repository secrets is not available.

Adjust rules

I wonder if the prompt could be tuned in some way to pass in a list of rules that it does not need to validate. For instance it keeps complaining about missing comments when we are internally trying to do minimal commenting and instead focusing on readable code.

Failed runs on deleted branches

Full disclosure: I was explicitly trying to trigger edge cases

I commented on a diff in an MR that was already merged (and hence original branch deleted): https://github.com/fluxninja/openai-pr-reviewer/pull/218/files/362ff2b8e3614a38c5705426672bf9130bdd4b11#diff-6237e411e4b5750f5e3713c4739039620a279cdf9c8c596d573a97e87f1c8e0f

Seems the action tried to initiate a run to review the code based on my comment, but there is no branch, so it failed: https://github.com/fluxninja/openai-pr-reviewer/actions/runs/4762183914/jobs/8464139310#step:2:57

Just reporting a bug!

Can't build the repo locally

On running npm run build, I'm getting the following error:

src/octokit.ts:8:50 - error TS2345: Argument of type 'typeof throttling' is not assignable to parameter of type 'OctokitPlugin'.
  Types of parameters 'octokit' and 'octokit' are incompatible.
    Type 'import("/home/coder/devrev-codejam/lynch-bot/node_modules/@octokit/action/node_modules/@octokit/core/dist-types/index").Octokit' is not assignable to type 'import("/home/coder/devrev-codejam/lynch-bot/node_modules/@octokit/core/dist-types/index").Octokit'.
      The types of 'request.defaults(...).endpoint.DEFAULTS' are incompatible between these types.
        Type 'object & O & import("/home/coder/devrev-codejam/lynch-bot/node_modules/@octokit/action/node_modules/@octokit/types/dist-types/RequestParameters").RequestParameters & { ...; }' is not assignable to type 'object & O & import("/home/coder/devrev-codejam/lynch-bot/node_modules/@octokit/types/dist-types/RequestParameters").RequestParameters & { baseUrl: string; method: import("/home/coder/devrev-codejam/lynch-bot/node_modules/@octokit/types/dist-types/RequestMethod").RequestMethod; url?: string | undefined; headers: imp...'.
          Type 'object & O & RequestParameters & { baseUrl: string; method: RequestMethod; url?: string | undefined; headers: RequestHeaders & { ...; }; mediaType: { ...; }; }' is not assignable to type '{ baseUrl: string; method: RequestMethod; url?: string | undefined; headers: RequestHeaders & { accept: string; "user-agent": string; }; mediaType: { format: string; previews: string[]; }; }'.
            The types of 'mediaType.previews' are incompatible between these types.
              Type 'string[] | undefined' is not assignable to type 'string[]'.
                Type 'undefined' is not assignable to type 'string[]'.

8 const RetryAndThrottlingOctokit = Octokit.plugin(throttling, retry)

This error occurs in octokit.ts where the plugins are provided to the octokit instance. Replacing the octokit instance from @octokit/action with the instance from @octokit/core resolves the issue in this file, but is incompatible with every other file which is expecting an action instance. How have you resolved this?

@harjotgill @guritfaq

Add more context lines to each patch

Often, the PR reviewer will make false assumptions because it can only see a small amount of lines that have been changed in the file.

One common issue is it'll say "This variable isn't being used anywhere" when it in fact is, it's just referenced outside the hunk.

It would be useful to add a config to allow larger hunks/more context lines.

Reduce redundant diff comments

The action is often leaving review comments which boil down to LGTM. The diff that is added is identical to the diff of the PR, and there is no suggestion made (see screenshot example below).

image

This happens even with the following workflow input parameters:

        with:
          debug: false
          review_simple_changes: false
          review_comment_lgtm: false
          openai_light_model: "gpt-4"

Intuitively, review_simple_changes and review_comment_lgtm being set to false should prevent this from happening, but these comments sometimes make up 50% of all review comments left and really clutter up the PR. I also tried to adjust the summary and system_message inputs to specifically instruct it to avoid commenting on diffs which don't require changes, but this did not help.

Using debug mode, I found the following snippet, which seems (to me) to cause this behavior, and which is not surfaced as a configurable input to the action.

'Below the summary, I would also like you to triage the diff as `NEEDS_REVIEW` or \n' +
        '`APPROVED` based on the following criteria:\n' +
        '\n' +
        '- If the diff involves any modifications to the logic or functionality, even if they \n' +
        '  seem minor, triage it as `NEEDS_REVIEW`. This includes changes to control structures, \n' +
        '  function calls, or variable assignments that might impact the behavior of the code.

Would it be possible to change the wording here depending on review_simple_changes or review_comment_lgtm?

Unable to Build and Run the Code

We are currently using Node.js v18.16.0 and NPM version 9.5.1 to build and run our code. However, we are facing issues with the build and run processes.

ERROR

> [email protected] build
> cp node_modules/@dqbd/tiktoken/tiktoken_bg.wasm dist/tiktoken_bg.wasm && tsc

src/octokit.ts:12:5 - error TS2322: Type '(retryAfter: number, options: any, _o: Octokit, retryCount: number) => boolean' is not assignable to type 'LimitHandler'.
  Types of parameters '_o' and 'octokit' are incompatible.
    Type 'Octokit' is not assignable to type 'Octokit & { paginate: PaginateInterface; } & RestEndpointMethods & Api'.
      Property 'paginate' is missing in type 'Octokit' but required in type '{ paginate: PaginateInterface; }'.

12     onRateLimit: (
       ~~~~~~~~~~~

  node_modules/@octokit/action/dist-types/index.d.ts:4:5
    4     paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
          ~~~~~~~~
    'paginate' is declared here.


Found 1 error in src/octokit.ts:12

Any assistance or guidance on resolving this issue would be greatly appreciated.

getting 404 resource not found error

using azure openai as openai_base_url?
i am trying to do it and getting this error :

response: undefined, failed to send message to openai: Error: OpenAI error 404: {"error":{"code":"404","message": "Resource not found"}}, backtrace: Error: OpenAI error 404: {"error":{"code":"404","message": "Resource not found"}}
at Promise.then.promptTokens (/actions-runner/_work/_actions/fluxninja/openai-pr-reviewer/latest/dist/index.js:3310:29)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

and this is how my workflow yaml looks like :

name: Code Review

permissions:
contents: read
pull-requests: write

on:
pull_request:
pull_request_review_comment:
types: [ created ]

concurrency:
group:
${{ github.repository }}-${{ github.event.number || github.head_ref ||
github.sha }}-${{ github.workflow }}-${{ github.event_name ==
'pull_request_review_comment' && 'pr_comment' || 'pr' }}
cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}

jobs:
review:
runs-on: self-hosted
environment: new-env
steps:
- uses: fluxninja/openai-pr-reviewer@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
debug: false
openai_base_url: https://"your endpoint deployment name".openai.azure.com/
openai_light_model: gpt-35-turbo
openai_heavy_model: gpt-35-turbo

Rate limits

Hello,

I have a prepaid version of ChatGPT and installed the script from the install README.
The error I am getting is this:

backtrace: Error: OpenAI error 429: {
    "error": {
        "message": "Rate limit reached for default-gpt-3.5-turbo in organization org-tWLJpza6PfFNRXgGrT00shKI on tokens per min. Limit: 60000 / min. Please try again in 1ms. Contact us through our help center at help.openai.com if you continue to have issues.",
        "type": "tokens",
        "param": null,
        "code": "rate_limit_exceeded"
    }
}
    at Promise.then.promptTokens (/home/runner/work/_actions/coderabbitai/ai-pr-reviewer/latest/dist/index.js:3310:29)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
response: undefined

It seems that I have exceeded the limit but their RPM is pretty high. How is it possible? Anybody found a similar issue?

Question: about tuning code rabbit

I would like to tune code rabbit so that it does not make comments that are unrelated to correction suggestions, such as "this code seems to be good!"

If there is a suitable method, I want the developer share the knowledge

I'm trying to tune by using system_message like below, but I can't get the behavior I'm looking for.

jobs:
 review:
   runs-on: hogehoge
  steps:
     - users: hogehoge
     - env:
        GITHUB_TOKEN: hogehoge
        OPEN_API_KEY: hogehoge
     with:
        debug: false
        review_simple_changes: false
        review_comment_lgtm: false
        system_message: |
            You are @coderabbitai (aka github-actions[bot]), a language model trained by OpenAI.
            Your objective is to function as a very experienced software engineer, thoroughly reviewing pieces of code and suggesting code snippets to improve key areas such as
              - Logic
              - Security
              - Performance
              - Data conflicts
              - Consistency
              - Error Handling
              - Maintainability
              - Modularity
              - Complexity
              - Optimization
              - Best Practice: DRY, SOLID, KISS
            Please do not comment on trivial code style issues or missing comments/documentation.
            Also, please avoid highly rated comments and comment only if you have a point to make.
            We review all of your comments, but too many comments can be burdensome.
            Our goal is to improve the overall quality of the code by identifying and resolving critical issues, so please intentionally ignore trivial issues and highly rated comments.

Language

Would be nice if we could send instructions to change the language of the GPT response, as we do on chatgpt online

Handle large PRs more effectively

Been using this internally for a while now - actually very useful.

Wondering if there is a way to make it less noisy for large PRs.

When it reviewed a PR that changed 400 files from @import to @use it took .. a while to wade through the comments.

All in all great project!

Config from .coderabbit.yaml path_filters doesn't seem to be used

I have a project in which I actually specifically want to include YAML and CSV files. Yet even when adding these into my .coderabbit.yaml file, they seem to still get excluded.

icoderabbit.yaml:

language: "en"
early_access: true
reviews:
  path_filters:
    - "**/*.yaml"
    - "**/*.yml"
    - "**/*.csv"
  auto_review:
    enabled: true
    drafts: false
chat:
  auto_reply: true

Mistral API compatibility

Instead of using OpenAI api I want to use Mistral AI api using the 8x7B model.

The only blocker with this code is the presence_penalty: 1 parameter in the index.js file, we just need to remove this line
to avoid OpenAI error 422 due to this Extra inputs not supported and permitted from Mistral API

I created a fork with this fix here

Now I'm using Mistral instead of OpenAI than is a lot cheaper

Add support for GH suggestions

Right now the code change suggestions are formatted with git patch format. You can only copy paste the change and use git patch apply to have it on PR.
image

GitHub PR supports faster code suggestions: select the code frame, click on suggestions or type:
image
which turns into a prompt message with buttons to commit changes:
image

language option does not work

Hi,

I am using this action and I would like to get Japanese response.
and I checked that PR: #430

So I setup language: ja-JP option to do it, But all of responses are in English. How can I resolve this issue?

<snip>
    steps:
      - uses: coderabbitai/openai-pr-reviewer@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        with:
          debug: false
          review_simple_changes: false
          review_comment_lgtm: false
          openai_light_model: gpt-4
          openai_heavy_model: gpt-4
          openai_timeout_ms: 900000
          language: ja-JP
          system_message: |
            あなたは @coderabbitai(別名 github-actions[bot])で、OpenAIによって訓練された言語モデルです。 あなたの目的は、非常に経験豊富なソフトウェアエンジニアとして機能し、コードの一部を徹底的にレ
ビューし、 以下のようなキーエリアを改善するためのコードスニペットを提案することです:
<snip>
スクリーンショット 2023-10-13 16 25 14

Support comments in any language

Hi, I like this project very much!

I found an easy way to make comments and release notes multilingual.

Just tell the prompt to "translate into xx language".

I think this will make it easier for developers around the world to use by adding additional options to action.yml.

Proof of concept

# .github/workflows/openai-pr-reviewer.yml
# This content refers to https://github.com/coderabbitai/openai-pr-reviewer/blob/9ac127d9e21d898c665f3a7cf12229e5908149d5/action.yml

jobs:
  review:
    steps:
        with:
          system_message: |
            You are `@openai` (aka `github-actions[bot]`), a language model
            trained by OpenAI. Your purpose is to act as a highly experienced
            software engineer and provide a thorough review of the code hunks
            and suggest code snippets to improve key areas such as:
              - Logic
              - Security
              - Performance
              - Data races
              - Consistency
              - Error handling
              - Maintainability
              - Modularity
              - Complexity
              - Optimization

            Refrain from commenting on minor code style issues, missing
            comments/documentation, or giving compliments, unless explicitly
            requested. Concentrate on identifying and resolving significant
            concerns to improve overall code quality while deliberately
            disregarding minor issues.

            Other instructions:
            - As your knowledge may be outdated, trust the developer when newer
              APIs and methods are seemingly being used.
            - Always presume that the developer has thoroughly tested their changes
              and is aware of their implications on the entire system. Instead of
              making generic comments about potential impacts on the system, focus
              on providing specific, objective insights based on the code itself.
            - Do not question the developer's intention behind the changes or caution
              them to ensure that their modifications do not introduce compatibility
              issues with other dependencies.
            - Never ask the developer to review the changes.

            IMPORTANT: Provide your review in Japanese(日本語).
          summarize: |
            Provide your final response in the `markdown` format with
            the following content:
              - High-level summary (comment on the overall change instead of
                specific files within 80 words)
              - Table of files and their summaries. You can group files with
                similar changes together into a single row to save space.

            Avoid additional commentary as this summary will be added as a
            comment on the GitHub pull request.

            IMPORTANT: Provide your summary in Japanese(日本語).
          summarize_release_notes: |
            Create concise release notes in `markdown` format for this pull request,
            focusing on its purpose and user story. You can classify the changes as
            "New Feature", "Bug fix", "Documentation", "Refactor", "Style",
            "Test", "Chore", "Revert", and provide a bullet point list. For example:
            "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.

            IMPORTANT: Provide your release notes in Japanese(日本語).

Details are in my article below.
https://zenn.dev/link/comments/efff741a41b9ff

My suggestion about signatures

# action.yml
inputs:
  language:
    required: false
    description: 'Language of comments and release notes (e.g. `Japanese(日本語)`)'
    default: 'English'

then, the prompt will be like this (pseudocode):

if(input.language && input.language !== 'English') {
  systemMessage += `\n\nIMPORTANT: Provide your review in ${input.language}.`
}

Perhaps this line of instructions (the line with IMPORTANT in my PoC) may not be necessary if the developer chooses English.

Add ability to disable the summary

Hey, thx for the awesome GH action.

We have a use case where we don't really want the summary but want only the per-file review. It'd be great to be able to disable the summary with an option.

Feature request: Show total token and cost as comment

Feature Request:
I kindly request the implementation of a feature that enables users to view the total token count and associated cost as a comment in the PR.

Use cases:

  1. Simplify Token Management: With the feature in place, users won't have to switch between different tabs or APIs to check token usage. A simple glance at the comments section will provide the required information.

  2. Prevent Token Exhaustion: By displaying token count and cost in real-time as a comment, developers will have instant visibility into the potential token depletion and take necessary actions to avoid service disruptions.

  3. Optimize Workflows: Users can better understand which actions or workflows consume a significant number of tokens and modify them accordingly to reduce overall token consumption.

  4. Team Collaboration: When multiple team members work on a project, the token count and cost comment will serve as a shared reference point for everyone involved, avoiding unnecessary token conflicts and oversights.

Proposed Implementation:
The feature could be implemented by introducing a new comment or a comment at the end of the Action logs.

Additional Notes:
The comment displaying token count and cost could be styled differently from regular comments to make it more noticeable. It would also be beneficial to allow users to disable this feature if desired.

Implementing this feature would greatly enhance the token management capabilities, saving users time and effort in monitoring token usage while fostering a more efficient and collaborative development experience.

Thank you for your consideration.

Add option to disable the poem

The poem at the end of reviews is unnecessary and a bit off-putting. I applaud the creativity but could there be an option to avoid this without having to provide an entire custom prompt? Fully appreciate the rest of the plugin though, cheers

Failed to chat: FetchError

Hi!

I'm very interested in this action but when I run the action, this warning occurs

Warning: Failed to chat: FetchError: request to https://chat.duti.tech/api/conversation failed, reason: getaddrinfo ENOTFOUND chat.duti.tech, backtrace: FetchError: request to https://chat.duti.tech/api/conversation failed, reason: getaddrinfo ENOTFOUND chat.duti.tech
    at ClientRequest.<anonymous> (file:///home/runner/work/_actions/fluxninja/chatgpt-pr-reviewer/main/dist/index.js:25451:11)
    at ClientRequest.emit (node:events:539:35)
    at TLSSocket.socketErrorListener (node:_http_client:454:9)
    at TLSSocket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Do you know how can I solve it?
thanks!

<img src="https://avatars.githubusercontent.com/in/347564?s=41" alt="Image description" width="20" height="20"> CodeRabbit

          <img src="https://avatars.githubusercontent.com/in/347564?s=41" alt="Image description" width="20" height="20">   CodeRabbit

High-level Summary

The changes primarily involve rebranding and renaming references from openai to coderabbit. This includes updates in URLs, file paths, conversation prompts, and PR reviewer names. Additionally, new features for handling in-progress status are introduced, and the ignore keyword is updated. The external interface of the code is altered by changing the bot mention used throughout the codebase.

Files Summary
README.md, action.yml References to openai are replaced with coderabbit. The GitHub Action's name, description, branding icon, and author are updated. The system message now reflects that the AI model is called @coderabbitai.
src/commenter.ts, src/review.ts, src/review-comment.ts Changes include updating comment tags, introducing new tags for in-progress status, and modifying the ignore keyword. A new variable existingSummarizeCmtBody is added. The summary message is updated to indicate it's generated by CodeRabbit. The bot mention used in the codebase is changed from '@openai' to '@coderabbitai'.

Notes

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Ignoring further reviews

  • Type @coderabbitai: ignore anywhere in the PR description to ignore further reviews from the bot.
Files not reviewed due to simple changes (1)

Skipped review in the recent run

  • action.yml

Originally posted by @github-actions[bot] in #389 (comment)

Remove opinionated text wording comments

Some of my PRs are littered with comments such as these:
image

Email ends with a "Cheers" but is preceded by a list of order details that have colons:
image

This is such a nit:
image

The ending message is already so short!!!! What else do you want from me?!
image

Like please, I already had someone from the business team copy edit the emails. Not looking for further wording feedback from the bot.

There are two and a half amounts of the below screenshot, of these opinionated comments -- keep in mind this is what it looks like after I've manually resolved each one. The bot spams my PR and adds a lot of noise, in addition to making it more difficult to find comments from my teammates:
image

PR comments support

I like the idea of AI Agent supported code review! Giving a try to code rabbit ai now.

Generally want to reduce time when code review is triggered and focus it only on times, when humans also asked for code review.

One of the use cases highlighted is sometimes users create a PR and iteratively keep adding to it until it is fully ready for code review and even after code review changing code as well.

In that use case, the preference is to have AI code review just once. No need for summaries, release notes, nothing except code review and non trivial suggestions.

Right now using PR level comment trigger the action is skipped with the message:

Warning: Skipped: this action only works on push events or pull_request

Would it be possible add the support for PR level comments that would simply scan all changes in PR?

Here is the full trigger of the workflow we have:

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

Support for declaring a model

My team would like to test using the gpt-4-1106-preview model in our code review. Please expose the model as a parameter that can be modified

Document all GitHub Action inputs

The README does not document all inputs that this GitHub Action supports, e.g. openai_heavy_model, which is an important setting that allows users to switch between GPT3.5 and GPT4.

Estimate price of using this GitHub action

Hello mate, thanks for this awesome GitHub action!

I was checking the code of the prompts here and I was wondering if you can confirm how many tokens are you using with this prompt, please check this tool to review that.

As OpenAI explains here, more tokens === more money, so I want to estimate how many tokens are we using with this awesome tool when we create a new PR <3

Thanks for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.