Skip to content

Add Amazon Bedrock support#483

Merged
mrT23 merged 5 commits into
The-PR-Agent:mainfrom
tmokmss:add-bedrock-support
Nov 29, 2023
Merged

Add Amazon Bedrock support#483
mrT23 merged 5 commits into
The-PR-Agent:mainfrom
tmokmss:add-bedrock-support

Conversation

@tmokmss
Copy link
Copy Markdown
Contributor

@tmokmss tmokmss commented Nov 28, 2023

closes #459

Added support for Anthropic Claude on Amazon Bedrock. I'll add some explanation in the review comments.

"VERTEXAI.VERTEX_LOCATION", None
)
if get_settings().get("AWS.BEDROCK_REGION", None):
litellm.AmazonAnthropicConfig.max_tokens_to_sample = 2000
Copy link
Copy Markdown
Contributor Author

@tmokmss tmokmss Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this because max_tokens_to_sample in litellm is 256 by default and that will stop the completion in the middle of a review. We can allow users to set this parameter from a config file but I think hardcoding this large value is usually enough for many users.

}
if self.aws_bedrock_client:
kwargs["aws_bedrock_client"] = self.aws_bedrock_client
response = await acompletion(**kwargs)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding aws_bedrock_client kwarg when calling other providers like openai will fail due to the below error, so I only add this arg when using bedrock.

openai.error.InvalidRequestError: Unrecognized request argument supplied: aws_bedrock_client

Comment thread pr_agent/algo/utils.py Outdated

def load_yaml(response_text: str) -> dict:
response_text = response_text.removeprefix('```yaml').rstrip('`')
response_text = response_text.strip().rstrip().removeprefix('{').removesuffix('}')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude tends to add a leading { and a trailing } in the generated yaml, so I'm removing these characters here. try_fix_yaml didn't work for some reason.

Copy link
Copy Markdown
Contributor

@mrT23 mrT23 Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is problematic.

what if the message actually starts with '{' ?
Its not something that should come in any way with a yaml, so removing it just like that is risky

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this line, as a seperate fallback, to 'try_fix_yaml' section.

but this is not good for claude in terms of claude-vs-openai comparison :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks. I moved them to try_fix_yaml. Yea I think I'll have to optimize prompts for Claude :)

Comment thread requirements.txt
starlette-context==0.3.6
litellm==0.12.5
boto3==1.28.25
boto3==1.33.1
Copy link
Copy Markdown
Contributor Author

@tmokmss tmokmss Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

litellm requires boto3>=1.28.57, so I updated boto3 to the latest version. I don't see any breaking changes between 1.28.25 and 1.33.1 (doc).

Comment thread pr_agent/algo/__init__.py
'codechat-bison-32k': 32000,
'anthropic.claude-v2': 100000,
'anthropic.claude-instant-v1': 100000,
'anthropic.claude-v1': 100000,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add support only for Claude for now because it's difficult to tune more parameters like max_tokens_to_sample specific for each model.

@mrT23
Copy link
Copy Markdown
Contributor

mrT23 commented Nov 29, 2023

thanks @tmokmss

@mrT23 mrT23 merged commit b90dde4 into The-PR-Agent:main Nov 29, 2023
@tmokmss tmokmss deleted the add-bedrock-support branch November 29, 2023 12:02
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
spartan-ducduong added a commit to spartan-stratos/pr-agent that referenced this pull request May 27, 2026
…false positives

Two new clauses in REVIEW_STYLE, both motivated by service-fleet PR scans:

1. Refactor-removal guard. PR The-PR-Agent#481 false-positives flagged "complete-onboarding
   no longer creates the user" — but the user creation moved to promote-driver.
   Reviewer must now search the diff for the new owner of any removed behavior
   before flagging a regression.

2. Module-placement citation requirement. PR The-PR-Agent#481 entity-leak false positive
   inferred module-impl placement from "Entity" name semantics. Reviewer must
   now cite the project's actual SCHEMA.md (or equivalent) before claiming a
   module-boundary violation.

Companion pattern files (~/.claude-library/rules/patterns/, not in this repo):
  - backend-micronaut/manager-vs-repository-injection.md (PR The-PR-Agent#471 lesson)
  - backend-micronaut/webhook-tolerant-vs-api-strict.md  (PR The-PR-Agent#483 lesson)
  - backend-micronaut/mock-vendor-exceptions.md          (extend for dev-sim, PR The-PR-Agent#482)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Amazon Bedrock support

2 participants