From fa889fbb064d2f36e0bc2fdcae79a4718a3558af Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 12:00:24 +0900 Subject: [PATCH 01/59] docs: add pull request event types --- docs/docs/installation/github.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index b405b020..f19590f1 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -7,6 +7,7 @@ You can use our pre-built Github Action Docker image to run PR-Agent as a Github ```yaml on: pull_request: + types: [opened,reopened,ready_for_review,review_requested] issue_comment: jobs: pr_agent_job: @@ -28,6 +29,7 @@ jobs: ```yaml on: pull_request: + types: [opened,reopened,ready_for_review,review_requested] issue_comment: jobs: From 493f73f1ce5e0625026cd0ebbcb0bac098990b62 Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 12:03:27 +0900 Subject: [PATCH 02/59] chore: add logging the reason not execute --- pr_agent/servers/github_action_runner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index d4278156..5382d051 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -101,6 +101,8 @@ async def run_action(): await PRReviewer(pr_url).run() if auto_improve is None or is_true(auto_improve): await PRCodeSuggestions(pr_url).run() + else: + get_logger().info(f"Skipping action: {action}") # Handle issue comment event elif GITHUB_EVENT_NAME == "issue_comment" or GITHUB_EVENT_NAME == "pull_request_review_comment": From 020a29ebb8c3794b0768ef3ab13ce19b69fd00ef Mon Sep 17 00:00:00 2001 From: idubnori Date: Wed, 27 Mar 2024 20:53:46 +0900 Subject: [PATCH 03/59] docs: optimize condition of github actions --- docs/docs/installation/github.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index f19590f1..edaaf24f 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -7,10 +7,11 @@ You can use our pre-built Github Action Docker image to run PR-Agent as a Github ```yaml on: pull_request: - types: [opened,reopened,ready_for_review,review_requested] + types: [opened, reopened, ready_for_review] issue_comment: jobs: pr_agent_job: + if: ${{ github.event.sender.type != 'Bot' }} runs-on: ubuntu-latest permissions: issues: write @@ -29,11 +30,12 @@ jobs: ```yaml on: pull_request: - types: [opened,reopened,ready_for_review,review_requested] + types: [opened, reopened, ready_for_review] issue_comment: jobs: pr_agent_job: + if: ${{ github.event.sender.type != 'Bot' }} runs-on: ubuntu-latest permissions: issues: write From 79bdb9a69f3dd732142053fea6065d3504a8848f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 27 Mar 2024 19:56:27 +0200 Subject: [PATCH 04/59] bugfix: validate output publishing with progress condition in pr_code_suggestions --- pr_agent/tools/pr_code_suggestions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index aa119f2a..926edf00 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -76,7 +76,7 @@ class PRCodeSuggestions: relevant_configs = {'pr_code_suggestions': dict(get_settings().pr_code_suggestions), 'config': dict(get_settings().config)} get_logger().debug("Relevant configs", artifacts=relevant_configs) - if get_settings().config.publish_output: + if get_settings().config.publish_output and get_settings().config.publish_output_progress: if self.git_provider.is_supported("gfm_markdown"): self.progress_response = self.git_provider.publish_comment(self.progress) else: From aae6869964000578ccecc5e4ee9ee5919f06b7c8 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 28 Mar 2024 09:37:29 +0200 Subject: [PATCH 05/59] docs: Update PR-Agent usage guide --- docs/docs/installation/github.md | 24 ++++--------------- .../docs/usage-guide/automations_and_usage.md | 13 +++++----- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/docs/docs/installation/github.md b/docs/docs/installation/github.md index 2e5a2824..4f7be99a 100644 --- a/docs/docs/installation/github.md +++ b/docs/docs/installation/github.md @@ -26,29 +26,14 @@ jobs: OPENAI_KEY: ${{ secrets.OPENAI_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -** if you want to pin your action to a specific release (v0.7 for example) for stability reasons, use: +** if you want to pin your action to a specific release (v2.0 for example) for stability reasons, use: ```yaml -on: - pull_request: - types: [opened, reopened, ready_for_review] - issue_comment: - -jobs: - pr_agent_job: - if: ${{ github.event.sender.type != 'Bot' }} - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - contents: write - name: Run pr agent on every pull request, respond to user comments +... steps: - name: PR Agent action step id: pragent - uses: Codium-ai/pr-agent@v0.7 - env: - OPENAI_KEY: ${{ secrets.OPENAI_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: Codium-ai/pr-agent@v2.0 +... ``` 2) Add the following secret to your repository under `Settings > Secrets and variables > Actions > New repository secret > Add secret`: @@ -70,6 +55,7 @@ When you open your next PR, you should see a comment from `github-actions` bot w PR_REVIEWER.REQUIRE_TESTS_REVIEW: "false" # Disable tests review PR_CODE_SUGGESTIONS.NUM_CODE_SUGGESTIONS: 6 # Increase number of code suggestions ``` +See detailed usage instructions in the [USAGE GUIDE](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-action) --- diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index d20516fd..f718e9bd 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -59,7 +59,7 @@ The configuration parameter `pr_commands` defines the list of tools that will be [github_app] pr_commands = [ "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true --pr_description.final_update_message=false", - "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", + "/review --pr_reviewer.num_code_suggestions=0", "/improve", ] ``` @@ -99,13 +99,13 @@ The configuration parameter `push_commands` defines the list of tools that will handle_push_trigger = true push_commands = [ "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", - "/review --pr_reviewer.num_code_suggestions=0", + "/review --pr_reviewer.num_code_suggestions=0 --pr_reviewer.final_update_message=false", ] ``` This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and `review` tools, with the specified parameters. ## GitHub Action -`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`. +`GitHub Action` is a different way to trigger PR-Agent tools, and uses a different configuration mechanism than `GitHub App`.
You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file. Specifically, start by setting the following environment variables: ```yaml @@ -119,13 +119,14 @@ Specifically, start by setting the following environment variables: `github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened. If not set, the default configuration is for all three tools to run automatically when a new PR is opened. -Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage. +Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/#global-configuration-file) in the root of your repo -For example, you can set an environment variable: `pr_description.add_original_user_description=false`, or add a `.pr_agent.toml` file with the following content: +For example, you can set an environment variable: `pr_description.publish_labels=false`, or add a `.pr_agent.toml` file with the following content: ``` [pr_description] -add_original_user_description = false +publish_labels = false ``` +to prevent PR-Agent from publishing labels when running the `describe` tool. ## GitLab Webhook After setting up a GitLab webhook, to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: From 7e84acc63cd1d382212b1ab9d45c36ce9e3f46ec Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 29 Mar 2024 13:34:23 +0300 Subject: [PATCH 06/59] docs: Refine project description and reorganize documentation links in README --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0f107870..0d75489c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@
-Making pull requests less painful with an AI agent +CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedbacks and suggestions [![GitHub license](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/Codium-ai/pr-agent/blob/main/LICENSE) @@ -21,6 +21,14 @@ Making pull requests less painful with an AI agent +### [Documentation](https://pr-agent-docs.codium.ai/) +- See the [Installation Guide](https://pr-agent-docs.codium.ai/installation/) for instructions on installing PR-Agent on different platforms. + +- See the [Usage Guide](https://pr-agent-docs.codium.ai/usage-guide/) for instructions on running PR-Agent tools via different interfaces, such as CLI, PR Comments, or by automatically triggering them when a new PR is opened. + +- See the [Tools Guide](https://pr-agent-docs.codium.ai/tools/) for a detailed description of the different tools, and the available configurations for each tool. + + ## Table of Contents - [News and Updates](#news-and-updates) - [Overview](#overview) @@ -63,14 +71,6 @@ If set to true, the tool will add a section that checks if the PR contains sever ## Overview
-CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedbacks and suggestions - -- See the [Installation Guide](https://pr-agent-docs.codium.ai/installation/) for instructions on installing and running the tool on different git platforms. - -- See the [Usage Guide](https://pr-agent-docs.codium.ai/usage-guide/) for instructions on running the PR-Agent commands via different interfaces, including _CLI_, _online usage_, or by _automatically triggering_ them when a new PR is opened. - -- See the [Tools Guide](https://pr-agent-docs.codium.ai/tools/) for a detailed description of the different tools. - Supported commands per platform: | | | GitHub | Gitlab | Bitbucket | Azure DevOps | From c3b3651769c8b42abf82dacf69cca9c988473c28 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 11:43:00 +0300 Subject: [PATCH 07/59] refine help --- pr_agent/tools/pr_help_message.py | 47 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/pr_agent/tools/pr_help_message.py b/pr_agent/tools/pr_help_message.py index f7a5ff13..df2698cf 100644 --- a/pr_agent/tools/pr_help_message.py +++ b/pr_agent/tools/pr_help_message.py @@ -27,12 +27,13 @@ class PRHelpMessage: tool_names.append(f"[DESCRIBE]({base_path}/describe/)") tool_names.append(f"[REVIEW]({base_path}/review/)") tool_names.append(f"[IMPROVE]({base_path}/improve/)") - tool_names.append(f"[ANALYZE]({base_path}/analyze/) 💎") tool_names.append(f"[UPDATE CHANGELOG]({base_path}/update_changelog/)") - tool_names.append(f"[ADD DOCUMENTATION]({base_path}/documentation/) 💎") - tool_names.append(f"[ASK]({base_path}/ask/)") - tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/custom_labels/)") + tool_names.append(f"[ADD DOCS]({base_path}/documentation/) 💎") tool_names.append(f"[TEST]({base_path}/test/) 💎") + tool_names.append(f"[IMPROVE COMPONENT]({base_path}/improve_component/) 💎") + tool_names.append(f"[ANALYZE]({base_path}/analyze/) 💎") + tool_names.append(f"[ASK]({base_path}/ask/)") + tool_names.append(f"[GENERATE CUSTOM LABELS]({base_path}/custom_labels/) 💎") tool_names.append(f"[CI FEEDBACK]({base_path}/ci_feedback/) 💎") tool_names.append(f"[CUSTOM SUGGESTIONS]({base_path}/custom_suggestions/) 💎") tool_names.append(f"[SIMILAR ISSUE]({base_path}/similar_issues/)") @@ -40,27 +41,29 @@ class PRHelpMessage: descriptions = [] descriptions.append("Generates PR description - title, type, summary, code walkthrough and labels") descriptions.append("Adjustable feedback about the PR, possible issues, security concerns, review effort and more") - descriptions.append("Code suggestions for improving the PR.") - descriptions.append("Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component.") - descriptions.append("Automatically updates the changelog.") - descriptions.append("Generates documentation to methods/functions/classes that changed in the PR.") - descriptions.append("Answering free-text questions about the PR.") + descriptions.append("Code suggestions for improving the PR") + descriptions.append("Automatically updates the changelog") + descriptions.append("Generates documentation to methods/functions/classes that changed in the PR") + descriptions.append("Generates unit tests for a specific component, based on the PR code change") + descriptions.append("Code suggestions for a specific component that changed in the PR") + descriptions.append("Identifies code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component") + descriptions.append("Answering free-text questions about the PR") descriptions.append("Generates custom labels for the PR, based on specific guidelines defined by the user") - descriptions.append("Generates unit tests for a specific component, based on the PR code change.") - descriptions.append("Generates feedback and analysis for a failed CI job.") - descriptions.append("Generates custom suggestions for improving the PR code, based on specific guidelines defined by the user.") - descriptions.append("Automatically retrieves and presents similar issues.") + descriptions.append("Generates feedback and analysis for a failed CI job") + descriptions.append("Generates custom suggestions for improving the PR code, based only on specific guidelines defined by the user") + descriptions.append("Automatically retrieves and presents similar issues") commands =[] commands.append("`/describe`") commands.append("`/review`") commands.append("`/improve`") - commands.append("`/analyze`") commands.append("`/update_changelog`") commands.append("`/add_docs`") + commands.append("`/test`") + commands.append("`/improve_component`") + commands.append("`/analyze`") commands.append("`/ask`") commands.append("`/generate_labels`") - commands.append("`/test`") commands.append("`/checks`") commands.append("`/custom_suggestions`") commands.append("`/similar_issue`") @@ -69,9 +72,13 @@ class PRHelpMessage: checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") - checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append(" - [ ] Run ") + checkbox_list.append("[*]") + checkbox_list.append("[*]") checkbox_list.append("[*]") checkbox_list.append("[*]") checkbox_list.append("[*]") @@ -80,16 +87,16 @@ class PRHelpMessage: checkbox_list.append("[*]") if isinstance(self.git_provider, GithubProvider): - pr_comment += f"" + pr_comment += f"
ToolDescriptionInvoke Interactively :gem:
" for i in range(len(tool_names)): - pr_comment += f"\n\n\n" + pr_comment += f"\n\n\n" pr_comment += "
ToolDescriptionTrigger Interactively :gem:
\n\n{tool_names[i]}{descriptions[i]}\n\n{checkbox_list[i]}\n
\n\n{tool_names[i]}{descriptions[i]}\n\n{checkbox_list[i]}\n
\n\n" pr_comment += f"""\n\n(1) Note that each tool be [triggered automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools-for-pr-actions) when a new PR is opened, or called manually by [commenting on a PR](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#online-usage).""" pr_comment += f"""\n\n(2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the `/ask` tool, you need to comment on a PR: `/ask ""`. See the relevant documentation for each tool for more details.""" else: - pr_comment += f"" + pr_comment += f"
ToolCommandDescription
" for i in range(len(tool_names)): - pr_comment += f"\n" + pr_comment += f"\n" pr_comment += "
ToolCommandDescription
\n\n{tool_names[i]}{commands[i]}{descriptions[i]}
\n\n{tool_names[i]}{commands[i]}{descriptions[i]}
\n\n" pr_comment += f"""\n\nNote that each tool be [invoked automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/) when a new PR is opened, or called manually by [commenting on a PR](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#online-usage).""" if get_settings().config.publish_output: From 8bda365636576c518e2e13f2f2107d483c8c5a62 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 12:13:25 +0300 Subject: [PATCH 08/59] docs: Add "Improve Component" tool documentation and update related guides --- docs/docs/tools/improve_component.md | 24 +++++++++++++++++++++++ docs/docs/tools/index.md | 29 ++++++++++++++-------------- docs/docs/tools/test.md | 2 +- docs/mkdocs.yml | 1 + pr_agent/settings/configuration.toml | 5 +++++ 5 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 docs/docs/tools/improve_component.md diff --git a/docs/docs/tools/improve_component.md b/docs/docs/tools/improve_component.md new file mode 100644 index 00000000..d7e0e787 --- /dev/null +++ b/docs/docs/tools/improve_component.md @@ -0,0 +1,24 @@ +## Overview +The `improve_component` tool generates code suggestions for a specific code component that changed in the PR. +it can be invoked manually by commenting on any PR: +``` +/improve_component component_name +``` + +To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. + + +Example result: + +![improve_component1](https://codium.ai/images/pr_agent/improve_component1.png){width=768} + +![improve_component2](https://codium.ai/images/pr_agent/improve_component2.png){width=768} + +**Notes** +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. + +## Configuration options +- `num_code_suggestions`: number of code suggestions to provide. Default is 4 +- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on ...". +- `file`: in case there are several components with the same name, you can specify the relevant file. +- `class_name`: in case there are several methods with the same name in the same file, you can specify the relevant class name. \ No newline at end of file diff --git a/docs/docs/tools/index.md b/docs/docs/tools/index.md index bcd9ed9d..b77097b3 100644 --- a/docs/docs/tools/index.md +++ b/docs/docs/tools/index.md @@ -2,19 +2,20 @@ Here is a list of PR-Agent tools, each with a dedicated page that explains how to use it: -| Tool | Description | -|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| -| **[PR Description (`/describe`](./describe.md))** | Automatically generating PR description - title, type, summary, code walkthrough and labels | -| **[PR Review (`/review`](./review.md))** | Adjustable feedback about the PR, possible issues, security concerns, review effort and more | -| **[Code Suggestions (`/improve`](./improve.md))** | Code suggestions for improving the PR | -| **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines | -| **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes | -| **[Find Similar Issue (`/similar_issue`](./similar_issues.md))** | Automatically retrieves and presents similar issues | -| **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR | -| **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user | -| **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component | -| **💎 [Custom Suggestions (`/custom_suggestions`](./custom_suggestions.md))** | Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user | -| **💎 [Generate Tests (`/test component_name`](./test.md))** | Automatically generates unit tests for a selected component, based on the PR code changes | -| **💎 [CI Feedback (`/checks ci_job`](./ci_feedback.md))** | Automatically generates feedback and analysis for a failed CI job | +| Tool | Description | +|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| **[PR Description (`/describe`](./describe.md))** | Automatically generating PR description - title, type, summary, code walkthrough and labels | +| **[PR Review (`/review`](./review.md))** | Adjustable feedback about the PR, possible issues, security concerns, review effort and more | +| **[Code Suggestions (`/improve`](./improve.md))** | Code suggestions for improving the PR | +| **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines | +| **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes | +| **[Find Similar Issue (`/similar_issue`](./similar_issues.md))** | Automatically retrieves and presents similar issues | +| **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR | +| **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user | +| **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component | +| **💎 [Custom Suggestions (`/custom_suggestions`](./custom_suggestions.md))** | Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user | +| **💎 [Generate Tests (`/test component_name`](./test.md))** | Automatically generates unit tests for a selected component, based on the PR code changes | +| **💎 [Improve Component (`/improve_component component_name`](./improve_component.md))** | Generates code suggestions for a specific code component that changed in the PR | +| **💎 [CI Feedback (`/checks ci_job`](./ci_feedback.md))** | Automatically generates feedback and analysis for a failed CI job | Note that the tools marked with 💎 are available only for PR-Agent Pro users. \ No newline at end of file diff --git a/docs/docs/tools/test.md b/docs/docs/tools/test.md index 6c1901b1..4cb46bac 100644 --- a/docs/docs/tools/test.md +++ b/docs/docs/tools/test.md @@ -5,7 +5,7 @@ It can be invoked manually by commenting on any PR: /test component_name ``` where 'component_name' is the name of a specific component in the PR. -To get a list of the components that changed in the PR, use the [`analyze`](./analyze.md) tool. +To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429): diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index b7e6864d..e67712e1 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -27,6 +27,7 @@ nav: - Similar Issues: 'tools/similar_issues.md' - 💎 Analyze: 'tools/analyze.md' - 💎 Test: 'tools/test.md' + - 💎 Improve Component: 'tools/improve_component.md' - 💎 Documentation: 'tools/documentation.md' - 💎 Custom Labels: 'tools/custom_labels.md' - 💎 Custom Suggestions: 'tools/custom_suggestions.md' diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 837c71d3..765c8342 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -110,6 +110,11 @@ file = "" # in case there are several components with the same name class_name = "" # in case there are several methods with the same name in the same file, you can specify the relevant class name enable_help_text=true +[pr_improve_component] # /improve_component # +num_code_suggestions=4 +extra_instructions = "" +file = "" # in case there are several components with the same name, you can specify the relevant file +class_name = "" [checks] # /checks (pro feature) # enable_auto_checks_feedback=true From ce47adf986593bff404ae06b613c5909fadab72f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 31 Mar 2024 12:15:29 +0300 Subject: [PATCH 09/59] C# --- docs/docs/tools/analyze.md | 2 +- docs/docs/tools/documentation.md | 2 +- docs/docs/tools/improve_component.md | 2 +- docs/docs/tools/test.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/tools/analyze.md b/docs/docs/tools/analyze.md index 3b7c6d58..0255e759 100644 --- a/docs/docs/tools/analyze.md +++ b/docs/docs/tools/analyze.md @@ -19,4 +19,4 @@ An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment- **Notes** -- Language that are currently supported: Python, Java, C++, JavaScript, TypeScript. \ No newline at end of file +- Language that are currently supported: Python, Java, C++, JavaScript, TypeScript, C#. \ No newline at end of file diff --git a/docs/docs/tools/documentation.md b/docs/docs/tools/documentation.md index 4318ee45..9c56386f 100644 --- a/docs/docs/tools/documentation.md +++ b/docs/docs/tools/documentation.md @@ -19,6 +19,6 @@ For example: **Notes** -- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently fully supported: Python, Java, C++, JavaScript, TypeScript, C#. - For languages that are not fully supported, the tool will suggest documentation only for new components in the PR. - A previous version of the tool, that offered support only for new components, was deprecated. \ No newline at end of file diff --git a/docs/docs/tools/improve_component.md b/docs/docs/tools/improve_component.md index d7e0e787..321114b4 100644 --- a/docs/docs/tools/improve_component.md +++ b/docs/docs/tools/improve_component.md @@ -15,7 +15,7 @@ Example result: ![improve_component2](https://codium.ai/images/pr_agent/improve_component2.png){width=768} **Notes** -- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#. ## Configuration options - `num_code_suggestions`: number of code suggestions to provide. Default is 4 diff --git a/docs/docs/tools/test.md b/docs/docs/tools/test.md index 4cb46bac..52e447ce 100644 --- a/docs/docs/tools/test.md +++ b/docs/docs/tools/test.md @@ -17,7 +17,7 @@ An example [result](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment- ![test3](https://codium.ai/images/pr_agent/test3.png){width=768} **Notes** -- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript. +- Language that are currently supported by the tool: Python, Java, C++, JavaScript, TypeScript, C#. ## Configuration options From b86b37e6a2bfd8104c786420e9239568f765190a Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:54:59 +0300 Subject: [PATCH 10/59] analytics --- docs/overrides/main.html | 10 ++++++++++ .../partials/integrations/analytics/custom.html | 7 +++++++ 2 files changed, 17 insertions(+) create mode 100644 docs/overrides/main.html create mode 100644 docs/overrides/partials/integrations/analytics/custom.html diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 00000000..93a67950 --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block scripts %} + {{ super() }} + + + + +{% endblock %} \ No newline at end of file diff --git a/docs/overrides/partials/integrations/analytics/custom.html b/docs/overrides/partials/integrations/analytics/custom.html new file mode 100644 index 00000000..9a0785d2 --- /dev/null +++ b/docs/overrides/partials/integrations/analytics/custom.html @@ -0,0 +1,7 @@ + + + \ No newline at end of file From a53ba4596efffa7beb2cb3776ce81ac29b77aed5 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:03:36 +0300 Subject: [PATCH 11/59] fix custom analytics --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index e67712e1..c045d8e4 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -96,7 +96,7 @@ extra: - icon: fontawesome/brands/instagram link: https://www.instagram.com/codiumai/ analytics: - provider: google + provider: custom property: ${{ secrets.GOOGLE_ANALYTICS_ID }} extra_css: From 3d86430f18f8d769db66413be3b7ce6c28bb960e Mon Sep 17 00:00:00 2001 From: Tal Date: Mon, 1 Apr 2024 18:46:08 +0300 Subject: [PATCH 12/59] Update automations_and_usage.md --- docs/docs/usage-guide/automations_and_usage.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index f718e9bd..f32863eb 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -154,11 +154,11 @@ Each time you invoke a `/review` tool, it will use inline code comments. ### BitBucket Self-Hosted App automatic tools -to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: +To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: Specifically, set the following values: -[bitbucket_app] ``` +[bitbucket_app] pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", "/improve --pr_code_suggestions.summarize=false", @@ -197,4 +197,4 @@ pr_commands = [ "/review --pr_reviewer.num_code_suggestions=0", "/improve", ] -``` \ No newline at end of file +``` From 27cdd419e57b78c37508dcbf3fdee1b9a0bae78f Mon Sep 17 00:00:00 2001 From: Tal Date: Mon, 1 Apr 2024 18:56:36 +0300 Subject: [PATCH 13/59] Update index.md --- docs/docs/index.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/docs/index.md b/docs/docs/index.md index 246680df..3919feae 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -19,20 +19,19 @@ PR-Agent offers extensive pull request functionalities across various git provid | | ⮑ [SOC2 Compliance](https://pr-agent-docs.codium.ai/tools/review/#soc2-ticket-compliance){:target="_blank"} 💎 | ✅ | ✅ | ✅ | ✅ | | | Ask | ✅ | ✅ | ✅ | ✅ | | | Describe | ✅ | ✅ | ✅ | ✅ | -| | ⮑ [Inline file summary](https://pr-agent-docs.codium.ai/tools/describe/#inline-file-summary){:target="_blank"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | ⮑ [Inline file summary](https://pr-agent-docs.codium.ai/tools/describe/#inline-file-summary){:target="_blank"} 💎 | ✅ | ✅ | | ✅ | | | Improve | ✅ | ✅ | ✅ | ✅ | | | ⮑ Extended | ✅ | ✅ | ✅ | ✅ | | | [Custom Suggestions](./tools/custom_suggestions.md){:target="_blank"} 💎 | ✅ | ✅ | ✅ | ✅ | | | Reflect and Review | ✅ | ✅ | ✅ | ✅ | | | Update CHANGELOG.md | ✅ | ✅ | ✅ | ️ | | | Find Similar Issue | ✅ | | | ️ | -| | [Add PR Documentation](./tools/documentation.md){:target="_blank"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | [Add PR Documentation](./tools/documentation.md){:target="_blank"} 💎 | ✅ | ✅ | | ✅ | | | [Generate Custom Labels](./tools/describe.md#handle-custom-labels-from-the-repos-labels-page-💎){:target="_blank"} 💎 | ✅ | ✅ | | ✅ | -| | [Analyze PR Components](./tools/analyze.md){:target="_blank"} 💎 | ✅ | ✅ | ✅ | ✅ | +| | [Analyze PR Components](./tools/analyze.md){:target="_blank"} 💎 | ✅ | ✅ | | ✅ | | | | | | | ️ | | USAGE | CLI | ✅ | ✅ | ✅ | ✅ | -| | App / webhook | ✅ | ✅ | | ✅ | -| | Tagging bot | ✅ | | | ✅ | +| | App / webhook | ✅ | ✅ | ✅ | ✅ | | | Actions | ✅ | | | ️ | | | | | | | | CORE | PR compression | ✅ | ✅ | ✅ | ✅ | From 501b0595759c47549ae3fc155ad79b5a29bf4835 Mon Sep 17 00:00:00 2001 From: gregoryboue Date: Tue, 2 Apr 2024 11:01:45 +0200 Subject: [PATCH 14/59] feat: allows ollama usage Fix https://github.com/Codium-ai/pr-agent/issues/657 --- pr_agent/algo/ai_handlers/litellm_ai_handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index ce4d1db0..d07542f6 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -61,6 +61,9 @@ class LiteLLMAIHandler(BaseAiHandler): if get_settings().get("HUGGINGFACE.API_BASE", None) and 'huggingface' in get_settings().config.model: litellm.api_base = get_settings().huggingface.api_base self.api_base = get_settings().huggingface.api_base + if get_settings().get("OLLAMA.API_BASE", None) : + litellm.api_base = get_settings().ollama.api_base + self.api_base = get_settings().ollama.api_base if get_settings().get("HUGGINGFACE.REPITITION_PENALTY", None): self.repetition_penalty = float(get_settings().huggingface.repetition_penalty) if get_settings().get("VERTEXAI.VERTEX_PROJECT", None): @@ -150,4 +153,4 @@ class LiteLLMAIHandler(BaseAiHandler): if get_settings().config.verbosity_level >= 2: get_logger().info(f"\nAI response:\n{resp}") - return resp, finish_reason \ No newline at end of file + return resp, finish_reason From 3ebb72e3f12b3fb4404513f49ce1c908e4d1f652 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 2 Apr 2024 17:52:34 +0300 Subject: [PATCH 15/59] feat: add persistent comment option for PR descriptions --- pr_agent/settings/configuration.toml | 4 +++- pr_agent/tools/pr_description.py | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 765c8342..c5c4a440 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -52,7 +52,6 @@ maximal_review_effort=5 [pr_description] # /describe # publish_labels=true -publish_description_as_comment=false add_original_user_description=true keep_original_user_title=true use_bullet_points=true @@ -61,6 +60,9 @@ enable_pr_type=true final_update_message = true enable_help_text=false enable_help_comment=true +# describe as comment +publish_description_as_comment=false +publish_description_as_comment_persistent=true ## changes walkthrough section enable_semantic_files_types=true collapsible_file_list='adaptive' # true, false, 'adaptive' diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py index 7500efa7..8526642f 100644 --- a/pr_agent/tools/pr_description.py +++ b/pr_agent/tools/pr_description.py @@ -132,7 +132,14 @@ class PRDescription: # publish description if get_settings().pr_description.publish_description_as_comment: full_markdown_description = f"## Title\n\n{pr_title}\n\n___\n{pr_body}" - self.git_provider.publish_comment(full_markdown_description) + if get_settings().pr_description.publish_description_as_comment_persistent: + self.git_provider.publish_persistent_comment(full_markdown_description, + initial_header="## Title", + update_header=True, + name="describe", + final_update_message=False, ) + else: + self.git_provider.publish_comment(full_markdown_description) else: self.git_provider.publish_description(pr_title, pr_body) From 9614f619e83d20d9b86a18b95f5fbb634ac4a187 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 2 Apr 2024 17:54:37 +0300 Subject: [PATCH 16/59] feat: add persistent comment option for PR descriptions --- docs/docs/tools/describe.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index e0de5153..bbd03ab7 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -27,6 +27,8 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen - `publish_description_as_comment`: if set to true, the tool will publish the description as a comment to the PR. If false, it will overwrite the original description. Default is false. + - `publish_description_as_comment_persistent`: if set to true and `publish_description_as_comment` is true, the tool will publish the description as a persistent comment to the PR. Default is true. + - `add_original_user_description`: if set to true, the tool will add the original user description to the generated description. Default is true. - `keep_original_user_title`: if set to true, the tool will keep the original PR title, and won't change it. Default is true. From 9c3673209dd7dd80d652c04dcec6131bdb3d048a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 3 Apr 2024 08:42:50 +0300 Subject: [PATCH 17/59] TokenEncoder --- pr_agent/algo/token_handler.py | 23 ++++++++++++++++++----- pr_agent/algo/utils.py | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pr_agent/algo/token_handler.py b/pr_agent/algo/token_handler.py index d7eff9d7..9cc3b41f 100644 --- a/pr_agent/algo/token_handler.py +++ b/pr_agent/algo/token_handler.py @@ -1,12 +1,25 @@ from jinja2 import Environment, StrictUndefined from tiktoken import encoding_for_model, get_encoding - from pr_agent.config_loader import get_settings +from threading import Lock -def get_token_encoder(): - return encoding_for_model(get_settings().config.model) if "gpt" in get_settings().config.model else get_encoding( - "cl100k_base") +class TokenEncoder: + _encoder_instance = None + _model = None + _lock = Lock() # Create a lock object + + @classmethod + def get_token_encoder(cls): + model = get_settings().config.model + if cls._encoder_instance is None or model != cls._model: # Check without acquiring the lock for performance + with cls._lock: # Lock acquisition to ensure thread safety + if cls._encoder_instance is None or model != cls._model: + cls._model = model + cls._encoder_instance = encoding_for_model(cls._model) if "gpt" in cls._model else get_encoding( + "cl100k_base") + return cls._encoder_instance + class TokenHandler: """ @@ -31,7 +44,7 @@ class TokenHandler: - system: The system string. - user: The user string. """ - self.encoder = get_token_encoder() + self.encoder = TokenEncoder.get_token_encoder() if pr is not None: self.prompt_tokens = self._get_system_user_tokens(pr, self.encoder, vars, system, user) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index c2b6323c..b017f0aa 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -12,7 +12,7 @@ import yaml from starlette_context import context from pr_agent.algo import MAX_TOKENS -from pr_agent.algo.token_handler import get_token_encoder +from pr_agent.algo.token_handler import TokenEncoder from pr_agent.config_loader import get_settings, global_settings from pr_agent.algo.types import FilePatchInfo from pr_agent.log import get_logger @@ -566,7 +566,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: return text try: - encoder = get_token_encoder() + encoder = TokenEncoder.get_token_encoder() num_input_tokens = len(encoder.encode(text)) if num_input_tokens <= max_tokens: return text From d7b19af117dc71d60154682c1871f00e65ace2e4 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:53:56 +0300 Subject: [PATCH 18/59] Update README.md --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 68867ce4..a06f01af 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,3 +13,4 @@ The deployment is managed on the gh-pages branches. After each merge to main the deplloyment will be taken care of by GH action automatically and the new version will be available at: [Docs](https://codium-ai.github.io/docs/) Github action is located in `.github/workflows/ci.yml` file. + From 877aeffbb3cfaebe923a86c916f9f0b12c1d8156 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:59:53 +0300 Subject: [PATCH 19/59] Update describe.md --- docs/docs/tools/describe.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index bbd03ab7..1510b2e8 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -5,6 +5,7 @@ The tool can be triggered automatically every time a new PR is [opened](../usage ``` /describe ``` + For example: ![Describe comment](https://codium.ai/images/pr_agent/describe_comment.png){width=512} @@ -160,4 +161,4 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases. Note that Labels are not mutually exclusive, so you can add multiple label categories. -
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. \ No newline at end of file +
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. From bbd302360f475129e8b890ddc3d9bb553a77c56f Mon Sep 17 00:00:00 2001 From: Tal Date: Fri, 5 Apr 2024 17:22:54 +0300 Subject: [PATCH 20/59] Update additional_configurations.md --- .../usage-guide/additional_configurations.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/docs/usage-guide/additional_configurations.md b/docs/docs/usage-guide/additional_configurations.md index 1a756252..e1128817 100644 --- a/docs/docs/usage-guide/additional_configurations.md +++ b/docs/docs/usage-guide/additional_configurations.md @@ -7,10 +7,10 @@ To ignore files or directories, edit the **[ignore.toml](https://github.com/Codi - `IGNORE.GLOB` - `IGNORE.REGEX` -For example, to ignore python files in a PR with online usage, comment on a PR: +For example, to ignore Python files in a PR with online usage, comment on a PR: `/review --ignore.glob=['*.py']` -To ignore python files in all PRs, set in a configuration file: +To ignore Python files in all PRs, set in a configuration file: ``` [ignore] glob = ['*.py'] @@ -26,13 +26,13 @@ All PR-Agent tools have a parameter called `extra_instructions`, that enables to ## Working with large PRs The default mode of CodiumAI is to have a single call per tool, using GPT-4, which has a token limit of 8000 tokens. -This mode provide a very good speed-quality-cost tradeoff, and can handle most PRs successfully. +This mode provides a very good speed-quality-cost tradeoff, and can handle most PRs successfully. When the PR is above the token limit, it employs a [PR Compression strategy](../core-abilities/index.md). -However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are 2 possible solutions: +However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are two possible solutions: 1) [Use a model](https://codium-ai.github.io/Docs-PR-Agent/usage-guide/#changing-a-model) with larger context, like GPT-32K, or claude-100K. This solution will be applicable for all the tools. 2) For the `/improve` tool, there is an ['extended' mode](https://codium-ai.github.io/Docs-PR-Agent/tools/#improve) (`/improve --extended`), -which divides the PR to chunks, and process each chunk separately. With this mode, regardless of the model, no compression will be done (but for large PRs, multiple model calls may occur) +which divides the PR to chunks, and processes each chunk separately. With this mode, regardless of the model, no compression will be done (but for large PRs, multiple model calls may occur) ## Changing a model @@ -79,6 +79,7 @@ MAX_TOKENS={ [config] # in configuration.toml model = "ollama/llama2" +model_turbo = "ollama/llama2" [ollama] # in .secrets.toml api_base = ... # the base url for your huggingface inference endpoint @@ -101,6 +102,7 @@ MAX_TOKENS={ } [config] # in configuration.toml model = "huggingface/meta-llama/Llama-2-7b-chat-hf" +model_turbo = "huggingface/meta-llama/Llama-2-7b-chat-hf" [huggingface] # in .secrets.toml key = ... # your huggingface api key @@ -114,13 +116,14 @@ To use Llama2 model with Replicate, for example, set: ``` [config] # in configuration.toml model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" +model_turbo = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" [replicate] # in .secrets.toml key = ... ``` (you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api)) -Also review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. +Also, review the [AiHandler](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/ai_handler.py) file for instructions on how to set keys for other models. ### Vertex AI @@ -129,6 +132,7 @@ To use Google's Vertex AI platform and its associated models (chat-bison/codecha ``` [config] # in configuration.toml model = "vertex_ai/codechat-bison" +model_turbo = "vertex_ai/codechat-bison" fallback_models="vertex_ai/codechat-bison" [vertexai] # in .secrets.toml @@ -183,7 +187,7 @@ AWS session is automatically authenticated from your environment, but you can al ## Patch Extra Lines -By default, around any change in your PR, git patch provides 3 lines of context above and below the change. +By default, around any change in your PR, git patch provides three lines of context above and below the change. ``` @@ -12,5 +12,5 @@ def func1(): code line that already existed in the file... From 4dc160bc1684a6dbfb8df306113bb9b9fc10126a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:08:40 +0300 Subject: [PATCH 21/59] readme --- README.md | 50 ++++++++++++------- docs/docs/index.md | 10 ++-- docs/docs/installation/index.md | 2 +- .../docs/usage-guide/automations_and_usage.md | 4 ++ docs/mkdocs.yml | 2 +- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0d75489c..de3f51e5 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p - [Overview](#overview) - [Example results](#example-results) - [Try it now](#try-it-now) -- [Installation](#installation) - [PR-Agent Pro 💎](#pr-agent-pro-) - [How it works](#how-it-works) - [Why use PR-Agent?](#why-use-pr-agent) @@ -235,32 +234,47 @@ Note that when you set your own PR-Agent or use CodiumAI hosted PR-Agent, there --- -## Installation -To use your own version of PR-Agent, you first need to acquire two tokens: +[//]: # (## Installation) -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. +[//]: # (To use your own version of PR-Agent, you first need to acquire two tokens:) -There are several ways to use PR-Agent: +[//]: # () +[//]: # (1. An OpenAI key from [here](https://platform.openai.com/), with access to GPT-4.) -**Locally** -- [Using pip package](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package) -- [Using Docker image](https://pr-agent-docs.codium.ai/installation/locally/#using-docker-image) -- [Run from source](https://pr-agent-docs.codium.ai/installation/locally/#run-from-source) +[//]: # (2. A GitHub personal access token (classic) with the repo scope.) -**GitHub specific methods** -- [Run as a GitHub Action](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-action) -- [Run as a GitHub App](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-app) +[//]: # () +[//]: # (There are several ways to use PR-Agent:) -**GitLab specific methods** -- [Run a GitLab webhook server](https://pr-agent-docs.codium.ai/installation/gitlab/) +[//]: # () +[//]: # (**Locally**) -**BitBucket specific methods** -- [Run as a Bitbucket Pipeline](https://pr-agent-docs.codium.ai/installation/bitbucket/) +[//]: # (- [Using pip package](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package)) + +[//]: # (- [Using Docker image](https://pr-agent-docs.codium.ai/installation/locally/#using-docker-image)) + +[//]: # (- [Run from source](https://pr-agent-docs.codium.ai/installation/locally/#run-from-source)) + +[//]: # () +[//]: # (**GitHub specific methods**) + +[//]: # (- [Run as a GitHub Action](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-action)) + +[//]: # (- [Run as a GitHub App](https://pr-agent-docs.codium.ai/installation/github/#run-as-a-github-app)) + +[//]: # () +[//]: # (**GitLab specific methods**) + +[//]: # (- [Run a GitLab webhook server](https://pr-agent-docs.codium.ai/installation/gitlab/)) + +[//]: # () +[//]: # (**BitBucket specific methods**) + +[//]: # (- [Run as a Bitbucket Pipeline](https://pr-agent-docs.codium.ai/installation/bitbucket/)) ## PR-Agent Pro 💎 [PR-Agent Pro](https://www.codium.ai/pricing/) is a hosted version of PR-Agent, provided by CodiumAI. It is available for a monthly fee, and provides the following benefits: -1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\BitBucket repo. +1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\GitLab\BitBucket repo. 2. **Improved privacy** - No data will be stored or used to train models. PR-Agent Pro will employ zero data retention, and will use an OpenAI account with zero data retention. 3. **Improved support** - PR-Agent Pro users will receive priority support, and will be able to request new features and capabilities. 4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. diff --git a/docs/docs/index.md b/docs/docs/index.md index 3919feae..cec35b45 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -45,7 +45,7 @@ PR-Agent offers extensive pull request functionalities across various git provid 💎 marks a feature available only in [PR-Agent Pro](https://www.codium.ai/pricing/){:target="_blank"} -## Example results +## Example Results #### [/describe](https://github.com/Codium-ai/pr-agent/pull/530)
![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} @@ -66,7 +66,7 @@ PR-Agent offers extensive pull request functionalities across various git provid ![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300}
-## How it works +## How it Works The following diagram illustrates PR-Agent tools and their flow: @@ -80,7 +80,7 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d [PR-Agent Pro](https://www.codium.ai/pricing/) is a hosted version of PR-Agent, provided by CodiumAI. It is available for a monthly fee, and provides the following benefits: -1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\BitBucket repo. +1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the PR-Agent app to your GitHub\GitLab\BitBucket repo. 2. **Improved privacy** - No data will be stored or used to train models. PR-Agent Pro will employ zero data retention, and will use an OpenAI account with zero data retention. 3. **Improved support** - PR-Agent Pro users will receive priority support, and will be able to request new features and capabilities. 4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. It has the following additional tools and features: @@ -88,13 +88,15 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d - [**Custom Code Suggestions**](./tools/custom_suggestions.md/) - [**Tests**](./tools/test.md/) - [**PR documentation**](./tools/documentation.md/) + - [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) + - [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) - [**CI feedback**](./tools/ci_feedback.md/) - [**SOC2 compliance check**](./tools/review.md/#soc2-ticket-compliance) - [**Custom labels**](./tools/describe.md/#handle-custom-labels-from-the-repos-labels-page) - [**Global and wiki configuration**](./usage-guide/configuration_options.md/#wiki-configuration-file) -## Data privacy +## Data Privacy If you host PR-Agent with your OpenAI API key, it is between you and OpenAI. You can read their API data privacy policy here: https://openai.com/enterprise-privacy diff --git a/docs/docs/installation/index.md b/docs/docs/installation/index.md index fc71ecbb..f8b64a27 100644 --- a/docs/docs/installation/index.md +++ b/docs/docs/installation/index.md @@ -1,6 +1,6 @@ # Installation -## self-hosted PR-Agent +## Self-hosted PR-Agent If you choose to host you own PR-Agent, you first need to acquire two tokens: 1. An OpenAI key from [here](https://platform.openai.com/api-keys), with access to GPT-4 (or a key for [other models](../usage-guide/additional_configurations.md/#changing-a-model), if you prefer). diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index f32863eb..3d23c491 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -50,6 +50,10 @@ Any configuration value in [configuration file](https://github.com/Codium-ai/pr- ## GitHub App +!!! note "Configurations for PR-Agent Pro" + PR-Agent Pro for GitHub is an App, hosted by CodiumAI. So all the instructions below are relevant also for PR-Agent Pro users. + Same goes for [GitLab webhook](#gitlab-webhook) and [BitBucket App](#bitbucket-app) sections. + ### GitHub app automatic tools when a new PR is opened The [github_app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L108) section defines GitHub app specific configurations. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c045d8e4..a34c1bc0 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -14,7 +14,7 @@ nav: - 'usage-guide/index.md' - Introduction: 'usage-guide/introduction.md' - Configuration Options: 'usage-guide/configuration_options.md' - - Managing email notifications: 'usage-guide/mail_notifications.md' + - Managing Mail Notifications: 'usage-guide/mail_notifications.md' - Usage and Automation: 'usage-guide/automations_and_usage.md' - Additional Configurations: 'usage-guide/additional_configurations.md' - Tools: From d9efc441df3941513793f8d22b559174dbb135af Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:28:22 +0300 Subject: [PATCH 22/59] readme --- docs/docs/index.md | 22 ++++++++++++---------- docs/docs/tools/analyze.md | 10 +++------- docs/docs/tools/help.md | 13 +++++++++++++ docs/docs/tools/index.md | 1 + 4 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 docs/docs/tools/help.md diff --git a/docs/docs/index.md b/docs/docs/index.md index cec35b45..198bee22 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -84,16 +84,18 @@ Check out the [PR Compression strategy](core-abilities/index.md) page for more d 2. **Improved privacy** - No data will be stored or used to train models. PR-Agent Pro will employ zero data retention, and will use an OpenAI account with zero data retention. 3. **Improved support** - PR-Agent Pro users will receive priority support, and will be able to request new features and capabilities. 4. **Extra features** -In addition to the benefits listed above, PR-Agent Pro will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. It has the following additional tools and features: - - [**Analyze PR components**](./tools/analyze.md/) - - [**Custom Code Suggestions**](./tools/custom_suggestions.md/) - - [**Tests**](./tools/test.md/) - - [**PR documentation**](./tools/documentation.md/) - - [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) - - [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) - - [**CI feedback**](./tools/ci_feedback.md/) - - [**SOC2 compliance check**](./tools/review.md/#soc2-ticket-compliance) - - [**Custom labels**](./tools/describe.md/#handle-custom-labels-from-the-repos-labels-page) - - [**Global and wiki configuration**](./usage-guide/configuration_options.md/#wiki-configuration-file) + - (Tool): [**Analyze PR components**](./tools/analyze.md/) + - (Tool): [**Custom Code Suggestions**](./tools/custom_suggestions.md/) + - (Tool): [**Tests**](./tools/test.md/) + - (Tool): [**PR documentation**](./tools/documentation.md/) + - (Tool): [**Improve Component**](https://pr-agent-docs.codium.ai/tools/improve_component/) + - (Tool): [**Similar code search**](https://pr-agent-docs.codium.ai/tools/similar_code/) + - (Tool): [**CI feedback**](./tools/ci_feedback.md/) + - (Feature): [**Interactive triggering**](./usage-guide/automations_and_usage.md/#interactive-triggering) + - (Feature): [**SOC2 compliance check**](./tools/review.md/#soc2-ticket-compliance) + - (Feature): [**Custom labels**](./tools/describe.md/#handle-custom-labels-from-the-repos-labels-page) + - (Feature): [**Global and wiki configuration**](./usage-guide/configuration_options.md/#wiki-configuration-file) + - (Feature): [**Inline file summary**](https://pr-agent-docs.codium.ai/tools/describe/#inline-file-summary) ## Data Privacy diff --git a/docs/docs/tools/analyze.md b/docs/docs/tools/analyze.md index 0255e759..7af0546e 100644 --- a/docs/docs/tools/analyze.md +++ b/docs/docs/tools/analyze.md @@ -1,7 +1,7 @@ ## Overview -The `analyze` tool combines static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes. +The `analyze` tool combines advanced static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes. -The tool scans the PR code changes, find the code components (methods, functions, classes) that changed, and summarizes the changes in each component. +The tool scans the PR code changes, find the code components (methods, functions, classes) that changed, and enables to interactively generate tests, docs, code suggestions and similar code search for each component. It can be invoked manually by commenting on any PR: ``` @@ -9,13 +9,9 @@ It can be invoked manually by commenting on any PR: ``` ## Example usage -An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): +An example result: ![Analyze 1](https://codium.ai/images/pr_agent/analyze_1.png){width=750} -→ -![Analyze 2](https://codium.ai/images/pr_agent/analyze_2.png){width=750} -→ -![Analyze 3](https://codium.ai/images/pr_agent/analyze_3.png){width=750} **Notes** diff --git a/docs/docs/tools/help.md b/docs/docs/tools/help.md new file mode 100644 index 00000000..ac66d158 --- /dev/null +++ b/docs/docs/tools/help.md @@ -0,0 +1,13 @@ +## Overview +The `help` tool provides a list of all the available tools and their descriptions. +For PR-Agent Pro users, it also enables to trigger each tool by checking the relevant box. +``` +/help +``` + +## Example usage +An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): + +![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750} +→ +![Analyze 2](https://codium.ai/images/pr_agent/help2.png){width=750} diff --git a/docs/docs/tools/index.md b/docs/docs/tools/index.md index b77097b3..49c31a8f 100644 --- a/docs/docs/tools/index.md +++ b/docs/docs/tools/index.md @@ -10,6 +10,7 @@ Here is a list of PR-Agent tools, each with a dedicated page that explains how t | **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines | | **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes | | **[Find Similar Issue (`/similar_issue`](./similar_issues.md))** | Automatically retrieves and presents similar issues | +| **[Help (`/help`](./help.md))** | Provides a list of all the available tools. Also enables to trigger them interactively (💎) | | **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR | | **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user | | **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component | From 60fd1c67fa4894f7c5e0092f579ec52d1b9e0415 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 09:35:41 +0300 Subject: [PATCH 23/59] readme --- docs/docs/usage-guide/index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/docs/usage-guide/index.md b/docs/docs/usage-guide/index.md index e784d1b0..ce714c70 100644 --- a/docs/docs/usage-guide/index.md +++ b/docs/docs/usage-guide/index.md @@ -1,8 +1,10 @@ # Usage guide +This page provides a detailed guide on how to use PR-Agent. It includes information on how to adjust PR-Agent configurations, define which tools will run automatically, manage mail notifications, and other advanced configurations. + + - [Introduction](./introduction.md) - [Configuration Options](./configuration_options.md) -- [Managing Mail Notifications](./mail_notifications.md) - [Usage and Automation](./automations_and_usage.md) - [Local Repo (CLI)](./automations_and_usage.md#local-repo-cli) - [Online Usage](./automations_and_usage.md#online-usage) @@ -11,6 +13,7 @@ - [GitLab Webhook](./automations_and_usage.md#gitlab-webhook) - [BitBucket App](./automations_and_usage.md#bitbucket-app) - [Azure DevOps Provider](./automations_and_usage.md#azure-devops-provider) +- [Managing Mail Notifications](./mail_notifications.md) - [Additional Configurations Walkthrough](./additional_configurations.md) - [Ignoring files from analysis](./additional_configurations.md#ignoring-files-from-analysis) - [Extra instructions](./additional_configurations.md#extra-instructions) From f3b46956173441320bb29df3921b14acfbdb1ff3 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 10:43:56 +0300 Subject: [PATCH 24/59] readme --- docs/docs/tools/help.md | 4 ++++ docs/docs/usage-guide/mail_notifications.md | 8 ++++++++ docs/mkdocs.yml | 1 + 3 files changed, 13 insertions(+) diff --git a/docs/docs/tools/help.md b/docs/docs/tools/help.md index ac66d158..5cfc1e81 100644 --- a/docs/docs/tools/help.md +++ b/docs/docs/tools/help.md @@ -1,6 +1,8 @@ ## Overview The `help` tool provides a list of all the available tools and their descriptions. For PR-Agent Pro users, it also enables to trigger each tool by checking the relevant box. + +It can be invoked manually by commenting on any PR: ``` /help ``` @@ -9,5 +11,7 @@ For PR-Agent Pro users, it also enables to trigger each tool by checking the rel An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): ![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750} + → + ![Analyze 2](https://codium.ai/images/pr_agent/help2.png){width=750} diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 82dc10a0..4c2ee64e 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -7,3 +7,11 @@ If you are subscribed to notifications for a repo with PR-Agent, we recommend tu As an alternative, you can filter in your mail provider the notifications specifically from the PR-Agent bot, [see how](https://www.quora.com/How-can-you-filter-emails-for-specific-people-in-Gmail#:~:text=On%20the%20Filters%20and%20Blocked,the%20body%20of%20the%20email). ![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} + + +Another option to reduce the mail overload is disable the help collapsible section in PR-Agent bot comments, by adding the relevant configurations to the `.pr_agent.toml` file. +For example, to disable the help text for the `pr_reviewer` tool, add to the configuration file: +``` +[pr_reviewer] +enable_help_text = false +``` \ No newline at end of file diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index a34c1bc0..717f42bf 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -25,6 +25,7 @@ nav: - Ask: 'tools/ask.md' - Update Changelog: 'tools/update_changelog.md' - Similar Issues: 'tools/similar_issues.md' + - Help: 'tools/help.md' - 💎 Analyze: 'tools/analyze.md' - 💎 Test: 'tools/test.md' - 💎 Improve Component: 'tools/improve_component.md' From 45eefaa4f0068e596cb330fcf1861292be58b206 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:04:23 +0300 Subject: [PATCH 25/59] readme --- docs/docs/usage-guide/mail_notifications.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 4c2ee64e..1d6f6dcb 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -9,8 +9,9 @@ As an alternative, you can filter in your mail provider the notifications specif ![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} -Another option to reduce the mail overload is disable the help collapsible section in PR-Agent bot comments, by adding the relevant configurations to the `.pr_agent.toml` file. -For example, to disable the help text for the `pr_reviewer` tool, add to the configuration file: +Another option to reduce the mail overload, yet still receive notifications on PR-Agent tools, is to disable the help collapsible section in PR-Agent bot comments. +This can done by setting `enable_help_text=false` configuration to the relevant tool in the configuration file. +For example, to disable the help text for the `pr_reviewer` tool, set: ``` [pr_reviewer] enable_help_text = false From d6b037a63a9244ab32eeb3da9f5c40aa501d530a Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:51:06 +0300 Subject: [PATCH 26/59] readme --- docs/docs/tools/describe.md | 70 ++++++++++++++------------- pr_agent/tools/pr_code_suggestions.py | 41 +++++++++------- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/docs/docs/tools/describe.md b/docs/docs/tools/describe.md index 1510b2e8..50d2af0a 100644 --- a/docs/docs/tools/describe.md +++ b/docs/docs/tools/describe.md @@ -69,22 +69,6 @@ If you prefer to have the file summaries appear in the "Files changed" tab on ev **Note**: that this feature is currently available only for GitHub. -### Handle custom labels from the Repo's labels page 💎 - -You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page: - -* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page) -* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu) - -Now add/edit the custom labels. they should be formatted as follows: - -* Label name: The name of the custom label. -* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
- -The description should be comprehensive and detailed, indicating when to add the desired label. For example: -![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} - - ### Markers template To enable markers, set `pr_description.use_description_markers=true`. @@ -117,6 +101,43 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` - `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false. - `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true. +## Custom labels + +The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`]. + +You can define custom labels that are relevant for your repo and use cases. +Custom labels can be defined in a [configuration file](https://pr-agent-docs.codium.ai/tools/custom_labels/#configuration-options), or directly in the repo's [labels page](#handle-custom-labels-from-the-repos-labels-page). + +Examples for custom labels: + + - `Main topic:performance` - pr_agent:The main topic of this PR is performance + - `New endpoint` - pr_agent:A new endpoint was added in this PR + - `SQL query` - pr_agent:A new SQL query was added in this PR + - `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile + - ... + +The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases. +Note that Labels are not mutually exclusive, so you can add multiple label categories. +
+Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. +Each label description should be a **conditional statement**, that indicates if to add the label to the PR or not, according to the PR content. + + +### Handle custom labels from the Repo's labels page 💎 + +You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page: + +* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page) +* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu) + +Now add/edit the custom labels. they should be formatted as follows: + +* Label name: The name of the custom label. +* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.
+ +The description should be comprehensive and detailed, indicating when to add the desired label. For example: +![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} + ## Usage Tips @@ -145,20 +166,3 @@ The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` * `walkthrough`: the PR walkthrough. - Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all. - -!!! tip "Custom labels" - - The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`]. - - If you specify [custom labels](#handle-custom-labels-from-the-repos-labels-page) in the repo's labels page, you can get tailored labels for your use cases. - Examples for custom labels: - - - `Main topic:performance` - pr_agent:The main topic of this PR is performance - - `New endpoint` - pr_agent:A new endpoint was added in this PR - - `SQL query` - pr_agent:A new SQL query was added in this PR - - `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile - - ... - - The list above is eclectic, and aims to give an idea of different possibilities. Define custom labels that are relevant for your repo and use cases. - Note that Labels are not mutually exclusive, so you can add multiple label categories. -
Make sure to provide proper title, and a detailed and well-phrased description for each label, so the tool will know when to suggest it. diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index 926edf00..ed14d225 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -196,24 +196,31 @@ class PRCodeSuggestions: suggestion_list = [] one_sentence_summary_list = [] for i, suggestion in enumerate(data['code_suggestions']): - if get_settings().pr_code_suggestions.summarize: - if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion: - get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}") - continue - - if suggestion['one_sentence_summary'] in one_sentence_summary_list: - get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}") - continue - - if ('existing_code' in suggestion) and ('improved_code' in suggestion) and ( - suggestion['existing_code'] != suggestion['improved_code']): - suggestion = self._truncate_if_needed(suggestion) + try: if get_settings().pr_code_suggestions.summarize: - one_sentence_summary_list.append(suggestion['one_sentence_summary']) - suggestion_list.append(suggestion) - else: - get_logger().debug( - f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}") + if not suggestion or 'one_sentence_summary' not in suggestion or 'label' not in suggestion or 'relevant_file' not in suggestion: + get_logger().debug(f"Skipping suggestion {i + 1}, because it is invalid: {suggestion}") + continue + + if suggestion['one_sentence_summary'] in one_sentence_summary_list: + get_logger().debug(f"Skipping suggestion {i + 1}, because it is a duplicate: {suggestion}") + continue + + if 'const' in suggestion['suggestion_content'] and 'instead' in suggestion['suggestion_content'] and 'let' in suggestion['suggestion_content']: + get_logger().debug(f"Skipping suggestion {i + 1}, because it uses 'const instead let': {suggestion}") + continue + + if ('existing_code' in suggestion) and ('improved_code' in suggestion) and ( + suggestion['existing_code'] != suggestion['improved_code']): + suggestion = self._truncate_if_needed(suggestion) + if get_settings().pr_code_suggestions.summarize: + one_sentence_summary_list.append(suggestion['one_sentence_summary']) + suggestion_list.append(suggestion) + else: + get_logger().debug( + f"Skipping suggestion {i + 1}, because existing code is equal to improved code {suggestion['existing_code']}") + except Exception as e: + get_logger().error(f"Error processing suggestion {i + 1}: {suggestion}, error: {e}") data['code_suggestions'] = suggestion_list return data From 68f29a41eff80a109ab971101267b33835ec3e04 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 11:52:42 +0300 Subject: [PATCH 27/59] readme --- docs/docs/usage-guide/mail_notifications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/usage-guide/mail_notifications.md b/docs/docs/usage-guide/mail_notifications.md index 1d6f6dcb..f25c7eaa 100644 --- a/docs/docs/usage-guide/mail_notifications.md +++ b/docs/docs/usage-guide/mail_notifications.md @@ -10,7 +10,7 @@ As an alternative, you can filter in your mail provider the notifications specif Another option to reduce the mail overload, yet still receive notifications on PR-Agent tools, is to disable the help collapsible section in PR-Agent bot comments. -This can done by setting `enable_help_text=false` configuration to the relevant tool in the configuration file. +This can done by setting `enable_help_text=false` for the relevant tool in the configuration file. For example, to disable the help text for the `pr_reviewer` tool, set: ``` [pr_reviewer] From dc14b876578765c2da32eaf026771df5330e02a8 Mon Sep 17 00:00:00 2001 From: Charles Uneze Date: Sun, 7 Apr 2024 10:06:05 +0100 Subject: [PATCH 28/59] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de3f51e5..1ac8b7da 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ ___ \ ‣ **CI Feedback 💎 ([`/checks ci_job`](https://pr-agent-docs.codium.ai/tools/ci_feedback/))**: Automatically generates feedback and analysis for a failed CI job. \ -‣ **Similar Code 💎 ([`/find_similar_component`](https://pr-agent-docs.codium.ai/tools/similar_code//))**: Retrieves the most similar code components from inside the organization's codebase, or from open-source code. +‣ **Similar Code 💎 ([`/find_similar_component`](https://pr-agent-docs.codium.ai/tools/similar_code/))**: Retrieves the most similar code components from inside the organization's codebase, or from open-source code. ___ ## Example results From aa2121a48def2f05e2e85e373063259999b1955b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 7 Apr 2024 16:28:30 +0300 Subject: [PATCH 29/59] readme --- docs/docs/tools/improve.md | 2 +- docs/docs/tools/review.md | 4 ++-- docs/docs/usage-guide/configuration_options.md | 2 +- pr_agent/servers/help.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/docs/tools/improve.md b/docs/docs/tools/improve.md index 40945775..b62fd649 100644 --- a/docs/docs/tools/improve.md +++ b/docs/docs/tools/improve.md @@ -72,7 +72,7 @@ To edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agen Examples for extra instructions: ``` [pr_code_suggestions] # /improve # - extra_instructions=""" + extra_instructions="""\ Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? diff --git a/docs/docs/tools/review.md b/docs/docs/tools/review.md index 41ef75ed..c5681bb4 100644 --- a/docs/docs/tools/review.md +++ b/docs/docs/tools/review.md @@ -124,8 +124,8 @@ The tool will first ask the author questions about the PR, and will guide the re Examples for extra instructions: ``` - [pr_reviewer] # /review # - extra_instructions=""" + [pr_reviewer] + extra_instructions="""\ In the code feedback section, emphasize the following: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? diff --git a/docs/docs/usage-guide/configuration_options.md b/docs/docs/usage-guide/configuration_options.md index 1d56baa2..ee908b76 100644 --- a/docs/docs/usage-guide/configuration_options.md +++ b/docs/docs/usage-guide/configuration_options.md @@ -22,7 +22,7 @@ Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) An example content: ``` -[pr_description] # /describe # +[pr_description] keep_original_user_title=false ``` diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 364088ec..9e85887d 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -128,7 +128,7 @@ Be specific, clear, and concise in the instructions. With extra instructions, yo Examples for extra instructions: ``` [pr_description] -extra_instructions=""" +extra_instructions="""\ - The PR title should be in the format: ': ' - The title should be short and concise (up to 10 words) - ... From 2be0e9108e531c2d39bfdd7f05ae76e0e2c0d4c3 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 7 Apr 2024 17:00:40 +0300 Subject: [PATCH 30/59] readme --- pr_agent/algo/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index b017f0aa..5a1e332d 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -575,7 +575,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: num_output_chars = int(chars_per_token * max_tokens) clipped_text = text[:num_output_chars] if add_three_dots: - clipped_text += "...(truncated)" + clipped_text += " ...(truncated)" return clipped_text except Exception as e: get_logger().warning(f"Failed to clip tokens: {e}") From a5a68c2a733d1b34f343af70c0b99aaaf1ff2022 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 7 Apr 2024 17:02:37 +0300 Subject: [PATCH 31/59] readme --- tests/unittest/test_clip_tokens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest/test_clip_tokens.py b/tests/unittest/test_clip_tokens.py index cc52ab7e..2405a06b 100644 --- a/tests/unittest/test_clip_tokens.py +++ b/tests/unittest/test_clip_tokens.py @@ -15,5 +15,5 @@ class TestClipTokens: max_tokens = 10 result = clip_tokens(text, max_tokens) - expected_results = 'line1\nline2\nline3\nli...(truncated)' + expected_results = 'line1\nline2\nline3\nli ...(truncated)' assert result == expected_results From 09f76f45effd7cbce4d6b36a98a03f31fb593beb Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:18:33 +0300 Subject: [PATCH 32/59] Update docs readme --- docs/README.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/docs/README.md b/docs/README.md index a06f01af..42154c96 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,16 +1 @@ -# To install: -pip install mkdocs -pip install mkdocs-material -pip install mkdocs-material-extensions -pip install "mkdocs-material[imaging]" - -# docs -To run localy: `mkdocs serve` - -To expand and customize the theme: [Material MKDocs](https://squidfunk.github.io/mkdocs-material/) - -The deployment is managed on the gh-pages branches. -After each merge to main the deplloyment will be taken care of by GH action automatically and the new version will be available at: [Docs](https://codium-ai.github.io/docs/) - -Github action is located in `.github/workflows/ci.yml` file. - +# [Visit Our Docs Portal](https://pr-agent-docs.codium.ai/) From a543d7ed1adfd888969da697b61143154c746623 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 09:12:50 +0300 Subject: [PATCH 33/59] readme --- docs/docs/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/docs/index.md b/docs/docs/index.md index 198bee22..80b62e11 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -46,25 +46,31 @@ PR-Agent offers extensive pull request functionalities across various git provid ## Example Results +<hr> + #### [/describe](https://github.com/Codium-ai/pr-agent/pull/530) <figure markdown="1"> ![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} </figure> +<hr> #### [/review](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099151) <figure markdown="1"> ![/review](https://www.codium.ai/images/pr_agent/review_new_short_main.png){width=512} </figure> +<hr> #### [/improve](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099159) <figure markdown="1"> ![/improve](https://www.codium.ai/images/pr_agent/improve_new_short_main.png){width=512} </figure> +<hr> #### [/generate_labels](https://github.com/Codium-ai/pr-agent/pull/530) <figure markdown="1"> ![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300} </figure> +<hr> ## How it Works From 84d8f78d0c6215d3d10acfdd9c25074800ddc639 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 14:00:41 +0300 Subject: [PATCH 34/59] publish_output --- pr_agent/algo/utils.py | 2 +- pr_agent/tools/pr_reviewer.py | 3 +++ tests/unittest/test_clip_tokens.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 5a1e332d..4c87c038 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -575,7 +575,7 @@ def clip_tokens(text: str, max_tokens: int, add_three_dots=True) -> str: num_output_chars = int(chars_per_token * max_tokens) clipped_text = text[:num_output_chars] if add_three_dots: - clipped_text += " ...(truncated)" + clipped_text += "\n...(truncated)" return clipped_text except Exception as e: get_logger().warning(f"Failed to clip tokens: {e}") diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 4d1739a5..c257c30a 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -357,6 +357,9 @@ class PRReviewer: return True def set_review_labels(self, data): + if not get_settings().config.publish_output: + return + if (get_settings().pr_reviewer.enable_review_labels_security or get_settings().pr_reviewer.enable_review_labels_effort): try: diff --git a/tests/unittest/test_clip_tokens.py b/tests/unittest/test_clip_tokens.py index 2405a06b..a56ff92f 100644 --- a/tests/unittest/test_clip_tokens.py +++ b/tests/unittest/test_clip_tokens.py @@ -15,5 +15,5 @@ class TestClipTokens: max_tokens = 10 result = clip_tokens(text, max_tokens) - expected_results = 'line1\nline2\nline3\nli ...(truncated)' + expected_results = 'line1\nline2\nline3\nli\n...(truncated)' assert result == expected_results From 8a5b01b4657d5522b6b4d44592f66cf3150f1836 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 8 Apr 2024 14:49:00 +0300 Subject: [PATCH 35/59] empty calc_pr_statistics --- pr_agent/git_providers/github_provider.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index de54ec3f..574e28cf 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -745,22 +745,4 @@ class GithubProvider(GitProvider): return False def calc_pr_statistics(self, pull_request_data: dict): - try: - out = {} - from datetime import datetime - created_at = pull_request_data['created_at'] - closed_at = pull_request_data['closed_at'] - closed_at_datetime = datetime.strptime(closed_at, "%Y-%m-%dT%H:%M:%SZ") - created_at_datetime = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ") - difference = closed_at_datetime - created_at_datetime - out['hours'] = difference.total_seconds() / 3600 - out['commits'] = pull_request_data['commits'] - out['comments'] = pull_request_data['comments'] - out['review_comments'] = pull_request_data['review_comments'] - out['changed_files'] = pull_request_data['changed_files'] - out['additions'] = pull_request_data['additions'] - out['deletions'] = pull_request_data['deletions'] - except Exception as e: - get_logger().exception(f"Failed to calculate PR statistics, error: {e}") - return {} - return out + return {} From 0257b619ff6507729ea2345a753ec9ac10716efb Mon Sep 17 00:00:00 2001 From: phuongvietnamlab <phuongpv@vietnamlab.vn> Date: Tue, 9 Apr 2024 15:47:54 +0700 Subject: [PATCH 36/59] Failed to review PR: name 'is_valid_file' is not defined --- pr_agent/git_providers/codecommit_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/git_providers/codecommit_provider.py b/pr_agent/git_providers/codecommit_provider.py index f035351d..41de6bb3 100644 --- a/pr_agent/git_providers/codecommit_provider.py +++ b/pr_agent/git_providers/codecommit_provider.py @@ -10,7 +10,7 @@ from ..algo.utils import load_large_diff from .git_provider import GitProvider from ..config_loader import get_settings from ..log import get_logger - +from pr_agent.algo.language_handler import is_valid_file class PullRequestCCMimic: """ From 75c4befadf901d6e214aacf779ed904505566028 Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Tue, 9 Apr 2024 22:51:02 +0900 Subject: [PATCH 37/59] feat: set review data to github actions output --- pr_agent/algo/utils.py | 10 ++++++++ pr_agent/servers/github_action_runner.py | 2 ++ pr_agent/settings/configuration.toml | 1 + pr_agent/tools/pr_reviewer.py | 3 ++- tests/unittest/test_github_output.py | 31 ++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/unittest/test_github_output.py diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index c2b6323c..8d3c9c01 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -2,6 +2,7 @@ from __future__ import annotations import difflib import json +import os import re import textwrap from datetime import datetime @@ -661,3 +662,12 @@ def find_line_number_of_relevant_line_in_file(diff_files: List[FilePatchInfo], absolute_position = start2 + delta - 1 break return position, absolute_position + +def github_output(output_data: dict, key_name: str): + if get_settings().github_action_config.enable_output is False: + return + + output = os.getenv('GITHUB_OUTPUT') + key_data = output_data.get(key_name, {}) + with open(output, 'w') as f: + f.write(f"{key_name}={json.dumps(key_data, indent=None, ensure_ascii=False)}") diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index d4278156..6f9b6275 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -59,6 +59,8 @@ async def run_action(): get_settings().set("OPENAI.ORG", OPENAI_ORG) get_settings().set("GITHUB.USER_TOKEN", GITHUB_TOKEN) get_settings().set("GITHUB.DEPLOYMENT_TYPE", "user") + enable_output = get_setting_or_env("GITHUB_ACTION_CONFIG.ENABLE_OUTPUT", False) + get_settings().set("GITHUB_ACTION_CONFIG.ENABLE_OUTPUT", enable_output) # Load the event payload try: diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 837c71d3..0f43ccd8 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -133,6 +133,7 @@ try_fix_invalid_inline_comments = true # auto_review = true # set as env var in .github/workflows/pr-agent.yaml # auto_describe = true # set as env var in .github/workflows/pr-agent.yaml # auto_improve = true # set as env var in .github/workflows/pr-agent.yaml +# enable_output = true # set as env var in .github/workflows/pr-agent.yaml [github_app] # these toggles allows running the github app from custom deployments diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 4d1739a5..38c2ef5c 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -8,7 +8,7 @@ from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models from pr_agent.algo.token_handler import TokenHandler -from pr_agent.algo.utils import convert_to_markdown, load_yaml, ModelType +from pr_agent.algo.utils import convert_to_markdown, github_output, load_yaml, ModelType from pr_agent.config_loader import get_settings from pr_agent.git_providers import get_git_provider from pr_agent.git_providers.git_provider import IncrementalPR, get_main_pr_language @@ -192,6 +192,7 @@ class PRReviewer: data = load_yaml(self.prediction.strip(), keys_fix_yaml=["estimated_effort_to_review_[1-5]:", "security_concerns:", "possible_issues:", "relevant_file:", "relevant_line:", "suggestion:"]) + github_output(data, 'review') if 'code_feedback' in data: code_feedback = data['code_feedback'] diff --git a/tests/unittest/test_github_output.py b/tests/unittest/test_github_output.py new file mode 100644 index 00000000..2ac3d2c7 --- /dev/null +++ b/tests/unittest/test_github_output.py @@ -0,0 +1,31 @@ +import os +import json +from pr_agent.algo.utils import get_settings, github_output + +class TestGitHubOutput: + def test_github_output_enabled(self, monkeypatch, tmp_path): + get_settings().set('GITHUB_ACTION_CONFIG.ENABLE_OUTPUT', True) + monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) + output_data = {'key1': {'value1': 1, 'value2': 2}} + key_name = 'key1' + + github_output(output_data, key_name) + + with open(str(tmp_path / 'output'), 'r') as f: + env_value = f.read() + + actual_key = env_value.split('=')[0] + actual_data = json.loads(env_value.split('=')[1]) + + assert actual_key == key_name + assert actual_data == output_data[key_name] + + def test_github_output_disabled(self, monkeypatch, tmp_path): + get_settings().set('GITHUB_ACTION_CONFIG.ENABLE_OUTPUT', False) + monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) + output_data = {'key1': {'value1': 1, 'value2': 2}} + key_name = 'key1' + + github_output(output_data, key_name) + + assert not os.path.exists(str(tmp_path / 'output')) \ No newline at end of file From 45176ab8932a07ba32cb226f340301a1003dc4fa Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 09:17:29 +0900 Subject: [PATCH 38/59] test: add config not set case --- tests/unittest/test_github_output.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/unittest/test_github_output.py b/tests/unittest/test_github_output.py index 2ac3d2c7..a046ec7d 100644 --- a/tests/unittest/test_github_output.py +++ b/tests/unittest/test_github_output.py @@ -28,4 +28,13 @@ class TestGitHubOutput: github_output(output_data, key_name) + assert not os.path.exists(str(tmp_path / 'output')) + + def test_github_output_notset(self, monkeypatch, tmp_path): + monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) + output_data = {'key1': {'value1': 1, 'value2': 2}} + key_name = 'key1' + + github_output(output_data, key_name) + assert not os.path.exists(str(tmp_path / 'output')) \ No newline at end of file From 3412095d81844f97abc6146603ceea1d584ea279 Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 09:18:21 +0900 Subject: [PATCH 39/59] chore: change default to true, if use in github actions --- pr_agent/servers/github_action_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 6f9b6275..ad16958e 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -59,7 +59,7 @@ async def run_action(): get_settings().set("OPENAI.ORG", OPENAI_ORG) get_settings().set("GITHUB.USER_TOKEN", GITHUB_TOKEN) get_settings().set("GITHUB.DEPLOYMENT_TYPE", "user") - enable_output = get_setting_or_env("GITHUB_ACTION_CONFIG.ENABLE_OUTPUT", False) + enable_output = get_setting_or_env("GITHUB_ACTION_CONFIG.ENABLE_OUTPUT", True) get_settings().set("GITHUB_ACTION_CONFIG.ENABLE_OUTPUT", enable_output) # Load the event payload From 108b1afa0ee8d853517a10e75ea4aef63f8db2bd Mon Sep 17 00:00:00 2001 From: Yuta Nishi <riyaamemiya@gmail.com> Date: Wed, 10 Apr 2024 14:44:38 +0900 Subject: [PATCH 40/59] add new models --- pr_agent/algo/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pr_agent/algo/__init__.py b/pr_agent/algo/__init__.py index 19968be5..1357db29 100644 --- a/pr_agent/algo/__init__.py +++ b/pr_agent/algo/__init__.py @@ -11,6 +11,8 @@ MAX_TOKENS = { 'gpt-4-1106-preview': 128000, # 128K, but may be limited by config.max_model_tokens 'gpt-4-0125-preview': 128000, # 128K, but may be limited by config.max_model_tokens 'gpt-4-turbo-preview': 128000, # 128K, but may be limited by config.max_model_tokens + 'gpt-4-turbo-2024-04-09': 128000, # 128K, but may be limited by config.max_model_tokens + 'gpt-4-turbo': 128000, # 128K, but may be limited by config.max_model_tokens 'claude-instant-1': 100000, 'claude-2': 100000, 'command-nightly': 4096, From 97dcb34d771f0b8bb50e7d953cb23eb81487c761 Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 22:16:09 +0900 Subject: [PATCH 41/59] clean: rename to github_action_output --- pr_agent/algo/utils.py | 2 +- pr_agent/tools/pr_reviewer.py | 4 ++-- tests/unittest/test_github_output.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 8d3c9c01..c719c240 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -663,7 +663,7 @@ def find_line_number_of_relevant_line_in_file(diff_files: List[FilePatchInfo], break return position, absolute_position -def github_output(output_data: dict, key_name: str): +def github_action_output(output_data: dict, key_name: str): if get_settings().github_action_config.enable_output is False: return diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index 38c2ef5c..53f7b0c0 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -8,7 +8,7 @@ from pr_agent.algo.ai_handlers.base_ai_handler import BaseAiHandler from pr_agent.algo.ai_handlers.litellm_ai_handler import LiteLLMAIHandler from pr_agent.algo.pr_processing import get_pr_diff, retry_with_fallback_models from pr_agent.algo.token_handler import TokenHandler -from pr_agent.algo.utils import convert_to_markdown, github_output, load_yaml, ModelType +from pr_agent.algo.utils import convert_to_markdown, github_action_output, load_yaml, ModelType from pr_agent.config_loader import get_settings from pr_agent.git_providers import get_git_provider from pr_agent.git_providers.git_provider import IncrementalPR, get_main_pr_language @@ -192,7 +192,7 @@ class PRReviewer: data = load_yaml(self.prediction.strip(), keys_fix_yaml=["estimated_effort_to_review_[1-5]:", "security_concerns:", "possible_issues:", "relevant_file:", "relevant_line:", "suggestion:"]) - github_output(data, 'review') + github_action_output(data, 'review') if 'code_feedback' in data: code_feedback = data['code_feedback'] diff --git a/tests/unittest/test_github_output.py b/tests/unittest/test_github_output.py index a046ec7d..10a2a02e 100644 --- a/tests/unittest/test_github_output.py +++ b/tests/unittest/test_github_output.py @@ -1,15 +1,15 @@ import os import json -from pr_agent.algo.utils import get_settings, github_output +from pr_agent.algo.utils import get_settings, github_action_output class TestGitHubOutput: - def test_github_output_enabled(self, monkeypatch, tmp_path): + def test_github_action_output_enabled(self, monkeypatch, tmp_path): get_settings().set('GITHUB_ACTION_CONFIG.ENABLE_OUTPUT', True) monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) output_data = {'key1': {'value1': 1, 'value2': 2}} key_name = 'key1' - github_output(output_data, key_name) + github_action_output(output_data, key_name) with open(str(tmp_path / 'output'), 'r') as f: env_value = f.read() @@ -20,21 +20,21 @@ class TestGitHubOutput: assert actual_key == key_name assert actual_data == output_data[key_name] - def test_github_output_disabled(self, monkeypatch, tmp_path): + def test_github_action_output_disabled(self, monkeypatch, tmp_path): get_settings().set('GITHUB_ACTION_CONFIG.ENABLE_OUTPUT', False) monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) output_data = {'key1': {'value1': 1, 'value2': 2}} key_name = 'key1' - github_output(output_data, key_name) + github_action_output(output_data, key_name) assert not os.path.exists(str(tmp_path / 'output')) - def test_github_output_notset(self, monkeypatch, tmp_path): + def test_github_action_output_notset(self, monkeypatch, tmp_path): monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) output_data = {'key1': {'value1': 1, 'value2': 2}} key_name = 'key1' - github_output(output_data, key_name) + github_action_output(output_data, key_name) assert not os.path.exists(str(tmp_path / 'output')) \ No newline at end of file From ae633b3cea456c9a6d155e9311b05b494249683f Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 22:30:16 +0900 Subject: [PATCH 42/59] refine: github_action_output --- pr_agent/algo/utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index c719c240..a1aaf50a 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -664,10 +664,13 @@ def find_line_number_of_relevant_line_in_file(diff_files: List[FilePatchInfo], return position, absolute_position def github_action_output(output_data: dict, key_name: str): - if get_settings().github_action_config.enable_output is False: - return - - output = os.getenv('GITHUB_OUTPUT') - key_data = output_data.get(key_name, {}) - with open(output, 'w') as f: - f.write(f"{key_name}={json.dumps(key_data, indent=None, ensure_ascii=False)}") + try: + if not get_settings().get('github_action_config.enable_output', False): + return + + key_data = output_data.get(key_name, {}) + with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: + print(f"{key_name}={json.dumps(key_data, indent=None, ensure_ascii=False)}", file=fh) + except Exception as e: + get_logger().error(f"Failed to write to GitHub Action output: {e}") + return \ No newline at end of file From 5e5ead98dea6598459833d750b9ca76829b1f447 Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 22:36:15 +0900 Subject: [PATCH 43/59] test: rename & add error case --- ...t_github_output.py => test_github_action_output.py} | 10 ++++++++++ 1 file changed, 10 insertions(+) rename tests/unittest/{test_github_output.py => test_github_action_output.py} (77%) diff --git a/tests/unittest/test_github_output.py b/tests/unittest/test_github_action_output.py similarity index 77% rename from tests/unittest/test_github_output.py rename to tests/unittest/test_github_action_output.py index 10a2a02e..2b8e0db1 100644 --- a/tests/unittest/test_github_output.py +++ b/tests/unittest/test_github_action_output.py @@ -31,10 +31,20 @@ class TestGitHubOutput: assert not os.path.exists(str(tmp_path / 'output')) def test_github_action_output_notset(self, monkeypatch, tmp_path): + # not set config monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) output_data = {'key1': {'value1': 1, 'value2': 2}} key_name = 'key1' github_action_output(output_data, key_name) + assert not os.path.exists(str(tmp_path / 'output')) + + def test_github_action_output_error_case(self, monkeypatch, tmp_path): + monkeypatch.setenv('GITHUB_OUTPUT', str(tmp_path / 'output')) + output_data = None # invalid data + key_name = 'key1' + + github_action_output(output_data, key_name) + assert not os.path.exists(str(tmp_path / 'output')) \ No newline at end of file From aef1c6ecde14c367662e6bce34b1d489fa567847 Mon Sep 17 00:00:00 2001 From: idubnori <i.dub.nori@gmail.com> Date: Wed, 10 Apr 2024 23:04:29 +0900 Subject: [PATCH 44/59] docs: add feature spec and config --- docs/docs/usage-guide/automations_and_usage.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/docs/usage-guide/automations_and_usage.md b/docs/docs/usage-guide/automations_and_usage.md index d20516fd..15b52402 100644 --- a/docs/docs/usage-guide/automations_and_usage.md +++ b/docs/docs/usage-guide/automations_and_usage.md @@ -115,10 +115,15 @@ Specifically, start by setting the following environment variables: github_action_config.auto_review: "true" # enable\disable auto review github_action_config.auto_describe: "true" # enable\disable auto describe github_action_config.auto_improve: "true" # enable\disable auto improve + github_action_config.enable_output: "true" # enable\disable github actions output parameter ``` `github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened. If not set, the default configuration is for all three tools to run automatically when a new PR is opened. +`github_action_config.enable_output` are used to enable/disable github actions [output parameter](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-docker-container-and-javascript-actions) (default is `true`). +Review result is output as JSON to `steps.{step-id}.outputs.review` property. +The JSON structure is equivalent to the yaml data structure defined in [pr_reviewer_prompts.toml](https://github.com/idubnori/pr-agent/blob/main/pr_agent/settings/pr_reviewer_prompts.toml). + Note that you can give additional config parameters by adding environment variables to `.github/workflows/pr_agent.yml`, or by using a `.pr_agent.toml` file in the root of your repo, similar to the GitHub App usage. For example, you can set an environment variable: `pr_description.add_original_user_description=false`, or add a `.pr_agent.toml` file with the following content: From 4c83bf695d4fc1e3f5a14a4002c7e70e55f314ae Mon Sep 17 00:00:00 2001 From: Pavel Kvach <pavel.kvach@gmail.com> Date: Fri, 12 Apr 2024 10:50:00 +0300 Subject: [PATCH 45/59] Handle OPENAI_KEY not set error in github_action_runner.py Fixes https://github.com/Codium-ai/pr-agent/issues/855 --- pr_agent/servers/github_action_runner.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 53b54a29..1aafcaae 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -46,15 +46,16 @@ async def run_action(): if not GITHUB_EVENT_PATH: print("GITHUB_EVENT_PATH not set") return - if not OPENAI_KEY: - print("OPENAI_KEY not set") - return if not GITHUB_TOKEN: print("GITHUB_TOKEN not set") return # Set the environment variables in the settings - get_settings().set("OPENAI.KEY", OPENAI_KEY) + if OPENAI_KEY: + get_settings().set("OPENAI.KEY", OPENAI_KEY) + else: + # Might not be set if the user is using models not from OpenAI + print("OPENAI_KEY not set") if OPENAI_ORG: get_settings().set("OPENAI.ORG", OPENAI_ORG) get_settings().set("GITHUB.USER_TOKEN", GITHUB_TOKEN) From a4680ded939401c60e61ab8192da989ad283ad8a Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Fri, 12 Apr 2024 20:32:47 +0300 Subject: [PATCH 46/59] protections --- pr_agent/agent/pr_agent.py | 3 ++ pr_agent/algo/pr_processing.py | 62 +++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/pr_agent/agent/pr_agent.py b/pr_agent/agent/pr_agent.py index 5be0f779..d2542cf2 100644 --- a/pr_agent/agent/pr_agent.py +++ b/pr_agent/agent/pr_agent.py @@ -73,6 +73,9 @@ class PRAgent: args = update_settings_from_args(args) action = action.lstrip("/").lower() + if action not in command2class: + get_logger().debug(f"Unknown command: {action}") + return False with get_logger().contextualize(command=action): get_logger().info("PR-Agent request handler started", analytics=True) if action == "reflect_and_review": diff --git a/pr_agent/algo/pr_processing.py b/pr_agent/algo/pr_processing.py index 90482a02..2c5a2957 100644 --- a/pr_agent/algo/pr_processing.py +++ b/pr_agent/algo/pr_processing.py @@ -9,7 +9,7 @@ from pr_agent.algo.git_patch_processing import convert_to_hunks_with_lines_numbe from pr_agent.algo.language_handler import sort_files_by_main_languages from pr_agent.algo.file_filter import filter_ignored from pr_agent.algo.token_handler import TokenHandler -from pr_agent.algo.utils import get_max_tokens, ModelType +from pr_agent.algo.utils import get_max_tokens, clip_tokens, ModelType from pr_agent.config_loader import get_settings from pr_agent.git_providers.git_provider import GitProvider from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo @@ -87,22 +87,34 @@ def get_pr_diff(git_provider: GitProvider, token_handler: TokenHandler, model: s # if we are over the limit, start pruning get_logger().info(f"Tokens: {total_tokens}, total tokens over limit: {get_max_tokens(model)}, " f"pruning diff.") - patches_compressed, modified_file_names, deleted_file_names, added_file_names = \ + patches_compressed, modified_file_names, deleted_file_names, added_file_names, total_tokens_new = \ pr_generate_compressed_diff(pr_languages, token_handler, model, add_line_numbers_to_hunks) + # Insert additional information about added, modified, and deleted files if there is enough space + max_tokens = get_max_tokens(model) - OUTPUT_BUFFER_TOKENS_HARD_THRESHOLD + curr_token = total_tokens_new # == token_handler.count_tokens(final_diff)+token_handler.prompt_tokens final_diff = "\n".join(patches_compressed) - if added_file_names: + delta_tokens = 10 + if added_file_names and (max_tokens - curr_token) > delta_tokens: added_list_str = ADDED_FILES_ + "\n".join(added_file_names) - final_diff = final_diff + "\n\n" + added_list_str - if modified_file_names: + added_list_str = clip_tokens(added_list_str, max_tokens - curr_token) + if added_list_str: + final_diff = final_diff + "\n\n" + added_list_str + curr_token += token_handler.count_tokens(added_list_str) + 2 + if modified_file_names and (max_tokens - curr_token) > delta_tokens: modified_list_str = MORE_MODIFIED_FILES_ + "\n".join(modified_file_names) - final_diff = final_diff + "\n\n" + modified_list_str - if deleted_file_names: + modified_list_str = clip_tokens(modified_list_str, max_tokens - curr_token) + if modified_list_str: + final_diff = final_diff + "\n\n" + modified_list_str + curr_token += token_handler.count_tokens(modified_list_str) + 2 + if deleted_file_names and (max_tokens - curr_token) > delta_tokens: deleted_list_str = DELETED_FILES_ + "\n".join(deleted_file_names) - final_diff = final_diff + "\n\n" + deleted_list_str + deleted_list_str = clip_tokens(deleted_list_str, max_tokens - curr_token) + if deleted_list_str: + final_diff = final_diff + "\n\n" + deleted_list_str try: get_logger().debug(f"After pruning, added_list_str: {added_list_str}, modified_list_str: {modified_list_str}, " - f"deleted_list_str: {deleted_list_str}") + f"deleted_list_str: {deleted_list_str}") except Exception as e: pass return final_diff @@ -149,7 +161,7 @@ def pr_generate_extended_diff(pr_languages: list, def pr_generate_compressed_diff(top_langs: list, token_handler: TokenHandler, model: str, - convert_hunks_to_line_numbers: bool) -> Tuple[list, list, list, list]: + convert_hunks_to_line_numbers: bool) -> Tuple[list, list, list, list, int]: """ Generate a compressed diff string for a pull request, using diff minimization techniques to reduce the number of tokens used. @@ -195,10 +207,11 @@ def pr_generate_compressed_diff(top_langs: list, token_handler: TokenHandler, mo patch = handle_patch_deletions(patch, original_file_content_str, new_file_content_str, file.filename, file.edit_type) if patch is None: - if not deleted_files_list: - total_tokens += token_handler.count_tokens(DELETED_FILES_) - deleted_files_list.append(file.filename) - total_tokens += token_handler.count_tokens(file.filename) + 1 + # if not deleted_files_list: + # total_tokens += token_handler.count_tokens(DELETED_FILES_) + if file.filename not in deleted_files_list: + deleted_files_list.append(file.filename) + # total_tokens += token_handler.count_tokens(file.filename) + 1 continue if convert_hunks_to_line_numbers: @@ -219,14 +232,17 @@ def pr_generate_compressed_diff(top_langs: list, token_handler: TokenHandler, mo if get_settings().config.verbosity_level >= 2: get_logger().warning(f"Patch too large, minimizing it, {file.filename}") if file.edit_type == EDIT_TYPE.ADDED: - if not added_files_list: - total_tokens += token_handler.count_tokens(ADDED_FILES_) - added_files_list.append(file.filename) + # if not added_files_list: + # total_tokens += token_handler.count_tokens(ADDED_FILES_) + if file.filename not in added_files_list: + added_files_list.append(file.filename) + # total_tokens += token_handler.count_tokens(file.filename) + 1 else: - if not modified_files_list: - total_tokens += token_handler.count_tokens(MORE_MODIFIED_FILES_) - modified_files_list.append(file.filename) - total_tokens += token_handler.count_tokens(file.filename) + 1 + # if not modified_files_list: + # total_tokens += token_handler.count_tokens(MORE_MODIFIED_FILES_) + if file.filename not in modified_files_list: + modified_files_list.append(file.filename) + # total_tokens += token_handler.count_tokens(file.filename) + 1 continue if patch: @@ -239,7 +255,7 @@ def pr_generate_compressed_diff(top_langs: list, token_handler: TokenHandler, mo if get_settings().config.verbosity_level >= 2: get_logger().info(f"Tokens: {total_tokens}, last filename: {file.filename}") - return patches, modified_files_list, deleted_files_list, added_files_list + return patches, modified_files_list, deleted_files_list, added_files_list, total_tokens async def retry_with_fallback_models(f: Callable, model_type: ModelType = ModelType.REGULAR): @@ -382,4 +398,4 @@ def get_pr_multi_diffs(git_provider: GitProvider, final_diff = "\n".join(patches) final_diff_list.append(final_diff) - return final_diff_list + return final_diff_list \ No newline at end of file From 8f0f08006f405bfab3cf8f8f353e4a216ffc5426 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 12:00:19 +0300 Subject: [PATCH 47/59] s --- pr_agent/algo/ai_handlers/base_ai_handler.py | 2 +- .../algo/ai_handlers/litellm_ai_handler.py | 12 +++++++- pr_agent/servers/github_app.py | 9 ++++-- pr_agent/settings/configuration.toml | 6 ++-- pr_agent/tools/pr_questions.py | 29 +++++++++++++++++-- 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/pr_agent/algo/ai_handlers/base_ai_handler.py b/pr_agent/algo/ai_handlers/base_ai_handler.py index c8473fb3..b5166b8e 100644 --- a/pr_agent/algo/ai_handlers/base_ai_handler.py +++ b/pr_agent/algo/ai_handlers/base_ai_handler.py @@ -15,7 +15,7 @@ class BaseAiHandler(ABC): pass @abstractmethod - async def chat_completion(self, model: str, system: str, user: str, temperature: float = 0.2): + async def chat_completion(self, model: str, system: str, user: str, temperature: float = 0.2, img_path: str = None): """ This method should be implemented to return a chat completion from the AI model. Args: diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index d07542f6..536faf41 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -102,13 +102,23 @@ class LiteLLMAIHandler(BaseAiHandler): retry=retry_if_exception_type((openai.APIError, openai.APIConnectionError, openai.Timeout)), # No retry on RateLimitError stop=stop_after_attempt(OPENAI_RETRIES) ) - async def chat_completion(self, model: str, system: str, user: str, temperature: float = 0.2): + async def chat_completion(self, model: str, system: str, user: str, temperature: float = 0.2, img_path: str = None): try: resp, finish_reason = None, None deployment_id = self.deployment_id if self.azure: model = 'azure/' + model messages = [{"role": "system", "content": system}, {"role": "user", "content": user}] + if img_path: + import requests + r = requests.get(img_path, allow_redirects=True) + if r.status_code == 404: + error_msg = "The image link is not alive. Please repost the image, get a new address, and send the question again." + get_logger().error(error_msg) + return f"{error_msg}", "error" + messages[1]["content"] = [{"type": "text", "text": messages[1]["content"]}, + {"type": "image_url", "image_url": {"url": img_path}}] + kwargs = { "model": model, "deployment_id": deployment_id, diff --git a/pr_agent/servers/github_app.py b/pr_agent/servers/github_app.py index bc7042b1..6d942289 100644 --- a/pr_agent/servers/github_app.py +++ b/pr_agent/servers/github_app.py @@ -86,8 +86,13 @@ async def handle_comments_on_pr(body: Dict[str, Any], return {} comment_body = body.get("comment", {}).get("body") if comment_body and isinstance(comment_body, str) and not comment_body.lstrip().startswith("/"): - get_logger().info("Ignoring comment not starting with /") - return {} + if '/ask' in comment_body and comment_body.strip().startswith('> ![image]'): + comment_body_split = comment_body.split('/ask') + comment_body = '/ask' + comment_body_split[1] +'/n' +comment_body_split[0].strip() + get_logger().info(f"Reformatting comment_body so command is at the beginning: {comment_body}") + else: + get_logger().info("Ignoring comment not starting with /") + return {} disable_eyes = False if "issue" in body and "pull_request" in body["issue"] and "url" in body["issue"]["pull_request"]: api_url = body["issue"]["pull_request"]["url"] diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 39282706..d49b345c 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -1,7 +1,7 @@ [config] -model="gpt-4" # "gpt-4-0125-preview" -model_turbo="gpt-4-0125-preview" -fallback_models=["gpt-3.5-turbo-16k"] +model="gpt-4-turbo" # "gpt-4-0125-preview" +model_turbo="gpt-4-turbo" +fallback_models=["gpt-4-0125-preview"] git_provider="github" publish_output=true publish_output_progress=true diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py index 4e1d3c1e..1e2a360e 100644 --- a/pr_agent/tools/pr_questions.py +++ b/pr_agent/tools/pr_questions.py @@ -56,6 +56,12 @@ class PRQuestions: get_logger().debug("Relevant configs", artifacts=relevant_configs) if get_settings().config.publish_output: self.git_provider.publish_comment("Preparing answer...", is_temporary=True) + + # identify image + img_path = self.idenfity_image_in_comment() + if img_path: + get_logger().debug(f"Image path identified", artifact=img_path) + await retry_with_fallback_models(self._prepare_prediction) pr_comment = self._prepare_pr_answer() @@ -71,6 +77,19 @@ class PRQuestions: self.git_provider.remove_initial_comment() return "" + def idenfity_image_in_comment(self): + img_path = '' + if '![image]' in self.question_str: + # assuming structure: + # /ask question ... > ![image](img_path) + img_path = self.question_str.split('![image]')[1].strip().strip('()') + self.vars['img_path'] = img_path + elif 'https://' in self.question_str and '.png' in self.question_str: # direct image link + # include https:// in the image path + img_path = 'https://' + self.question_str.split('https://')[1] + self.vars['img_path'] = img_path + return img_path + async def _prepare_prediction(self, model: str): self.patches_diff = get_pr_diff(self.git_provider, self.token_handler, model) if self.patches_diff: @@ -86,8 +105,14 @@ class PRQuestions: environment = Environment(undefined=StrictUndefined) system_prompt = environment.from_string(get_settings().pr_questions_prompt.system).render(variables) user_prompt = environment.from_string(get_settings().pr_questions_prompt.user).render(variables) - response, finish_reason = await self.ai_handler.chat_completion(model=model, temperature=0.2, - system=system_prompt, user=user_prompt) + if 'img_path' in variables: + img_path = self.vars['img_path'] + response, finish_reason = await self.ai_handler.chat_completion(model=model, temperature=0.2, + system=system_prompt, user=user_prompt, + img_path=img_path) + else: + response, finish_reason = await self.ai_handler.chat_completion(model=model, temperature=0.2, + system=system_prompt, user=user_prompt) return response def _prepare_pr_answer(self) -> str: From 4683a29819be315268e922dd3652fca53a50cec8 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 12:34:14 +0300 Subject: [PATCH 48/59] s --- docs/docs/tools/ask.md | 35 +++++++++++++++++-- .../algo/ai_handlers/litellm_ai_handler.py | 2 +- pr_agent/servers/github_app.py | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/docs/tools/ask.md b/docs/docs/tools/ask.md index 453807fd..79c4f00f 100644 --- a/docs/docs/tools/ask.md +++ b/docs/docs/tools/ask.md @@ -7,9 +7,9 @@ It can be invoked manually by commenting on any PR: ``` For example: -![Ask Comment](https://codium.ai/images/pr_agent/ask_comment.png){width=768} +![Ask Comment](https://codium.ai/images/pr_agent/ask_comment.png){width=512} -![Ask](https://codium.ai/images/pr_agent/ask.png){width=768} +![Ask](https://codium.ai/images/pr_agent/ask.png){width=512} ## Ask lines @@ -18,6 +18,35 @@ You can run `/ask` on specific lines of code in the PR from the PR's diff view. - To select multiple lines, click on the '+' sign of the first line and then hold and drag to select the rest of the lines. - write `/ask "..."` in the comment box and press `Add single comment` button. -![Ask Line](https://codium.ai/images/pr_agent/Ask_line.png){width=768} +![Ask Line](https://codium.ai/images/pr_agent/Ask_line.png){width=512} Note that the tool does not have "memory" of previous questions, and answers each question independently. + +## Ask on images (using the PR code as context) + +You can also ask questions about images that appear in the comment, where the entire PR is considered as the context. The tool will answer questions based on the images in the PR. +The basic syntax is: +``` +/ask "..." + +[Image](https://real_link_to_image) +``` + +Note that GitHub has a mecahnism of pasting images in comments. However, pasted image does not provide a direct link. +To get a direct link to the image, we recommend using the following steps: +1) send a comment that contains only the image: + +![Ask image1](https://codium.ai/images/pr_agent/ask_images1.png){width=512} + +2) quote reply to that comment: + +![Ask image2](https://codium.ai/images/pr_agent/ask_images2.png){width=512} + +3) type the question below the image: + +![Ask image3](https://codium.ai/images/pr_agent/ask_images3.png){width=512} +![Ask image4](https://codium.ai/images/pr_agent/ask_images3.png){width=512} + +4) post the comment, and receive the answer: + +![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} \ No newline at end of file diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index 536faf41..a547d956 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -113,7 +113,7 @@ class LiteLLMAIHandler(BaseAiHandler): import requests r = requests.get(img_path, allow_redirects=True) if r.status_code == 404: - error_msg = "The image link is not alive. Please repost the image, get a new address, and send the question again." + error_msg = f"The image link is not [alive](img_path).\nPlease repost the original image as a comment, and send the question again with 'quote reply' (see [instructions](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context))." get_logger().error(error_msg) return f"{error_msg}", "error" messages[1]["content"] = [{"type": "text", "text": messages[1]["content"]}, diff --git a/pr_agent/servers/github_app.py b/pr_agent/servers/github_app.py index 6d942289..f0d1340d 100644 --- a/pr_agent/servers/github_app.py +++ b/pr_agent/servers/github_app.py @@ -88,7 +88,7 @@ async def handle_comments_on_pr(body: Dict[str, Any], if comment_body and isinstance(comment_body, str) and not comment_body.lstrip().startswith("/"): if '/ask' in comment_body and comment_body.strip().startswith('> ![image]'): comment_body_split = comment_body.split('/ask') - comment_body = '/ask' + comment_body_split[1] +'/n' +comment_body_split[0].strip() + comment_body = '/ask' + comment_body_split[1] +' \n' +comment_body_split[0].strip().lstrip('>') get_logger().info(f"Reformatting comment_body so command is at the beginning: {comment_body}") else: get_logger().info("Ignoring comment not starting with /") From f0230fce79dbb2fcba44fde112e042b282f034e4 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 12:37:54 +0300 Subject: [PATCH 49/59] gpt-4-turbo-2024-04-09 --- pr_agent/settings/configuration.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index d49b345c..4ab511c1 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -1,6 +1,6 @@ [config] -model="gpt-4-turbo" # "gpt-4-0125-preview" -model_turbo="gpt-4-turbo" +model="gpt-4-turbo-2024-04-09" +model_turbo="gpt-4-turbo-2024-04-09" fallback_models=["gpt-4-0125-preview"] git_provider="github" publish_output=true From 86e64501dfb69ff87aa2b165035902ccae6d2b2f Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 12:43:26 +0300 Subject: [PATCH 50/59] ask --- pr_agent/servers/help.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pr_agent/servers/help.py b/pr_agent/servers/help.py index 9e85887d..d76f70a4 100644 --- a/pr_agent/servers/help.py +++ b/pr_agent/servers/help.py @@ -160,16 +160,17 @@ It can be invoked manually by commenting on any PR: /ask "..." ``` -Note that the tool does not have "memory" of previous questions, and answers each question independently. +Note that the tool does not have "memory" of previous questions, and answers each question independently. +You can ask questions about the entire PR, about specific code lines, or about an image related to the PR code changes. """ - output += "\n\n<table>" - - # general - output += "\n\n<tr><td><details> <summary><strong> More PR-Agent commands</strong></summary><hr> \n\n" - output += HelpMessage.get_general_bot_help_text() - output += "\n\n</details></td></tr>\n\n" - - output += "</table>" + # output += "\n\n<table>" + # + # # # general + # # output += "\n\n<tr><td><details> <summary><strong> More PR-Agent commands</strong></summary><hr> \n\n" + # # output += HelpMessage.get_general_bot_help_text() + # # output += "\n\n</details></td></tr>\n\n" + # + # output += "</table>" output += f"\n\nSee the [ask usage](https://pr-agent-docs.codium.ai/tools/ask/) page for a comprehensive guide on using this tool.\n\n" From 92ef2b4464ce6fed2ab68d901428cc7cc03eb752 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 14:09:58 +0300 Subject: [PATCH 51/59] ask --- README.md | 5 +++++ .../algo/ai_handlers/litellm_ai_handler.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1ac8b7da..91f7a5ef 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ## News and Updates +### April 14, 2024 +You can now ask questions about images that appear in the comment, where the entire PR is considered as the context. +see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context). +![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} + ### March 24, 2024 PR-Agent is now available for easy installation via [pip](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package). diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index a547d956..4acd55ea 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -1,5 +1,5 @@ import os - +import requests import boto3 import litellm import openai @@ -110,12 +110,16 @@ class LiteLLMAIHandler(BaseAiHandler): model = 'azure/' + model messages = [{"role": "system", "content": system}, {"role": "user", "content": user}] if img_path: - import requests - r = requests.get(img_path, allow_redirects=True) - if r.status_code == 404: - error_msg = f"The image link is not [alive](img_path).\nPlease repost the original image as a comment, and send the question again with 'quote reply' (see [instructions](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context))." - get_logger().error(error_msg) - return f"{error_msg}", "error" + try: + # check if the image link is alive + r = requests.head(img_path, allow_redirects=True) + if r.status_code == 404: + error_msg = f"The image link is not [alive](img_path).\nPlease repost the original image as a comment, and send the question again with 'quote reply' (see [instructions](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context))." + get_logger().error(error_msg) + return f"{error_msg}", "error" + except Exception as e: + get_logger().error(f"Error fetching image: {img_path}", e) + return f"Error fetching image: {img_path}", "error" messages[1]["content"] = [{"type": "text", "text": messages[1]["content"]}, {"type": "image_url", "image_url": {"url": img_path}}] From 506e3007c4549262b82c2478ca0c83afccfca569 Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 14:11:04 +0300 Subject: [PATCH 52/59] ask --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91f7a5ef..40453d37 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,9 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ### April 14, 2024 You can now ask questions about images that appear in the comment, where the entire PR is considered as the context. -see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context). -![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} +see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context) for more details. + +<kbd><img src="https://codium.ai/images/pr_agent/ask_images5.png" width="512"></kbd> ### March 24, 2024 PR-Agent is now available for easy installation via [pip](https://pr-agent-docs.codium.ai/installation/locally/#using-pip-package). From 44eb0b4f237d68df03955082c8338464bdf478ee Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 14:12:48 +0300 Subject: [PATCH 53/59] ask --- pr_agent/tools/pr_questions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/tools/pr_questions.py b/pr_agent/tools/pr_questions.py index 1e2a360e..d78d0880 100644 --- a/pr_agent/tools/pr_questions.py +++ b/pr_agent/tools/pr_questions.py @@ -84,7 +84,7 @@ class PRQuestions: # /ask question ... > ![image](img_path) img_path = self.question_str.split('![image]')[1].strip().strip('()') self.vars['img_path'] = img_path - elif 'https://' in self.question_str and '.png' in self.question_str: # direct image link + elif 'https://' in self.question_str and ('.png' in self.question_str or 'jpg' in self.question_str): # direct image link # include https:// in the image path img_path = 'https://' + self.question_str.split('https://')[1] self.vars['img_path'] = img_path From 8168ce0c8eedda9c1ae212b7a098957d27f8743e Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Sun, 14 Apr 2024 14:45:15 +0300 Subject: [PATCH 54/59] ask --- docs/docs/tools/ask.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/docs/tools/ask.md b/docs/docs/tools/ask.md index 79c4f00f..f7678337 100644 --- a/docs/docs/tools/ask.md +++ b/docs/docs/tools/ask.md @@ -22,7 +22,7 @@ You can run `/ask` on specific lines of code in the PR from the PR's diff view. Note that the tool does not have "memory" of previous questions, and answers each question independently. -## Ask on images (using the PR code as context) +## Ask on images You can also ask questions about images that appear in the comment, where the entire PR is considered as the context. The tool will answer questions based on the images in the PR. The basic syntax is: @@ -34,6 +34,7 @@ The basic syntax is: Note that GitHub has a mecahnism of pasting images in comments. However, pasted image does not provide a direct link. To get a direct link to the image, we recommend using the following steps: + 1) send a comment that contains only the image: ![Ask image1](https://codium.ai/images/pr_agent/ask_images1.png){width=512} @@ -45,8 +46,11 @@ To get a direct link to the image, we recommend using the following steps: 3) type the question below the image: ![Ask image3](https://codium.ai/images/pr_agent/ask_images3.png){width=512} -![Ask image4](https://codium.ai/images/pr_agent/ask_images3.png){width=512} +![Ask image4](https://codium.ai/images/pr_agent/ask_images4.png){width=512} 4) post the comment, and receive the answer: -![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} \ No newline at end of file +![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} + + +See a full video tutorial [here](https://codium.ai/images/pr_agent/ask_image_video.mov) \ No newline at end of file From 93d153bae109ea85aca4509bd959701770046b9d Mon Sep 17 00:00:00 2001 From: mrT23 <tal.r@codium.ai> Date: Mon, 15 Apr 2024 10:12:19 +0300 Subject: [PATCH 55/59] ask --- README.md | 2 +- docs/docs/tools/ask.md | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 40453d37..43ce7efc 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ### April 14, 2024 You can now ask questions about images that appear in the comment, where the entire PR is considered as the context. -see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images-using-the-pr-code-as-context) for more details. +see [here](https://pr-agent-docs.codium.ai/tools/ask/#ask-on-images) for more details. <kbd><img src="https://codium.ai/images/pr_agent/ask_images5.png" width="512"></kbd> diff --git a/docs/docs/tools/ask.md b/docs/docs/tools/ask.md index f7678337..0d477934 100644 --- a/docs/docs/tools/ask.md +++ b/docs/docs/tools/ask.md @@ -24,31 +24,33 @@ Note that the tool does not have "memory" of previous questions, and answers eac ## Ask on images -You can also ask questions about images that appear in the comment, where the entire PR is considered as the context. The tool will answer questions based on the images in the PR. +You can also ask questions about images that appear in the comment, where the entire PR code will be used as context. +<br> The basic syntax is: ``` /ask "..." [Image](https://real_link_to_image) ``` +where `https://real_link_to_image` is the direct link to the image. -Note that GitHub has a mecahnism of pasting images in comments. However, pasted image does not provide a direct link. -To get a direct link to the image, we recommend using the following steps: +Note that GitHub has a built-in mechanism of pasting images in comments. However, pasted image does not provide a direct link. +To get a direct link to an image, we recommend using the following scheme: -1) send a comment that contains only the image: +1) First, post a comment that contains **only** the image: ![Ask image1](https://codium.ai/images/pr_agent/ask_images1.png){width=512} -2) quote reply to that comment: +2) Quote reply to that comment: ![Ask image2](https://codium.ai/images/pr_agent/ask_images2.png){width=512} -3) type the question below the image: +3) In the screen opened, type the question below the image: ![Ask image3](https://codium.ai/images/pr_agent/ask_images3.png){width=512} ![Ask image4](https://codium.ai/images/pr_agent/ask_images4.png){width=512} -4) post the comment, and receive the answer: +4) Post the comment, and receive the answer: ![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} From 1481796d6ac475075a26c3c47fbef1a5f6b62b62 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:32:05 +0300 Subject: [PATCH 56/59] Add GitHub repository URL to MkDocs configuration --- docs/mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c045d8e4..5e6940d1 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -1,4 +1,5 @@ site_name: PR-Agent +repo_url: https://github.com/Codium-ai/pr-agent nav: - Overview: 'index.md' From fe231929aefdac34d56c9e1de130cd2964b69686 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:33:22 +0300 Subject: [PATCH 57/59] Update mkdocs.yml to include site description and rename site --- docs/mkdocs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 5e6940d1..9854ca14 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -1,4 +1,5 @@ -site_name: PR-Agent +site_name: PR-Agent Documentation +description: Documentation for PR-Agent, the AI-powered Pull Request tool. repo_url: https://github.com/Codium-ai/pr-agent nav: From d5262f24ca42941e89db29ca79d23e75b4a30f70 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:37:50 +0300 Subject: [PATCH 58/59] add name + github icon --- docs/mkdocs.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 9854ca14..c11965d0 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -1,7 +1,7 @@ site_name: PR-Agent Documentation description: Documentation for PR-Agent, the AI-powered Pull Request tool. repo_url: https://github.com/Codium-ai/pr-agent - +repo_name: Codium-ai/pr-agent nav: - Overview: 'index.md' - Installation: @@ -41,6 +41,8 @@ theme: logo: assets/logo.svg favicon: assets/favicon.ico name: material + icon: + repo: fontawesome/brands/github features: - navigation.tabs - navigation.expand From 32fd03bd556bdbb2ae5f566b640fb4fa853c12c8 Mon Sep 17 00:00:00 2001 From: Almog Lavi <42740235+almog-lv@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:42:36 +0300 Subject: [PATCH 59/59] Add repository URL to MkDocs configuration --- docs/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index c11965d0..66a702ac 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -1,7 +1,7 @@ site_name: PR-Agent Documentation -description: Documentation for PR-Agent, the AI-powered Pull Request tool. repo_url: https://github.com/Codium-ai/pr-agent repo_name: Codium-ai/pr-agent + nav: - Overview: 'index.md' - Installation: