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(community): Add support for Bedrock cross-region inference models #187

Closed
wants to merge 2 commits into from

Conversation

keremnalbant
Copy link

@keremnalbant keremnalbant commented Sep 8, 2024

Merged for LangChainJS: langchain-ai/langchainjs#6682
Closed PR as the Bedrock is deprecated in langchain-core: langchain-ai/langchain#26038

Hey, I recently I switched using to Bedrock Inference models.

With Inference models, Amazon introduced a new prefix which is a region code. If the modelId previously was anthropic.claude-3-5-sonnet-20240620-v1:0 now, with the change it's eu.anthropic.claude-3-5-sonnet-20240620-v1:0

This PR adds:

  • Support for each AWS Bedrock supported regions.
  • Support streaming for inference models in Converse API

Fixes #186

@keremnalbant
Copy link
Author

Can you please check here, @efriis 👆🏼,

Thanks in advance 🙏🏼

@efriis
Copy link
Member

efriis commented Sep 8, 2024

@3coins if there's another approach for detecting the cross-region strings that would be more tolerant if other regions get added, please comment!

@efriis efriis requested a review from 3coins September 8, 2024 18:48
@3coins
Copy link
Collaborator

3coins commented Sep 10, 2024

@keremnalbant
#184 fixes the support for region prefixes. I noticed that we are missing some regions e.g., il, me, af and us-govin that PR.

@efriis
One solution might be to decide if a prefix is present based on the no of parts. This would break if the provider or the model ended up adding a period in their names (we have not seen this so far). For example:

eu.anthropic.claude-3-5-sonnet-20240620-v1:0 # has 3 parts after splitting
anthropic.claude-3-5-sonnet-20240620-v1:0 # has 2 parts after splitting

@keremnalbant
Copy link
Author

@keremnalbant #184 fixes the support for region prefixes. I noticed that we are missing some regions e.g., il, me, af and us-govin that PR.

@efriis One solution might be to decide if a prefix is present based on the no of parts. This would break if the provider or the model ended up adding a period in their names (we have not seen this so far). For example:

eu.anthropic.claude-3-5-sonnet-20240620-v1:0 # has 3 parts after splitting
anthropic.claude-3-5-sonnet-20240620-v1:0 # has 2 parts after splitting

Yes, but this is not really safe if we are looking for safety as they can pass anything as the first part.

Currently supported regions are just those I've added, please visit the link to view AWS Bedrock Documentation. However this will require extra effort if new regions get supported by AWS. I can add every region in AWS to overcome.

# ref: https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bedrock_region
AWS_REGIONS = [
    "us",
    "ap",
    "ca",
    "eu",
    "sa",
    "us-gov",
]

@keremnalbant
Copy link
Author

@3coins please see the commit which adds all AWS regions.

@rsgrewal-aws
Copy link

@3coins could you please review

@3coins
Copy link
Collaborator

3coins commented Oct 3, 2024

@keremnalbant
Thanks for submitting this change. Can you rebase off main and re-submit.

@3coins
Copy link
Collaborator

3coins commented Oct 21, 2024

Closing this in favor of #242.

@3coins 3coins closed this Oct 21, 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.

Bedrock Inference Model IDs are out of support.
4 participants