Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t1 #589

Closed
wants to merge 132 commits into from
Closed

t1 #589

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
24583b0
Publish GitHub review comments with single API call
zmeir Jul 17, 2023
8ae3c60
In case of new file creation by the MR there is a 404 error on file r…
Jul 17, 2023
6f1b418
Merge pull request #79 from patryk-kowalski-ds/deepsense.ai/gitlab-pr…
mrT23 Jul 18, 2023
4d92e7d
Update README.md
GadiZimerman Jul 18, 2023
9783482
Update README.md
GadiZimerman Jul 18, 2023
87ea017
Update README.md
okotek Jul 18, 2023
9e0f5f0
Merge pull request #78 from Codium-ai/tr/agent_logic
okotek Jul 18, 2023
90f97b0
Lint fixes
okotek Jul 18, 2023
e5a8ed2
Merge pull request #82 from Codium-ai/ok/lint
okotek Jul 18, 2023
7d10899
Merge remote-tracking branch 'origin/main' into zmeir-publish_inline_…
okotek Jul 18, 2023
1309211
Move the new git provider function to the abstract interface
okotek Jul 18, 2023
05e4e09
Lint
okotek Jul 18, 2023
ffd11ae
Merge pull request #81 from Codium-ai/GadiZimerman-patch-1
mrT23 Jul 18, 2023
f2b74b6
support gitlab describe function
hussam789 Jul 18, 2023
6c42a47
Merge pull request #76 from zmeir/zmeir-publish_inline_comments_singl…
hussam789 Jul 18, 2023
8fb9aff
add try catch
hussam789 Jul 18, 2023
7f0a96d
readme
hussam789 Jul 18, 2023
90c045e
Update README.md
GadiZimerman Jul 18, 2023
5d45632
Performance improvement: Filter out bad files before getting their he…
hussam789 Jul 18, 2023
d6d4427
Merge pull request #84 from Codium-ai/GadiZimerman-patch-1
okotek Jul 18, 2023
2e36fce
Merge pull request #83 from Codium-ai/hl/gitlab_description
hussam789 Jul 18, 2023
3efe08d
Merge pull request #85 from Codium-ai/hl/always_filer_bad_extensions
hussam789 Jul 18, 2023
5c5015b
Update README.md
GadiZimerman Jul 18, 2023
c507785
bugfix
mrT23 Jul 18, 2023
77f243b
Allow passing CLI args (helps with debugging)
zmeir Jul 18, 2023
0396e10
Add configuration to request a score for the PR
zmeir Jul 18, 2023
6d91f44
Added configuration option to control publishing review progress
zmeir Jul 18, 2023
dc67e6a
Support deploying pr-agent on AWS Lambda
YuviGold Jul 18, 2023
bdf7eff
Merge pull request #87 from Codium-ai/tr/bug_fix
mrT23 Jul 18, 2023
dc4bf13
Add Incremental Review
hussam789 Jul 18, 2023
5f36f0d
Merge commit 'bdf7eff7cd0a8894c3e66e49bdf89f27da1bfcb4' into hl/incre…
hussam789 Jul 18, 2023
f73cddc
Change Review title when
hussam789 Jul 18, 2023
a47fa34
Merge pull request #88 from zmeir/zmeir-cli_args
mrT23 Jul 19, 2023
ccddbec
num_code_suggestions=0 for review
mrT23 Jul 19, 2023
2e832b8
Merge pull request #86 from Codium-ai/GadiZimerman-patch-1
okotek Jul 19, 2023
f8aea90
Add example output
zmeir Jul 19, 2023
fc8494d
Rephrase score description in promt
zmeir Jul 19, 2023
e17dd66
Disable score review by default
zmeir Jul 19, 2023
370520d
Update docker/Dockerfile.lambda
YuviGold Jul 19, 2023
8868c92
Merge branch 'main' into zmeir-review_score
zmeir Jul 19, 2023
2f55800
Update INSTALL.md, add notes about injecting secrets
okotek Jul 19, 2023
5bc2ef1
Merge pull request #92 from YuviGold/deploy-on-lambda
okotek Jul 19, 2023
3b27c83
Merge remote-tracking branch 'origin/main' into ok/update_readme
okotek Jul 19, 2023
97bfee4
minor fixes
mrT23 Jul 19, 2023
7e2449b
Changed score type to int
zmeir Jul 19, 2023
6e26ad0
Merge branch 'main' into zmeir-review_score
zmeir Jul 19, 2023
8038b6a
refactor and clean
hussam789 Jul 19, 2023
7abbe08
Merge pull request #95 from Codium-ai/tr/disable_review_suggestiosn
mrT23 Jul 19, 2023
c47e74c
Merge commit '5bc2ef1eff1f570779191a8f3c7a562f5b8fe230' into hl/incre…
hussam789 Jul 19, 2023
17b40a1
Merge commit '7abbe08ff15d31c7e20de6d88638bfe27430c2f4' into hl/incre…
hussam789 Jul 19, 2023
7fdbd6a
Update utils.py
mrT23 Jul 19, 2023
1f373d7
Update README.md
hussam789 Jul 19, 2023
3420853
Merge pull request #98 from Codium-ai/hl/update_readme
mrT23 Jul 19, 2023
d1586dd
Merge pull request #97 from Codium-ai/mrT23-patch-1
hussam789 Jul 19, 2023
523839b
Merge commit 'd1586ddd77b86f0d3b29aee3370f29624799e388' into hl/incre…
hussam789 Jul 19, 2023
36be79e
ignore merge from main
hussam789 Jul 19, 2023
3326327
More refactoring....
hussam789 Jul 19, 2023
1e96247
Merge pull request #94 from Codium-ai/hl/incremental_review
hussam789 Jul 19, 2023
fc24b34
Merge pull request #96 from Codium-ai/ok/update_readme
okotek Jul 19, 2023
577f24d
Merge pull request #89 from zmeir/zmeir-review_score
mrT23 Jul 19, 2023
ee2c00a
split(" ") -> split()
okotek Jul 19, 2023
0985db4
Update help
okotek Jul 19, 2023
67c61e0
Update help
okotek Jul 19, 2023
4c36fb4
args bug
okotek Jul 19, 2023
df25a3e
typo
okotek Jul 19, 2023
fe29ce2
Update README.md
hussam789 Jul 19, 2023
23ed255
Update README.md
hussam789 Jul 19, 2023
d89792d
PR Type label
mrT23 Jul 19, 2023
a2eb2e4
Update pr_agent/git_providers/github_provider.py
mrT23 Jul 19, 2023
3d5d517
code suggestions
mrT23 Jul 19, 2023
329e228
Merge pull request #100 from Codium-ai/tr/describe_labels
mrT23 Jul 19, 2023
e2a4cd6
docstring
mrT23 Jul 20, 2023
12e51bb
Merge remote-tracking branch 'origin/main' into tr/docstring
mrT23 Jul 20, 2023
6cd38a3
fix question cli
hussam789 Jul 20, 2023
7c3188a
Merge pull request #102 from Codium-ai/hl/question_fix
mrT23 Jul 20, 2023
cd04380
Merge pull request #101 from Codium-ai/tr/docstring
mrT23 Jul 20, 2023
12a7e1c
Update README.md
mrT23 Jul 20, 2023
050bb60
Merge pull request #103 from Codium-ai/mrT23-patch-1
okotek Jul 20, 2023
3cfbba7
Fix README
okotek Jul 20, 2023
6134c2f
Merge remote-tracking branch 'origin/main'
okotek Jul 20, 2023
2f9546e
Retry on rate limit error on OpenAI calls
okotek Jul 20, 2023
2e24686
Retry on rate limit error on OpenAI calls
okotek Jul 20, 2023
0b63d4c
README update
okotek Jul 20, 2023
f5d5008
README update
okotek Jul 20, 2023
f825f6b
README update
okotek Jul 20, 2023
f87fdd8
README update
okotek Jul 20, 2023
6731a76
README update
okotek Jul 20, 2023
9f67d07
README update
okotek Jul 20, 2023
23fa834
Merge pull request #106 from Codium-ai/ok/readme_update
okotek Jul 20, 2023
a71a127
Move hard-coded language configurations to a configuration file.
patryk-kowalski-ds Jul 20, 2023
1f0df47
Update README.md
mrT23 Jul 20, 2023
9adec7c
README update
okotek Jul 20, 2023
79cb94b
Add use_extra_bad_extensions to configuration.toml
patryk-kowalski-ds Jul 20, 2023
fdf6a3e
Merge pull request #107 from Codium-ai/mrT23-patch-1
okotek Jul 20, 2023
e99f9fd
Update README.md
mrT23 Jul 20, 2023
1ea23ca
Merge pull request #105 from Codium-ai/ok/retry_on_rate_limit_error
okotek Jul 20, 2023
63c4c7e
Merge pull request #90 from zmeir/zmeir-output_progress
okotek Jul 20, 2023
05f29cc
Fix TypeError for GitlabProvider
Jul 20, 2023
057bb39
Merge pull request #109 from Codium-ai/mrT23-patch-1
mrT23 Jul 20, 2023
d5b9be2
Merge pull request #110 from linuxlewis/main
mrT23 Jul 20, 2023
86fd84e
Update action name
okotek Jul 20, 2023
f0a17b8
Merge remote-tracking branch 'origin/main'
okotek Jul 20, 2023
74572e1
Update action.yaml
okotek Jul 20, 2023
bbdfd2c
Merge pull request #108 from patryk-kowalski-ds/deepsense.ai/configur…
mrT23 Jul 21, 2023
f5e2838
refactor
mrT23 Jul 21, 2023
f4a226b
Merge pull request #113 from Codium-ai/tr/cli_refactor
mrT23 Jul 23, 2023
2f83e77
Update README.md gifs
almog-lv Jul 23, 2023
76e00ac
Update INSTALL.md
okotek Jul 23, 2023
d1b91b0
Update INSTALL.md
okotek Jul 23, 2023
fca78cf
Merge pull request #114 from Codium-ai/update-readme-gifs
mrT23 Jul 23, 2023
21ced18
Merge pull request #115 from Codium-ai/ok/readme_update
okotek Jul 23, 2023
35dac01
Update README.md
almog-lv Jul 23, 2023
e34f9d8
Merge pull request #116 from Codium-ai/fix-describe-gif
mrT23 Jul 23, 2023
02a1d8d
Add support for fallback models
okotek Jul 23, 2023
321f7bc
Merge pull request #117 from Codium-ai/ok/fallback_models
okotek Jul 23, 2023
1e97236
Add support for fallback models
okotek Jul 23, 2023
42e3266
Merge pull request #118 from Codium-ai/ok/fallback_models
okotek Jul 23, 2023
3235867
Reduce the number of GitHub API calls when pushing code suggestions
zmeir Jul 23, 2023
32151e3
Temporarily remove gitlab polling server until a rewrite is ready
okotek Jul 23, 2023
54b021b
Merge pull request #120 from Codium-ai/ok/remove_gitlab_polling
okotek Jul 23, 2023
e8aa33f
Update README.md
almog-lv Jul 23, 2023
cd51bef
Merge pull request #119 from zmeir/zmeir-code_suggestions_single_api_…
okotek Jul 23, 2023
1eac324
Merge pull request #121 from Codium-ai/update-gifs
okotek Jul 23, 2023
0412d7a
Update README.md
almog-lv Jul 23, 2023
8e5498e
Merge pull request #122 from Codium-ai/update-readme-gifs-2
okotek Jul 23, 2023
cd8bbbf
bugfix
Jul 23, 2023
1f98738
Merge pull request #124 from Xyand/bugfix/mising_model
mrT23 Jul 24, 2023
1bf27c3
_prepare_pr_answer
mrT23 Jul 24, 2023
b9c25e4
On /describe, preserve the current labels
okotek Jul 24, 2023
dd8f6eb
Merge pull request #126 from Codium-ai/ok/preserve_labels
mrT23 Jul 24, 2023
4d84f76
_get_prediction
mrT23 Jul 24, 2023
abca2fd
Merge remote-tracking branch 'origin/main' into tr/code_enhancment
okotek Jul 24, 2023
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
1 change: 1 addition & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ You can select your git_provider with the flag `git_provider` in the `config` se
You can enable/disable the different PR Reviewer abilities with the following flags (`pr_reviewer` section):
```
require_focused_review=true
require_score_review=true
require_tests_review=true
require_security_review=true
```
Expand Down
52 changes: 45 additions & 7 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
# Edit .secrets.toml file
```

4. Run the appropriate Python scripts from the scripts folder:
4. Add the pr_agent folder to your PYTHONPATH, then run the cli.py script:

```
export PYTHONPATH=[$PYTHONPATH:]<PATH to pr_agent folder>
python pr_agent/cli.py --pr_url <pr_url> review
python pr_agent/cli.py --pr_url <pr_url> ask <your question>
python pr_agent/cli.py --pr_url <pr_url> describe
Expand Down Expand Up @@ -149,16 +150,35 @@ git clone https://github.com/Codium-ai/pr-agent.git
```

5. Copy the secrets template file and fill in the following:
```
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
# Edit .secrets.toml file
```
- Your OpenAI key.
- Set deployment_type to 'app'
- Copy your app's private key to the private_key field.
- Copy your app's ID to the app_id field.
- Copy your app's webhook secret to the webhook_secret field.

```
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
# Edit .secrets.toml file
```
- Set deployment_type to 'app' in [configuration.toml](./pr_agent/settings/configuration.toml)

> The .secrets.toml file is not copied to the Docker image by default, and is only used for local development.
> If you want to use the .secrets.toml file in your Docker image, you can add remove it from the .dockerignore file.
> In most production environments, you would inject the secrets file as environment variables or as mounted volumes.
> For example, in order to inject a secrets file as a volume in a Kubernetes environment you can update your pod spec to include the following,
> assuming you have a secret named `pr-agent-settings` with a key named `.secrets.toml`:
```
volumes:
- name: settings-volume
secret:
secretName: pr-agent-settings
// ...
containers:
// ...
volumeMounts:
- mountPath: /app/pr_agent/settings_prod
name: settings-volume
```

> Another option is to set the secrets as environment variables in your deployment environment, for example `OPENAI.KEY` and `GITHUB.USER_TOKEN`.

6. Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:

Expand All @@ -169,6 +189,7 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository

7. Host the app using a server, serverless function, or container environment. Alternatively, for development and
debugging, you may use tools like smee.io to forward webhooks to your local machine.
You can check [Deploy as a Lambda Function](#deploy-as-a-lambda-function)

8. Go back to your app's settings, and set the following:

Expand All @@ -178,3 +199,20 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository
9. Install the app by navigating to the "Install App" tab and selecting your desired repositories.

---

#### Deploy as a Lambda Function

1. Follow steps 1-5 of [Method 5](#method-5-run-as-a-github-app).
2. Build a docker image that can be used as a lambda function
```shell
docker buildx build --platform=linux/amd64 . -t codiumai/pr-agent:serverless -f docker/Dockerfile.lambda
```
3. Push image to ECR
```shell
docker tag codiumai/pr-agent:serverless <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless
docker push <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless
```
4. Create a lambda function that uses the uploaded image. Set the lambda timeout to be at least 3m.
5. Configure the lambda function to have a Function URL.
6. Go back to steps 8-9 of [Method 5](#method-5-run-as-a-github-app) with the function url as your Webhook URL.
The Webhook URL would look like `https://<LAMBDA_FUNCTION_URL>/api/v1/github_webhooks`
83 changes: 46 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,93 +2,96 @@

<div align="center">

<img src="./pics/logo-dark.png#gh-dark-mode-only" width="250"/>
<img src="./pics/logo-light.png#gh-light-mode-only" width="250"/>

<img src="./pics/logo-dark.png#gh-dark-mode-only" width="330"/>
<img src="./pics/logo-light.png#gh-light-mode-only" width="330"/><br/>
Making pull requests less painful with an AI agent
</div>

[![GitHub license](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Codium-ai/pr-agent/blob/main/LICENSE)
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label&color=purple)](https://discord.com/channels/1057273017547378788/1126104260430528613)
<a href="https://github.com/Codium-ai/pr-agent/commits/main">
<img alt="GitHub" src="https://img.shields.io/github/last-commit/Codium-ai/pr-agent/main?style=for-the-badge" height="20">
</a>
</div>
<div style="text-align:left;">

CodiumAI `PR-Agent` is an open-source tool aiming to help developers review PRs faster and more efficiently. It automatically analyzes the PR and can provide several types of feedback:
CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull requests faster and more efficiently. It automatically analyzes the pull request and can provide several types of feedback:

**Auto-Description**: Automatically generating PR description - name, type, summary, and code walkthrough.
**Auto-Description**: Automatically generating PR description - title, type, summary, code walkthrough and PR labels.
\
**PR Review**: Feedback about the PR main theme, type, relevant tests, security issues, focused PR, and various suggestions for the PR content.
**PR Review**: Adjustable feedback about the PR main theme, type, relevant tests, security issues, focus, score, and various suggestions for the PR content.
\
**Question Answering**: Answering free-text questions about the PR.
\
**Code Suggestion**: Committable code suggestions for improving the PR.

<h3>Example results:</h2>
</div>
<h4>Describe:</h4>
<h4>/describe:</h4>
<div align="center">
<p float="center">
<img src="https://www.codium.ai/images/describe-2.gif" width="800">
</p>
</div>
<h4>/review:</h4>
<div align="center">
<p float="center">
<img src="https://codium.ai/images/describe.gif" width="800">
<img src="https://www.codium.ai/images/review-2.gif" width="800">
</p>
</div>
<h4>Review:</h4>
<h4>/reflect_and_review:</h4>
<div align="center">
<p float="center">
<img src="https://codium.ai/images/review.gif" width="800">
<img src="https://www.codium.ai/images/reflect_and_review.gif" width="800">
</p>
</div>
<h4>Ask:</h4>
<h4>/ask:</h4>
<div align="center">
<p float="center">
<img src="https://codium.ai/images/ask.gif" width="800">
<img src="https://www.codium.ai/images/ask-2.gif" width="800">
</p>
</div>
<h4>Improve:</h4>
<h4>/improve:</h4>
<div align="center">
<p float="center">
<img src="https://codium.ai/images/improve.gif" width="800">
<img src="https://www.codium.ai/images/improve-2.gif" width="800">
</p>
</div>
<div align="left">

- [Live demo](#live-demo)

- [Overview](#overview)
- [Quickstart](#quickstart)
- [Try it now](#try-it-now)
- [Installation](#installation)
- [Usage and tools](#usage-and-tools)
- [Configuration](./CONFIGURATION.md)
- [How it works](#how-it-works)
- [Roadmap](#roadmap)
- [Similar projects](#similar-projects)
</div>

## Live demo

Experience GPT-4 powered PR review on your public GitHub repository with our hosted PR-Agent. To try it, just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command.

![Review generation process](https://codium.ai/images/demo.gif)

To set up your own PR-Agent, see the [Quickstart](#Quickstart) section

---
## Overview
`PR-Agent` offers extensive pull request functionalities across various git providers:
| | | GitHub | Gitlab | Bitbucket |
|-------|---------------------------------------------|:------:|:------:|:---------:|
| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | |
| | Ask | :white_check_mark: | :white_check_mark: | |
| | Auto-Description | :white_check_mark: | | |
| | Auto-Description | :white_check_mark: | :white_check_mark: | |
| | Improve Code | :white_check_mark: | :white_check_mark: | |
| | Reflect and Review | :white_check_mark: | | |
| | | | | |
| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | Tagging bot | :white_check_mark: | :white_check_mark: | |
| | Tagging bot | :white_check_mark: | | |
| | Actions | :white_check_mark: | | |
| | | | | |
| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | Adaptive and token-aware<br />file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| | Incremental PR Review | :white_check_mark: | | |

Examples for invoking the different tools via the [CLI](#quickstart):
Examples for invoking the different tools via the CLI:
- **Review**: python cli.py --pr-url=<pr_url> review
- **Describe**: python cli.py --pr-url=<pr_url> describe
- **Improve**: python cli.py --pr-url=<pr_url> improve
Expand All @@ -99,18 +102,24 @@ Examples for invoking the different tools via the [CLI](#quickstart):

In the [configuration](./CONFIGURATION.md) file you can select your git provider (GitHub, Gitlab, Bitbucket), and further configure the different tools.

## Quickstart
## Try it now

Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command.

![Review generation process](https://www.codium.ai/images/demo-2.gif)

To set up your own PR-Agent, see the [Installation](#installation) section

---

## Installation

To get started with PR-Agent quickly, you first need to acquire two tokens:

1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4.
2. A GitHub personal access token (classic) with the repo scope.

There are several ways to use PR-Agent. Let's start with the simplest one:


## Install
Here are several ways to install and run PR-Agent:
There are several ways to use PR-Agent:

- [Method 1: Use Docker image (no installation required)](INSTALL.md#method-1-use-docker-image-no-installation-required)
- [Method 2: Run as a GitHub Action](INSTALL.md#method-2-run-as-a-github-action)
Expand All @@ -128,19 +137,19 @@ Here are several ways to install and run PR-Agent:
- The "PR Q&A" tool answers free-text questions about the PR.
- The "PR Description" tool automatically sets the PR Title and body.
- The "PR Code Suggestion" tool provide inline code suggestions for the PR that can be applied and committed.
- The "PR Reflect and Review" tool first dialog with the user and asks him to reflect on the PR, and then provides a review.
- The "PR Reflect and Review" tool initiates a dialog with the user, asks them to reflect on the PR, and then provides a more focused review.

## How it works

![PR-Agent Tools](https://codium.ai/images/pr_agent_overview.png)
![PR-Agent Tools](https://www.codium.ai/wp-content/uploads/2023/07/codiumai-diagram-v4.jpg)

Check out the [PR Compression strategy](./PR_COMPRESSION.md) page for more details on how we convert a code diff to a manageable LLM prompt

## Roadmap

- [ ] Support open-source models, as a replacement for openai models. (Note - a minimal requirement for each open-source model is to have 8k+ context, and good support for generating json as an output)
- [ ] Support open-source models, as a replacement for OpenAI models. (Note - a minimal requirement for each open-source model is to have 8k+ context, and good support for generating JSON as an output)
- [x] Support other Git providers, such as Gitlab and Bitbucket.
- [ ] Develop additional logics for handling large PRs, and compressing git patches
- [ ] Develop additional logic for handling large PRs, and compressing git patches
- [ ] Add additional context to the prompt. For example, repo (or relevant files) summarization, with tools such a [ctags](https://github.com/universal-ctags/ctags)
- [ ] Adding more tools. Possible directions:
- [x] PR description
Expand Down
5 changes: 4 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 'PR Agent'
name: 'Codium PR Agent'
description: 'Summarize, review and suggest improvements for pull requests'
branding:
icon: 'award'
color: 'green'
runs:
using: 'docker'
image: 'Dockerfile.github_action_dockerhub'
12 changes: 12 additions & 0 deletions docker/Dockerfile.lambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM public.ecr.aws/lambda/python:3.10

RUN yum update -y && \
yum install -y gcc python3-devel && \
yum clean all

ADD requirements.txt .
RUN pip install -r requirements.txt && rm requirements.txt
RUN pip install mangum==16.0.0
COPY pr_agent/ ${LAMBDA_TASK_ROOT}/pr_agent/

CMD ["pr_agent.servers.serverless.serverless"]
Binary file modified pics/logo-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pics/logo-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 9 additions & 12 deletions pr_agent/agent/pr_agent.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
import re

from pr_agent.config_loader import settings
from pr_agent.tools.pr_code_suggestions import PRCodeSuggestions
from pr_agent.tools.pr_description import PRDescription
from pr_agent.tools.pr_information_from_user import PRInformationFromUser
from pr_agent.tools.pr_questions import PRQuestions
from pr_agent.tools.pr_reviewer import PRReviewer
from pr_agent.config_loader import settings


class PRAgent:
def __init__(self):
pass

async def handle_request(self, pr_url, request) -> bool:
if any(cmd in request for cmd in ["/answer"]):
action, *args = request.strip().split()
if any(cmd == action for cmd in ["/answer"]):
await PRReviewer(pr_url, is_answer=True).review()
elif any(cmd in request for cmd in ["/review", "/review_pr", "/reflect_and_review"]):
elif any(cmd == action for cmd in ["/review", "/review_pr", "/reflect_and_review"]):
if settings.pr_reviewer.ask_and_reflect or "/reflect_and_review" in request:
await PRInformationFromUser(pr_url).generate_questions()
else:
await PRReviewer(pr_url).review()
elif any(cmd in request for cmd in ["/describe", "/describe_pr"]):
await PRReviewer(pr_url, args=args).review()
elif any(cmd == action for cmd in ["/describe", "/describe_pr"]):
await PRDescription(pr_url).describe()
elif any(cmd in request for cmd in ["/improve", "/improve_code"]):
elif any(cmd == action for cmd in ["/improve", "/improve_code"]):
await PRCodeSuggestions(pr_url).suggest()
elif any(cmd in request for cmd in ["/ask", "/ask_question"]):
pattern = r'(/ask|/ask_question)\s*(.*)'
matches = re.findall(pattern, request, re.IGNORECASE)
if matches:
question = matches[0][1]
await PRQuestions(pr_url, question).answer()
elif any(cmd == action for cmd in ["/ask", "/ask_question"]):
await PRQuestions(pr_url, args).answer()
else:
return False

Expand Down
Loading