Files
pr-agent/Usage.md

491 lines
22 KiB
Markdown
Raw Normal View History

2023-09-29 09:47:13 +03:00
## Usage Guide
2023-07-16 14:59:40 +03:00
2023-09-02 09:43:46 +03:00
### Table of Contents
- [Introduction](#introduction)
2024-01-05 17:05:03 +02:00
- [Local Repo (CLI)](#working-from-a-local-repo-cli)
- [Online Usage](#online-usage)
- [GitHub App](#working-with-github-app)
- [GitHub Action](#working-with-github-action)
- [GitLab Webhook](#working-with-gitlab-webhook)
2024-01-05 17:05:03 +02:00
- [BitBucket App](#working-with-bitbucket-self-hosted-app)
2024-02-18 07:59:53 +02:00
- [Azure DevOps Provider](#azure-devops-provider)
2024-01-05 17:05:03 +02:00
- [Additional Configurations Walkthrough](#appendix---additional-configurations-walkthrough)
2023-09-02 09:43:46 +03:00
2023-09-02 09:19:35 +03:00
### Introduction
2023-10-26 12:10:14 +03:00
After [installation](/INSTALL.md), there are three basic ways to invoke CodiumAI PR-Agent:
2023-09-02 09:19:35 +03:00
1. Locally running a CLI command
2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR
2023-09-02 09:25:38 +03:00
3. Enabling PR-Agent tools to run automatically when a new PR is opened
2023-09-02 09:19:35 +03:00
2023-09-02 09:37:44 +03:00
Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source).
2023-09-02 09:19:35 +03:00
For online usage, you will need to setup either a [GitHub App](INSTALL.md#method-5-run-as-a-github-app), or a [GitHub Action](INSTALL.md#method-3-run-as-a-github-action).
GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened.
#### The configuration file
2023-12-26 16:33:34 +02:00
- The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)**.
2023-09-02 09:37:44 +03:00
In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the [pr_reviewer](/pr_agent/settings/configuration.toml#L16) section in the configuration file.
2023-08-04 12:13:04 +03:00
2023-12-26 16:33:34 +02:00
- The [Tools Guide](./docs/TOOLS_GUIDE.md) provides a detailed description of the different tools and their configurations.
- By uploading a local `.pr_agent.toml` file to the root of the repo's main branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect.
For example, if you set in `.pr_agent.toml`:
```
[pr_reviewer]
extra_instructions="""\
- instruction a
- instruction b
...
"""
```
Then you can give a list of extra instructions to the `review` tool.
#### Global configuration file 💎
2023-12-26 17:15:48 +02:00
If you create a repo called `pr-agent-settings` in your **organization**, it's configuration file `.pr_agent.toml` will be used as a global configuration file for any other repo that belongs to the same organization.
2023-12-26 16:33:34 +02:00
Parameters from a local `.pr_agent.toml` file, in a specific repo, will override the global configuration parameters.
For example, in the GitHub organization `Codium-ai`:
- The repo [`https://github.com/Codium-ai/pr-agent-settings`](https://github.com/Codium-ai/pr-agent-settings/blob/main/.pr_agent.toml) contains a `.pr_agent.toml` file that serves as a global configuration file for all the repos in the GitHub organization `Codium-ai`.
- The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`.
2023-10-01 09:00:58 +03:00
2023-10-06 22:13:03 +11:00
#### Ignoring files from analysis
In some cases, you may want to exclude specific files or directories from the analysis performed by CodiumAI PR-Agent. This can be useful, for example, when you have files that are generated automatically or files that shouldn't be reviewed, like vendored code.
2023-11-23 08:06:07 +02:00
To ignore files or directories, edit the **[ignore.toml](/pr_agent/settings/ignore.toml)** configuration file. This setting also exposes the following environment variables:
2023-10-06 22:13:03 +11:00
- `IGNORE.GLOB`
- `IGNORE.REGEX`
2023-11-23 09:16:50 +02:00
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:
```
[ignore]
glob = ['*.py']
```
2023-10-06 22:13:03 +11:00
2023-10-01 09:00:58 +03:00
#### git provider
2023-09-01 20:27:29 +03:00
The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported:
2023-09-01 20:22:10 +03:00
`
2023-10-01 09:00:58 +03:00
"github", "gitlab", "azure", "codecommit", "local", "gerrit"
2023-09-01 20:22:10 +03:00
`
2023-09-01 19:40:38 +03:00
2023-09-02 09:19:35 +03:00
### Working from a local repo (CLI)
2023-09-02 09:33:33 +03:00
When running from your local repo (CLI), your local configuration file will be used.
2023-11-23 08:06:07 +02:00
Examples of invoking the different tools via the CLI:
2023-09-01 20:22:10 +03:00
2023-09-30 10:51:37 +03:00
- **Review**: `python -m pr_agent.cli --pr_url=<pr_url> review`
- **Describe**: `python -m pr_agent.cli --pr_url=<pr_url> describe`
- **Improve**: `python -m pr_agent.cli --pr_url=<pr_url> improve`
- **Ask**: `python -m pr_agent.cli --pr_url=<pr_url> ask "Write me a poem about this PR"`
- **Reflect**: `python -m pr_agent.cli --pr_url=<pr_url> reflect`
- **Update Changelog**: `python -m pr_agent.cli --pr_url=<pr_url> update_changelog`
2023-09-01 20:22:10 +03:00
`<pr_url>` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50).
**Notes:**
2023-09-02 09:37:44 +03:00
2023-09-02 09:33:33 +03:00
(1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line:
2023-09-02 09:19:35 +03:00
```
2023-09-30 10:51:37 +03:00
python -m pr_agent.cli --pr_url=<pr_url> /review --pr_reviewer.extra_instructions="focus on the file: ..."
2023-09-02 09:19:35 +03:00
```
2023-09-01 20:22:10 +03:00
(2) You can print results locally, without publishing them, by setting in `configuration.toml`:
2023-08-04 12:13:04 +03:00
```
[config]
2024-02-06 07:44:20 +02:00
publish_output=false
2023-08-04 12:13:04 +03:00
verbosity_level=2
```
2023-11-23 08:06:07 +02:00
This is useful for debugging or experimenting with different tools.
2023-08-04 12:13:04 +03:00
2023-07-16 14:59:40 +03:00
2023-09-02 09:19:35 +03:00
### Online usage
Online usage means invoking PR-Agent tools by [comments](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR.
Commands for invoking the different tools via comments:
- **Review**: `/review`
- **Describe**: `/describe`
- **Improve**: `/improve`
2023-09-02 09:33:33 +03:00
- **Ask**: `/ask "..."`
2023-09-02 09:19:35 +03:00
- **Reflect**: `/reflect`
- **Update Changelog**: `/update_changelog`
To edit a specific configuration value, just add `--config_path=<value>` to any command.
2023-11-23 08:06:07 +02:00
For example, if you want to edit the `review` tool configurations, you can run:
2023-09-02 09:19:35 +03:00
```
2023-09-02 09:33:33 +03:00
/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false
2023-09-02 09:19:35 +03:00
```
2023-11-23 08:06:07 +02:00
Any configuration value in [configuration file](pr_agent/settings/configuration.toml) file can be similarly edited. Comment `/config` to see the list of available configurations.
2023-09-02 09:19:35 +03:00
### Working with GitHub App
2023-11-01 18:36:12 +02:00
When running PR-Agent from GitHub App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded.
2023-11-27 16:18:02 +02:00
By uploading a local `.pr_agent.toml` file to the root of the repo's main branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect.
2023-11-01 18:36:12 +02:00
For example, if you set in `.pr_agent.toml`:
```
[pr_reviewer]
num_code_suggestions=1
```
2023-11-23 08:06:07 +02:00
Then you will overwrite the default number of code suggestions to 1.
2023-09-02 09:19:35 +03:00
#### GitHub app automatic tools
The [github_app](pr_agent/settings/configuration.toml#L108) section defines GitHub app specific configurations.
##### GitHub app automatic tools for PR actions
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened.
2023-08-30 19:42:46 +03:00
```
[github_app]
pr_commands = [
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
"/review --pr_reviewer.num_code_suggestions=0",
"/improve",
2023-08-30 19:42:46 +03:00
]
```
This means that when a new PR is opened/reopened or marked as ready for review, PR-Agent will run the `describe`, `review` and `improve` tools.
For the `describe` tool, for example, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
2023-08-30 19:42:46 +03:00
2023-10-01 09:00:58 +03:00
You can override the default tool parameters by uploading a local configuration file called `.pr_agent.toml` to the root of your repo.
2023-08-30 19:42:46 +03:00
For example, if your local `.pr_agent.toml` file contains:
```
[pr_description]
add_original_user_description = false
keep_original_user_title = false
```
2023-09-02 09:19:35 +03:00
When a new PR is opened, PR-Agent will run the `describe` tool with the above parameters.
2023-08-30 19:42:46 +03:00
2023-10-05 17:03:10 +03:00
To cancel the automatic run of all the tools, set:
```
[github_app]
handle_pr_actions = []
2023-10-05 17:03:10 +03:00
```
##### GitHub app automatic tools for push actions (commits to an open PR)
2023-11-01 18:36:12 +02:00
In addition to running automatic tools when a PR is opened, the GitHub app can also respond to new code that is pushed to an open PR.
2023-10-05 17:03:10 +03:00
The configuration toggle `handle_push_trigger` can be used to enable this feature.
The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR.
```
[github_app]
handle_push_trigger = true
push_commands = [
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
2023-12-31 17:34:13 +02:00
"/review -i --pr_reviewer.remove_previous_review_comment=true",
]
```
2023-12-31 17:34:13 +02:00
This means that when new code is pushed to the PR, the PR-Agent will run the `describe` and incremental `review` tools.
For the `describe` tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true.
For the `review` tool, it will run in incremental mode, and the `remove_previous_review_comment` parameter will be set to true.
2023-11-23 08:06:07 +02:00
Much like the configurations for `pr_commands`, you can override the default tool parameters by uploading a local configuration file to the root of your repo.
2023-08-30 19:46:33 +03:00
2023-08-31 08:02:14 +03:00
#### Editing the prompts
2023-08-31 08:06:43 +03:00
The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder.
2023-10-06 22:13:03 +11:00
In practice, the prompts are loaded and stored as a standard setting object.
2023-09-02 09:25:38 +03:00
Hence, editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value.
2023-08-31 08:02:14 +03:00
For example, if you want to edit the prompts of the [describe](./pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file:
```
[pr_description_prompt]
system="""
...
"""
user="""
...
"""
```
2023-08-31 08:08:09 +03:00
Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137).
2023-08-31 08:02:14 +03:00
2024-02-19 14:07:46 +02:00
#### Managing notifications
If you are subscribed to notifications for a repo with PR-Agent, we recommend turning off notifications for PR comments, to avoid lengthy emails:
<kbd><img src="https://codium.ai/images/pr_agent/notifications.png" width="512"></kbd>
2023-09-02 09:19:35 +03:00
### Working with GitHub Action
`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.
2023-10-29 13:07:22 +02:00
Specifically, start by setting the following environment variables:
2023-09-25 18:56:10 +03:00
```yaml
env:
2023-10-29 13:05:15 +02:00
OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make sure to add your GitHub token to your repo secrets
github_action_config.auto_review: "true" # enable\disable auto review
github_action_config.auto_describe: "true" # enable\disable auto describe
2024-01-27 21:38:25 +02:00
github_action_config.auto_improve: "true" # enable\disable auto improve
2023-09-25 18:56:10 +03:00
```
`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.
2024-01-27 21:29:19 +02:00
If not set, the default configuration is for all three tools to run automatically when a new PR is opened.
2023-09-25 18:56:10 +03:00
2023-10-29 13:01:55 +02:00
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.
2023-10-29 13:05:15 +02:00
2023-10-29 13:01:55 +02:00
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:
```
[pr_description]
add_original_user_description = false
```
### Working with 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:
```
[gitlab]
pr_commands = [
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
"/review --pr_reviewer.num_code_suggestions=0",
"/improve",
]
```
2023-10-29 13:01:55 +02:00
2023-12-04 11:11:02 +02:00
### Working with BitBucket Self-Hosted App
Similar to GitHub app, when running PR-Agent from BitBucket App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded.
By uploading a local `.pr_agent.toml` file to the root of the repo's main branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect.
For example, if your local `.pr_agent.toml` file contains:
```
[pr_reviewer]
inline_code_comments = true
```
Each time you invoke a `/review` tool, it will use inline code comments.
2023-10-29 13:01:55 +02:00
#### BitBucket Self-Hosted App automatic tools
You can configure in your local `.pr_agent.toml` file which tools will **run automatically** when a new PR is opened.
Specifically, set the following values:
```yaml
[bitbucket_app]
auto_review = true # set as config var in .pr_agent.toml
auto_describe = true # set as config var in .pr_agent.toml
auto_improve = true # set as config var in .pr_agent.toml
```
`bitbucket_app.auto_review`, `bitbucket_app.auto_describe` and `bitbucket_app.auto_improve` are used to enable/disable automatic tools.
If not set, the default option is that only the `review` tool will run automatically when a new PR is opened.
Note that due to limitations of the bitbucket platform, the `auto_describe` tool will be able to publish a PR description only as a comment.
In addition, some subsections like `PR changes walkthrough` will not appear, since they require the usage of collapsible sections, which are not supported by bitbucket.
2024-02-18 07:59:53 +02:00
### Azure DevOps provider
To use Azure DevOps provider use the following settings in configuration.toml:
```
[config]
git_provider="azure"
use_repo_settings_file=false
```
2024-02-19 08:35:45 -05:00
Azure DevOps provider supports [PAT token](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows) or [DefaultAzureCredential](https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview#authentication-in-server-environments) authentication.
PAT is faster to create, but has build in experation date, and will use the user identity for API calls.
Using DefaultAzureCredential you can use managed identity or Service principle, which are more secure and will create seperate ADO user identity (via AAD) to the agent.
If PAT was choosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was choosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local develpment) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml:
2024-02-18 07:59:53 +02:00
```
[azure_devops]
org = "https://dev.azure.com/YOUR_ORGANIZATION/"
2024-02-19 08:35:45 -05:00
# pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication
2024-02-18 07:59:53 +02:00
```
##### Azure DevOps Webhook
To trigger from an Azure webhook, you need to manually [add a webhook](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops).
Use the "Pull request created" type to trigger a review, or "Pull request commented on" to trigger any supported comment with /<command> <args> comment on the relevant PR. Note that for the "Pull request commented on" trigger, only API v2.0 is supported.
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:
```
[azure_devops_server]
pr_commands = [
"/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true",
"/review --pr_reviewer.num_code_suggestions=0",
"/improve",
]
```
For webhook security, create a sporadic username/password pair and configure the webhook username and password on both the server and Azure DevOps webhook. These will be sent as basic Auth data by the webhook with each request:
```
[azure_devops_server]
webhook_username = "<basic auth user>"
webhook_password = "<basic auth password>"
```
> :warning: **Ensure that the webhook endpoint is only accessible over HTTPS** to mitigate the risk of credential interception when using basic authentication.
2023-12-26 16:33:34 +02:00
### Appendix - additional configurations walkthrough
#### Extra instructions
All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage:
```
/update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..."
```
#### 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.
When the PR is above the token limit, it employs a [PR Compression strategy](./PR_COMPRESSION.md).
However, for very large PRs, or in case you want to emphasize quality over speed and cost, there are 2 possible solutions:
1) [Use a model](#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](./docs/IMPROVE.md) (`/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)
#### Changing a model
2023-08-30 19:42:46 +03:00
2023-08-07 09:04:52 +03:00
See [here](pr_agent/algo/__init__.py) for the list of available models.
2023-10-01 09:00:58 +03:00
To use a different model than the default (GPT-4), you need to edit [configuration file](pr_agent/settings/configuration.toml#L2).
2023-09-30 10:51:37 +03:00
For models and environments not from OPENAI, you might need to provide additional keys and other parameters. See below for instructions.
2023-08-07 09:04:52 +03:00
2023-12-26 16:33:34 +02:00
##### Azure
To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action):
2023-09-05 15:19:56 -07:00
```
api_key = "" # your azure api key
api_type = "azure"
api_version = '2023-05-15' # Check Azure documentation for the current API version
api_base = "" # The base URL for your Azure OpenAI resource. e.g. "https://<your resource name>.openai.azure.com"
2023-10-10 17:23:58 +03:00
openai.deployment_id = "" # The deployment name you chose when you deployed the engine
2023-09-05 15:19:56 -07:00
```
and set in your configuration file:
2023-08-07 09:04:52 +03:00
```
[config]
2023-09-05 15:19:56 -07:00
model="" # the OpenAI model you've deployed on Azure (e.g. gpt-3.5-turbo)
```
2023-12-26 16:33:34 +02:00
##### Huggingface
2023-09-05 16:23:22 -07:00
2023-10-06 22:13:03 +11:00
**Local**
You can run Huggingface models locally through either [VLLM](https://docs.litellm.ai/docs/providers/vllm) or [Ollama](https://docs.litellm.ai/docs/providers/ollama)
E.g. to use a new Huggingface model locally via Ollama, set:
```
[__init__.py]
MAX_TOKENS = {
"model-name-on-ollama": <max_tokens>
}
e.g.
MAX_TOKENS={
...,
"ollama/llama2": 4096
}
[config] # in configuration.toml
model = "ollama/llama2"
[ollama] # in .secrets.toml
2023-10-06 22:13:03 +11:00
api_base = ... # the base url for your huggingface inference endpoint
# e.g. if running Ollama locally, you may use:
api_base = "http://localhost:11434/"
```
**Inference Endpoints**
2023-09-05 16:23:22 -07:00
To use a new model with Huggingface Inference Endpoints, for example, set:
```
[__init__.py]
MAX_TOKENS = {
"model-name-on-huggingface": <max_tokens>
}
e.g.
MAX_TOKENS={
...,
"meta-llama/Llama-2-7b-chat-hf": 4096
}
[config] # in configuration.toml
model = "huggingface/meta-llama/Llama-2-7b-chat-hf"
[huggingface] # in .secrets.toml
key = ... # your huggingface api key
2023-10-06 22:13:03 +11:00
api_base = ... # the base url for your huggingface inference endpoint
2023-09-05 16:23:22 -07:00
```
(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api))
2023-12-26 16:33:34 +02:00
##### Replicate
2023-09-05 16:23:22 -07:00
2023-09-05 15:19:56 -07:00
To use Llama2 model with Replicate, for example, set:
```
[config] # in configuration.toml
2023-08-07 09:04:52 +03:00
model = "replicate/llama-2-70b-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1"
2023-09-05 15:19:56 -07:00
[replicate] # in .secrets.toml
2023-08-07 09:04:52 +03:00
key = ...
```
(you can obtain a Llama2 key from [here](https://replicate.com/replicate/llama-2-70b-chat/api))
2023-09-05 16:23:22 -07:00
2023-08-07 09:04:52 +03:00
Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models.
2023-12-26 16:33:34 +02:00
##### Vertex AI
2023-11-15 10:24:56 +00:00
To use Google's Vertex AI platform and its associated models (chat-bison/codechat-bison) set:
```
[config] # in configuration.toml
model = "vertex_ai/codechat-bison"
2023-11-17 10:41:52 +02:00
fallback_models="vertex_ai/codechat-bison"
2023-11-15 10:24:56 +00:00
[vertexai] # in .secrets.toml
vertex_project = "my-google-cloud-project"
vertex_location = ""
```
Your [application default credentials](https://cloud.google.com/docs/authentication/application-default-credentials) will be used for authentication so there is no need to set explicit credentials in most environments.
If you do want to set explicit credentials then you can use the `GOOGLE_APPLICATION_CREDENTIALS` environment variable set to a path to a json credentials file.
2023-12-26 16:33:34 +02:00
##### Amazon Bedrock
2023-11-28 20:11:40 +09:00
To use Amazon Bedrock and its foundational models, add the below configuration:
```
[config] # in configuration.toml
model = "anthropic.claude-v2"
fallback_models="anthropic.claude-instant-v1"
[aws] # in .secrets.toml
bedrock_region = "us-east-1"
```
Note that you have to add access to foundational models before using them. Please refer to [this document](https://docs.aws.amazon.com/bedrock/latest/userguide/setting-up.html) for more details.
AWS session is automatically authenticated from your environment, but you can also explicitly set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables.
2023-08-31 11:47:51 +00:00
2023-10-05 08:38:43 +03:00
#### Patch Extra Lines
By default, around any change in your PR, git patch provides 3 lines of context above and below the change.
2023-10-05 08:46:02 +03:00
```
@@ -12,5 +12,5 @@ def func1():
code line that already existed in the file...
code line that already existed in the file...
code line that already existed in the file....
-code line that was removed in the PR
+new code line added in the PR
code line that already existed in the file...
code line that already existed in the file...
code line that already existed in the file...
```
2023-10-05 08:38:43 +03:00
For the `review`, `describe`, `ask` and `add_docs` tools, if the token budget allows, PR-Agent tries to increase the number of lines of context, via the parameter:
```
[config]
patch_extra_lines=3
```
2023-10-05 08:46:02 +03:00
2023-10-05 08:38:43 +03:00
Increasing this number provides more context to the model, but will also increase the token budget.
2024-02-19 08:35:45 -05:00
If the PR is too large (see [PR Compression strategy](./PR_COMPRESSION.md)), PR-Agent automatically sets this number to 0, using the original git patch.