Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(bedrock): add profile argument to client #648

Merged
merged 4 commits into from
Sep 9, 2024

Conversation

khalilfiremind
Copy link
Contributor

Add profile option to Bedrock client for profile selection

This update introduces a profile option to the Bedrock client, allowing users to select which profile to use when interacting with the Bedrock client.

In my scenario, I use SSO to access the AWS account. When attempting to run the code locally, it initially failed. By passing the profile_name in the boto3.Session(), the issue was resolved.

@khalilfiremind khalilfiremind requested a review from a team as a code owner August 30, 2024 20:40
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! Just a minor comment on the docs

README.md Outdated
Comment on lines 204 to 226
or if you want to use a profile and region

```py
import os
from anthropic import AnthropicBedrock

PROFILE_NAME = os.getenv("PROFILE_NAME")
REGION_NAME = os.getenv("REGION_NAME")

client = AnthropicBedrock(aws_profile=PROFILE_NAME, aws_region=REGION_NAME)

message = client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Hello!",
}
],
model="anthropic.claude-3-sonnet-20240229-v1:0",
)
print(message)
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think this example is slightly too big, having either a list of supported additional client arguments or a small snippet like this would be best imo:

The bedrock client supports the following arguments for authentication

AnthropicBedrock(
  aws_profile='...',
  aws_region='us-east'
  ... etc
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ✅ @RobertCraigie thank you!

README.md Outdated
AnthropicBedrock(
aws_profile='...',
aws_region='us-east'
... etc
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah sorry I wasn't clear in my comment, I intended for ... etc to be replaced with an exhaustive list of the supported options

Suggested change
... etc
aws_secret_key='...',
aws_access_key='...',
aws_session_token='...',

Copy link
Contributor Author

@khalilfiremind khalilfiremind Sep 4, 2024

Choose a reason for hiding this comment

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

Ahh fine, sorry, i did it @RobertCraigie

Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

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

Thanks!

@RobertCraigie RobertCraigie changed the base branch from main to next September 9, 2024 10:40
@RobertCraigie RobertCraigie changed the title add profile parameter to the AnthropicBedrock class feat(bedrock): add profile argument to client Sep 9, 2024
@RobertCraigie RobertCraigie merged commit 6ea5fce into anthropics:next Sep 9, 2024
4 checks passed
@stainless-app stainless-app bot mentioned this pull request Sep 12, 2024
stainless-app bot pushed a commit that referenced this pull request Oct 4, 2024
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.

None yet

2 participants