{"id":13579590,"url":"https://github.com/unsafecoerce/chatgpt-action","last_synced_at":"2025-04-05T23:31:50.166Z","repository":{"id":88027466,"uuid":"606326013","full_name":"unsafecoerce/chatgpt-action","owner":"unsafecoerce","description":"A collection of ChatGPT assistants, e.g., pull request scoring, code view, labeler, assigner, etc.","archived":true,"fork":false,"pushed_at":"2023-03-21T20:06:38.000Z","size":5784,"stargazers_count":40,"open_issues_count":8,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T03:33:33.862Z","etag":null,"topics":["actions","chatgpt","chatgpt-bot","code-review","pull-request-scoring"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/chatgpt-action","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unsafecoerce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-25T06:24:24.000Z","updated_at":"2025-03-09T15:31:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6fc9e50-397a-432a-94f5-8c83648f525e","html_url":"https://github.com/unsafecoerce/chatgpt-action","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"actions/typescript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unsafecoerce%2Fchatgpt-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unsafecoerce%2Fchatgpt-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unsafecoerce%2Fchatgpt-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unsafecoerce%2Fchatgpt-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unsafecoerce","download_url":"https://codeload.github.com/unsafecoerce/chatgpt-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415783,"owners_count":20935383,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","chatgpt","chatgpt-bot","code-review","pull-request-scoring"],"created_at":"2024-08-01T15:01:40.842Z","updated_at":"2025-04-05T23:31:45.158Z","avatar_url":"https://github.com/unsafecoerce.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ChatGPT actions\n\nA collection of ChatGPT assistants, e.g., code viewer, labeler, assigner, etc.\n\n- [Overview](#overview)\n  - [Why reinvent the wheel?](#why-reinvent-the-wheel)\n  - [Features](#features)\n- [Usage](#usage)\n  - [Configuration](#configuration)\n    - [Environment variables](#environment-variables)\n    - [Inputs](#inputs)\n  - [Prompt templates](#prompt-templates)\n    - [Variables available in prompt templates](#variables-available-in-prompt-templates)\n- [Developing](#developing)\n- [FAQs](#faqs)\n  - [Review pull request from forks](#review-pull-request-from-forks)\n  - [Choose the ChatGPT API implementation](#choose-the-chatgpt-api-implementation)\n  - [Inspect the messages between ChatGPT server](#inspect-the-messages-between-chatgpt-server)\n- [License](#license)\n\n![https://github.com/unsafecoerce/chatgpt-action/pull/13](./docs/images/chatgpt-example.jpg)\n\n## Overview\n\n### Why reinvent the wheel?\n\nThere're already many [chatgpt-actions][1], why we need to reinvent the wheel?\n\n- Code review is not pull request changeset summarization\n\n  Some of existing actions send the whole pull request diff to ChatGPT, and\n  ask ChatGPT to summarize the pull request, or summarize each hunks. In\n  practice, the summarize has already done by the proposer and the code reviewer\n  is responsible for reviewing the changes, evaluate the quality, and decide\n  whether to merge the pull request.\n\n  **This action has a \"score\" action that asks ChatGPT to score the pull request,\n  and give a short comment as a explanation. That should be a \"good hint\" when\n  starting a code review.**\n\n- Leave too much comments on Github pull requests\n\n  Some of existing actions send each hunks in a pull request diff to ChatGPT,\n  and yields a comment (or comment snippet) for each hunk. That makes them in\n  practically unusable, as receiving 20+ email notification after submitting\n  a pull request is not a good experience. For the reviewer's perspective, we\n  usually just focus on the hunks that are \"too good\" or \"too bad\".\n\n  **This actions take such experience into consideration, and only leave comments\n  for the hunks that are not \"LGTM\".** (We do have an option to leave comments\n  for good hunks as well).\n\n- Lack of customization of the prompt\n\n  All of existing actions hard-coded the prompt template inside the source code\n  and there's no chance to customize the prompt. When the built-in prompt is\n  not good enough, ChatGPT responses with useless comments.\n\n  At the same time, someone may have good prompt ideas, he/she want to try using\n  ChatGPT as an AI assistant for code quality evaluation and review, but he/she\n  needs to reinvent the wheel for a new action to play on Github.\n\n  **This action makes the prompt template configurable.** With a set of variables\n  like `$title`, `$description`, `$filename`, `$patch`, you can customize the\n  message sent to ChatGPT for better experience.\n\n  Prompt engineering is an _art_ to make ChatGPT success, we encourage the community\n  to try discovering new, novel, and insightful prompts to make ChatGPT do\n  code review job better, _**without reinventing the wheel for another chatgpt-action**_.\n\n  **ANY SUGGESTIONS AND IMPROVEMENTS ARE HIGHLY APPRECIATED!!!**\n\n### Features\n\n- Scoring your pull requests\n\n  ```yaml\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          CHATGPT_ACCESS_TOKEN: ${{ secrets.CHATGPT_ACCESS_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: score\n  ```\n\n- Code review your pull requests\n\n  ```yaml\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          CHATGPT_ACCESS_TOKEN: ${{ secrets.CHATGPT_ACCESS_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: review\n          review_comment_lgtm: true\n  ```\n\n- Customizable prompt templates\n\n  ```yaml\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          CHATGPT_ACCESS_TOKEN: ${{ secrets.CHATGPT_ACCESS_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: score\n          scoring_beginning: |\n            Hi ChatGPT, I have a pull request with title \"$title\" and the description is as follows,\n\n            \u003e $description\n\n            I would like to give you the whole diff of the pull request and you need to given a score after\n            reviewing the pull request. The score should be a number between 0 and 100 and 85 means the\n            the pull request is basically acceptable. You just need to reply a number between 0 and 100,\n            e.g., \"85\", and a comment within 30 words. Reply \"OK\" to confirm.\n  ```\n\n## Usage\n\n```yaml\nname: Code Review\n\npermissions:\n  contents: read\n  pull-requests: write\n\non:\n  pull_request:\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          repository: ${{github.event.pull_request.head.repo.full_name}}\n          ref: ${{github.event.pull_request.head.ref}}\n          submodules: false\n\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          CHATGPT_ACCESS_TOKEN: ${{ secrets.CHATGPT_ACCESS_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: score\n\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          CHATGPT_ACCESS_TOKEN: ${{ secrets.CHATGPT_ACCESS_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: review\n          review_comment_lgtm: true\n```\n\n### Configuration\n\nSee also: [./action.yml](./action.yml)\n\n#### Environment variables\n\n- `GITHUB_TOKEN`\n- `CHATGPT_ACCESS_TOKEN`: ChatGPT access token, see also: https://github.com/acheong08/ChatGPT.\n\n  The access token can be easily obtained from https://chat.openai.com/api/auth/session after\n  logging into ChatGPT.\n\n- `OPENAI_API_KEY`: use this to authenticate with OpenAI API, official ChatGPT's behavior using\n  `text-davinci-003`, see also: https://github.com/transitive-bullshit/chatgpt-api\n\nNote that `CHATGPT_ACCESS_TOKEN` and `OPENAI_API_KEY` are not both required. Inside this action,\nunofficial ChatGPT is preferred if `CHATGPT_ACCESS_TOKEN` exists. Note that the `CHATGPT_ACCESS_TOKEN`\ncan expire frequently, so `OPENAI_API_KEY` should be more convenient if its cost is affordable\nto you.\n\n#### Inputs\n\n- `action`: The action to run, currently can be `review`, `score`\n- `debug`: Enable debug mode, will show messages and responses between ChatGPT server in CI logs.\n- `chatgpt_reverse_proxy`: The URL of the ChatGPT reverse proxy\n- `review_comment_lgtm`: Leave comments even the patch is LGTM\n- `path_filters`: Rules to filter files to be reviewed.\n\n### Prompt templates:\n\nSee also: [./action.yml](./action.yml)\n\n- `review_beginning`: The beginning prompt of a code review dialog\n- `review_patch`: The prompt for each chunks/patches\n- `scoring_beginning`: The beginning prompt for scoring a pull request\n- `scoring`: The prompt for the whole pull request\n\n#### Variables available in prompt templates\n\n- pull request score (`action: score`):\n\n  - `$title`: Title of the pull requests.\n  - `$description`: The description of the pull request.\n  - `$diff`: The whole diff of the pull request.\n\n- code review (`action: review`):\n\n  - `$title`: Title of the pull requests.\n  - `$description`: The description of the pull request.\n  - `$filename`: Filename of the file being viewed.\n  - `$patch`: The diff contents of the patch being viewed.\n\nAny suggestions or pull requests for improving the prompts are highly appreciated.\n\n## Developing\n\n\u003e First, you'll need to have a reasonably modern version of `node` handy, tested with node 16.\n\nInstall the dependencies\n\n```bash\n$ npm install\n```\n\nBuild the typescript and package it for distribution\n\n```bash\n$ npm run build \u0026\u0026 npm run package\n```\n\n## FAQs\n\n### Review pull request from forks\n\nGithub Actions limits the access of secrets from forked repositories. To enable\nthis feature, you need to use the `pull_request_target` event instead of\n`pull_request` in your workflow file. Note that with `pull_request_target`, you\nneed extra configuration to ensure checking out the right commit:\n\n```yaml\nname: Code Review\n\npermissions:\n  contents: read\n  pull-requests: write\n\non:\n  pull_request_target:\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          repository: ${{github.event.pull_request.head.repo.full_name}}\n          ref: ${{github.event.pull_request.head.ref}}\n          submodules: false\n\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: score\n\n      - uses: unsafecoerce/chatgpt-action@main\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n        with:\n          debug: false\n          action: review\n          review_comment_lgtm: true\n```\n\nSee also: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target\n\n### Choose the ChatGPT API implementation\n\nThe javascript's [chatgpt][2] package provides two implementations of the ChatGPT API:\n\n- `ChatGPTAPI`: official ChatGPT using the OpenAI's `text-davinci-003`.\n  - not free\n  - requires `OPENAI_API_KEY`\n- `ChatGPTUnofficialProxyAPI`: unofficial ChatGPT models, rely on third-party server and is\n  rate limited.\n  - free\n  - requires `CHATGPT_ACCESS_TOKEN`\n  - the proxy server is configurable using `chatgpt_reverse_proxy`\n\nIf both environment variables `OPENAI_API_KEY` and `CHATGPT_ACCESS_TOKEN` exists, we\nprefer the `ChatGPTUnofficialProxyAPI` implementation.\n\n### Inspect the messages between ChatGPT server\n\nSet `debug: true` in the workflow file to enable debug mode, which will show the messages\n\n[1]: https://github.com/marketplace?type=\u0026verification=\u0026query=chatgpt-action+\n[2]: https://www.npmjs.com/package/chatgpt\n\n## License\n\nThe MIT License (MIT), Copyright (c) 2023 Tao He.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funsafecoerce%2Fchatgpt-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funsafecoerce%2Fchatgpt-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funsafecoerce%2Fchatgpt-action/lists"}