-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7b68aa
Showing
24 changed files
with
81,210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lib/ | ||
dist/ | ||
node_modules/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Dependency directory | ||
node_modules | ||
|
||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# OS metadata | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore built ts files | ||
__tests__/runner/* | ||
|
||
# IDE files | ||
.idea | ||
.vscode | ||
*.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/ | ||
node_modules/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 140, | ||
"singleQuote": true, | ||
"semi": true, | ||
"useTabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": false, | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "none", | ||
"bracketSpacing": true, | ||
"bracketSameLine": true, | ||
"arrowParens": "avoid", | ||
"proseWrap": "always", | ||
"htmlWhitespaceSensitivity": "css", | ||
"endOfLine": "lf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# CodeGPT PR Assistant | ||
|
||
## Description | ||
|
||
The CodeGPT PR Assistant is a GitHub Action designed to review pull requests and provide code suggestions, helping developers improve their code quality and consistency. It integrates with GitHub Actions to automatically analyze and comment on new pull requests and commits. | ||
|
||
## Features | ||
|
||
- Review pull request changes automatically. | ||
- Provide feedback and code suggestions. | ||
|
||
## Required ENV variables | ||
|
||
- `OPENAI_API_KEY`: The OpenAI API key needed to interact with language models. This var is **required**. | ||
- `GITHUB_TOKEN`: The GitHub API key needed to interact with GitHub's API. Usually available on your env. This var is **required**. | ||
|
||
## Inputs | ||
|
||
- `OPENAI_ASSISTANT_ID`: The ID of the OpenAI assistant being used. This input is **required**. | ||
|
||
## Outputs | ||
|
||
- `response`: The output message from processing the event, which includes feedback or code suggestions based on the pull request content. | ||
|
||
## Usage | ||
|
||
To use this action in your GitHub workflows, add the following step: | ||
|
||
```yaml | ||
name: Ask CodeGPT for feedback | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
process-events: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Run CodeGPT | ||
if: github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && contains(github.event.comment.body, 'CodeGPT') && !contains(github.event.comment.body,'The following is a message from CodeGPT:')) | ||
uses: isat/codegpt@v1.0.0 | ||
with: | ||
OPENAI_ASSISTANT_ID: 'YOUR_ASSISTANT_ID_GOES_HERE' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
``` | ||
Don't forget to enable `Read and Write` permissions on your Repo/Org's `Workflow permissions` if you haven't already. | ||
|
||
Each repo can also have a `CODEGPT.md` file, which will be passed as context to the Bot. | ||
|
||
These are the recommended base instructions for your assistant. | ||
|
||
``` | ||
You will be resposible for reviewing pull requests. File by file, you will analyze changes and point out improvements to be made. | ||
|
||
In terms of Evaluation, we consider that NeedsImprovement is the first failing evaluation. Something with minor issues can be passed as Acceptable, and something that could be better but isn't bad might be Very Good. Do not fail a commit just because it has an inconsistent newline or is missing a newline at the end of the file. | ||
|
||
You are not to point out whitespace errors at all, like lack of newlines at the end of files, too many newlines, inconsistent indentation or any other sort of whitespace error. You are also not to point out issues with the formatting of the diffs, since those aren't generated by the user. | ||
|
||
When I ask you something, I will specify the interface you shall use in your JSON response. | ||
``` | ||
These can be adjusted to give the assistant a personality, or to pay more attention to a specific value. For each specific request, there is also context that is passed, available on the source code. You can fork this repo to change this specific context. | ||
## How it works | ||
This GitHub Action uses [Open AI's Assistants](https://platform.openai.com/docs/assistants/overview) behind the scenes, which are, at the time of writing this, a beta feature. Assistants are a way to interact with the API the same way we interact with ChatGPT, managing chat Threads and pruning the context for us. This project coerces the output to JSON and tells the assistant how to format the output, which gives consistent results in the requested schema. | ||
To better manage the context, the Action splits the PR into multiple parts: | ||
![image](https://github.com/isat/codegpt/assets/26225974/cf9ec4fc-f804-41e5-b644-8215728d107b) | ||
Each of these parts is analyzed in a different thread, concurrently. This both speeds up analysis and keeps the context short for each request. | ||
To make sure we get relevant feedback, we coerce the assistant to give feedback in a specific schema, which can be visualized globally below: | ||
![image](https://github.com/isat/codegpt/assets/26225974/39627f75-8f87-49a9-859b-df6ab86a188e) | ||
The global flow is summarized below: | ||
![image](https://github.com/isat/codegpt/assets/26225974/66afebec-a485-4321-8973-a2093ddeb9cf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'CodeGPT PR Assistant' | ||
description: 'A helpful assistant that reviews pull requests and provides code suggestions.' | ||
author: 'PedroCavalheiro@isat' | ||
inputs: | ||
OPENAI_ASSISTANT_ID: | ||
description: 'ID of the OpenAI assistant.' | ||
required: true | ||
outputs: | ||
response: | ||
description: 'The output message from processing the event.' | ||
runs: | ||
using: node20 | ||
main: dist/index.js | ||
branding: | ||
icon: 'code' | ||
color: 'blue' |
Oops, something went wrong.