Giter Site home page Giter Site logo

anc95 / chatgpt-codereview Goto Github PK

View Code? Open in Web Editor NEW
3.7K 18.0 336.0 4.26 MB

🐥 A code review bot powered by ChatGPT

Home Page: https://github.com/apps/cr-gpt

License: ISC License

Dockerfile 0.01% JavaScript 99.85% HTML 0.01% TypeScript 0.08% C 0.06%
chatgpt codereview probot

chatgpt-codereview's Introduction

Anurag's GitHub stats

wechat: anc-95

chatgpt-codereview's People

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-codereview's Issues

OPEN_API_KEY - Secret vs Variable

Is there any reason why the OPEN_API_KEY is intended to be a variable rather than a secret? I think the latter would be more secure and achieves the same thing.

Code review will not fail automatically in case of issues

image

For some reason, there was an issue with the review
and action didn't cancel until the 6-hour timeout had elapsed

@@ -6,6 +6,7 @@
import lombok.Getter;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Getter
@Builder(access = AccessLevel.PRIVATE)
@@ -21,6 +22,8 @@ public class SubscriptionPlanDto {
    public static SubscriptionPlanDto NONE() {
        // TODO: 구독 없는 경우 어떻게 처리? (플로우)
        return SubscriptionPlanDto.builder()
                .planCode("")
                .price(BigDecimal.ZERO)
                .name("이용중인 서비스 없음")
                .isActive(false)
                .build();
@@ -34,7 +37,7 @@ public static SubscriptionPlanDto of(SubscriptionPlan plan) {
                .description(plan.getDescription())
                .planCode(plan.getPlanCode())
                .price(plan.getPrice())
                .priceIncludeVat(plan.getPrice().multiply(BigDecimal.valueOf(1.1)))
                .priceIncludeVat(plan.getPrice().multiply(BigDecimal.valueOf(1.1)).setScale(0, RoundingMode.FLOOR)) // 1원단위 절삭
                .isActive(plan.getIsActive())
                .build();
    }

This code that tried, just simple

`OPENAI_API_KEY` 检测失败

求助~

之前添加了github/action后,已经成功运行过一次review,但后来我更换了一次openai key之后,review又失败了,log里看到获取的OPENAI_API_KEY是空的:

image

但实际上已经进行了设置:

image

关于文件长度限制

看起来该工具是将每个文件单独review,并且直接跳过长度大于4000的文件,是否有更好的方式,比如对总长不超过4000的文件合并review,对超长文件切分review?

Language is not support

yaml

name: Code Review

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, reopened]

jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: anc95/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LANGUAGE: Chinese


run

Bellow is the code patch, please help me do a brief code review, if any bug risk and improvement suggestion are welcome
class ElasticQueryServiceImpl(

 override fun addSplitListQuery(value: String?, fieldName: String): BoolQueryBuilder? {
     if (value.isNullOrEmpty()) return null
   val codes = listOf(value.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray())
    val codes = value.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
     val boolQueryBuilder = QueryBuilders.boolQuery()
     codes.forEach { boolQueryBuilder.should(QueryBuilders.matchQuery(fieldName, it).operator(Operator.AND)) }
     return boolQueryBuilder

code-review cost: 4.652s
gpt cost: 5.9


result

!

Code Review:

The code looks generally good. The changes made are valid and the logic is sound.

However, there is one small bug risk I see. The listOf() function creates an immutable list, but the code expects to modify it, so it should be changed to a mutable list. Also, the value.split() returns an array of strings, so the codes variable should be declared as an array instead of a list.

Overall, the code looks good and should work as expected.

Customizable prompt?

Hey there! Great project, it seems to work as intended and the CRs are very useful.
For our use case, and I imagine for many others as well, it would be beneficial to be able to customize the prompt.
The easiest solution would be to expose it as an env var, e.g.: OPEN_API_PROMPT or similar.
Thoughts? Let me know if you want me to make a PR.

Enable to make GPT review in draft

Motivation

I would like to make the Action to review even in draft. If a pull request gets ready to review, humans get in the loop of the review. Developers have to pass code refined with GPT to humans beforehand.

https://github.com/anc95/ChatGPT-CodeReview/blob/main/src/bot.ts#L58

Possible Solution

We may pass an input or an environment variable to the Action whether or not we run the Action in draft.

Aside from that, it would be good to clearly define inputs and outputs of the Action in action.yml so that users of the Action can easily understand them.

Is this bot a good choice for English grammar review

Enabled this bot in a documentation website with markdowns files, but it seems that the bot does more code review (which isn't needed for our use case) than writing review, such as spelling and grammar.

Is our use case not appropriate for this bot or is there any config we haven't explored?

TIA!

在批量提交多个commit时,似乎可能只评审其中的最后一个commit内容

在同一个PR的第二次提交中,批量提交了多个commit,但bot没有产生任何回复,只有最后一个commit上面显示了一个√。
然后再次提交一个commit(修改的文件在之前的commit已经出现过),bot对该文件之前提交的内容进行了review,它原本应该出现在上一轮的提交中才对。

Github Actions version doesn't seem to have enough permission to comment by default? Suggestions?

I tried to switch from GitHub Apps version to GitHub Actions version, but it seems default GITHUB_TOKEN won't have enough permission to comment, not sure if using a PAT would be a good idea, anyone got the same issue and how do you deal with it? Thanks!

https://github.com/transmission-remote-gui/transgui/actions/runs/5038925037/jobs/9036731668?pr=1302

env:
    GITHUB_TOKEN: ***
    OPENAI_API_KEY: 
    MODEL: gpt-4
    top_p: 1
    temperature: 0.2
Error: Resource not accessible by integration
{
  name: 'event',
  id: '5038925037',
  err: {
    type: 'RequestError',
    message: 'Resource not accessible by integration',
    stack: 'HttpError: Resource not accessible by integration\n' +
      '    at /home/runner/work/_actions/anc95/ChatGPT-CodeReview/main/action/index.cjs:4070:21\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
      '    at async Job.doExecute (/home/runner/work/_actions/anc95/ChatGPT-CodeReview/main/action/index.cjs:34389:18)',
    name: 'HttpError',
    status: 403,
    response: {
      url: 'https://api.github.com/repos/transmission-remote-gui/transgui/issues/1302/comments',

The 429 too many request error

The 429 too many request error appears in the open api, is it a bug? Or should I use the paid version?
this is error code

Error: OpenAI error 429: {
        "error": {
            "message": "You exceeded your current quota, please check your plan and billing details.",
            "type": "insufficient_quota",
            "param": null,
            "code": null
        }
    }
        at /home/runner/work/_actions/anc95/ChatGPT-CodeReview/main/action/index.cjs:153249:29
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
{

this is my yml code

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/ChatGPT-CodeReview@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          LANGUAGE: Korean
          MODEL: gpt-3.5-turbo
          top_p: 1
          temperature: 1

bug: do not work on new commit to pull_request

refer to Certseeds/openpgpage#4
use actions to trigger code-review

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, reopened, synchronize]

jobs:
  test:
    if: github.repository == 'Certseeds/openpgpage'
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/ChatGPT-CodeReview@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.CHATGPT_SESSION_TOKEN }}

1st commit trigger a review, get a meaningful response.
2nd force-push trigger a review, find a meaingful response too.
but the 3rd and 4th push can trigger actions but do not find response, is that corect?
ps:
the 3rd action https://github.com/Certseeds/openpgpage/actions/runs/4315833869
the 4th action https://github.com/Certseeds/openpgpage/actions/runs/4315849686

如何配置中文回答?

配置了 LANGUAGE: Chinese,依然是英文回答

ZhongAnTech/zarm#1078

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, reopened]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          LANGUAGE: Chinese

Is the LANGUAGE environment variable working properly? I would like to receive code reviews in Korean.

Hi there. Thank you for making such a great app, but I would like to get a code review in Korean.
When I looked at the code in the repo, it seems that I can register the LANGUAGE configuration file and process it in the desired language.

But when I test it several times, the code review message is still written in English only.

It would be helpful if the README.md documentation also described how to set the language.

Thanks.

Run only on labeled PRs

Hey,

I love it! Awesome job. I'm trying to run it only when I set a particular label for the PR (to save tokens for small PRs).

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, reopened, labeled]

jobs:
  test:
    if: github.event.label.name == 'GPT-CR'
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/ChatGPT-CodeReview@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          # Optional
          LANGUAGE: English

I also get the action triggered, but for some reason, no feedback is posted on the PR.
Here is the action result:
image

Any idea why no feedback is provided?

关于频率限制

openai 本身有频率限制

免费试用用户现在除了 3 次请求 / 分钟外,还有个 token 数量限制,每分钟最多发送 4 万个 tokens

程序有避让措施吗?

Customs LLMs

Do you have any plans to add configuration options that would allow the use of custom LLMs in future versions?
I recently published a package llm-client that can be very helpful in enabling the support to run other LLM models, including OpenAI, Google, AI21, HuggingfaceHub, Aleph Alpha, Anthropic, Local models with transformers.

小白使用求助

image
你好,我是一位小开发人员,我看到你这个机器人比较感兴趣,因此我计划做两件事:
1、先体验使用看看这个机器人是如何运行的,因此我按照ReadMe中的描述,选择了 Self-hosting 模式进行安装在一台 linux 服务器上,但是安装过程报错了,在执行第二步的时候 回显是 undefined ,我不知道是否是正常的,在执行第三步的时候就直接报错了,能帮看看是啥原因吗?
2、第二件事就是,我使用的是Gerrit 代码托管平台,我想把你这个机器人改造成我的一个小服务,然后在我往 gerrit 上提交代码的时候,调用改造后的机器人接口,也能实现自动添加 reviewer 的功能,那么我需要具体怎么做,能详细指导一下吗?

[Feature] Japanese language support

Background

There are many people using this workflow in Japan, and I would like to create a Japanese version of the README since it does not exist.

WHAT

make README (Japanese ver)

Feature request(GitHub App): Specify label name to be reviewed in .env

Purpose

As per Github Actions version, it would be convenient if you can specify the label name to be reviewed in GitHub App version.

Suggestion

Here's my implementation suggestion.

      const target_label = process.env.TARGET_LABEL
      if (target_label && pull_request.labels.every(label => label.name !== target_label)) {
        return "no target label attached"
      }

I also tried to make a PR, but npm test doesn't work for my environment. (Windows / WSL2)

How about excluding removed and renamed 'files' from code reviews?

Hello!
I'm using your app really really well.
Let me give you a suggestion.

Current Issue:

The code review conducted by the app includes deleted files, which is not necessary. In the code file src/bot.ts, the changedFiles variable obtained from the data.data object includes files with changes, including deleted files. The file.status property can be one of added, modified, removed, renamed, or copied. Therefore, it is suggested to exclude the files with the removed and renamed status from the changeFiles. It may also be helpful to add an environment variable to control this behavior.

// src/bot.ts

let { files: changedFiles, commits } = data.data; // 68 line

Proposed Solution:

Exclude the files with the removed and renamed status from the changeFiles function, and consider adding an environment variable to control this behavior.

Using `CONTRIBUTION_GUIDELINE.md` in the prompt message

I would like to update the prompt to use the contribution guidelines and then review the PR based on that. This should be configurable and should be read by the bot once.

contribution_guideline: ./docs/Contributing.md

Ask for asnwer, pls help me

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Could you let me know, why my github demo project still get the message?

Action does not properly get triggered upon being integrated with different actions

Background

I have succeeded in integrating this via github actions with the basic, recommended commands.

I wanted to take a step further, and make this be triggered only when I have added a specific label to the PR itself.

mattverse/osmosis#12

This is the sample integration I have been working on.
Notice that this is almost identical to the original example provided in this repository, the only difference is that it has an if statement for the job to run.

Also notice how the action itself has been properly started, as we can know from run https://github.com/mattverse/osmosis/actions/runs/4604642813/jobs/8135769907?pr=12.

Would there be specific reason why adding on new logic on top of this gh action might be causing this flakiness?

Internal Server Error

I have installed the tool on my own server. The tool throws an error while creating a new pull request on GitHub

image

Can't not build Docker image directly

Looks like package-lock.json is missing, or should we switch to yarn in Dockerfile, as there is yarn.lock file?

~/ChatGPT-CodeReview $ docker build -t before .
Sending build context to Docker daemon  17.38MB
Step 1/8 : FROM node:18-slim
18-slim: Pulling from library/node
9e3ea8720c6d: Pull complete 
22cee24855b2: Pull complete 
1f1858138a90: Pull complete 
6e736ef1cbb5: Pull complete 
c4ef7605ff4f: Pull complete 
Digest: sha256:2ff9841de879f1a2d2d8ef83183c2d93435c451a36d6cfb37b3331d1386c00f8
Status: Downloaded newer image for node:18-slim
 ---> 249e97c8a29e
Step 2/8 : WORKDIR /usr/src/app
 ---> Running in eb421e4594e0
Removing intermediate container eb421e4594e0
 ---> d958cab7c813
Step 3/8 : COPY package.json package-lock.json ./
COPY failed: file not found in build context or excluded by .dockerignore: stat package-lock.json: file does not exist

OPENAI_API_KEY configuration error: Issues during GitHub Action execution

I have a problem with OPENAI_API_KEY not being recognized.

Screenshot 2023-04-10 at 00 30 56

  • In the first attempt, I set the OPENAI_API_KEY variable in the Variables tab. The GitHub Action runs, but OPENAI_API_KEY is empty, and the error message says it cannot be found.
    Screenshot 2023-04-10 at 00 31 39

  • In the second attempt, I set up the YAML file like this and pushed it, but OPENAI_API_KEY is still empty.

  • Despite setting up the OPENAI_API_KEY in Actions secrets and variables, you are still encountering an issue where the OPENAI_API_KEY value is not being recognized.

name: Code Review

permissions:
  contents: read
  pull-requests: write

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: anc95/ChatGPT-CodeReview@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Screenshot 2023-04-10 at 00 50 09

Screenshot 2023-04-10 at 00 33 36

Please tell me how to solve the problem.🥲

安全疑问

想问下会有安全问题吗,chatgpt联网,代码review的时候会有些代码暴露,假如我要把这个引入公司,领导问我这个安全问题,我该怎么回答呢

Support in Bitbucket

Hi, all.
We are using bitbucket in our company, so I would like to ask if you will consider supporting bitbucket.
Thanks.

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.