-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: update AWS Bedrock cross-region inference profile mapping, Closed issue #2704 #4973
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
base: main
Are you sure you want to change the base?
feat: update AWS Bedrock cross-region inference profile mapping, Closed issue #2704 #4973
Conversation
- Add AWS_INFERENCE_PROFILE_MAPPING with official inference profile prefixes - Update getPrefixForRegion to use AWS recommended inference profiles - Improve region-to-profile mapping based on AWS documentation - Prioritize more specific region patterns (e.g., us-gov- before us-) - Add support for apac., ca., sa., and ug. inference profiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @KevinZhao, thank you for your PR!
This looks like a solid implementation, I left some suggestions to hopefully get this ready and merged.
Let me know what you think!
return prefix | ||
// Use AWS recommended inference profile prefixes | ||
// Sort by prefix length (descending) to ensure more specific prefixes match first (e.g., us-gov- before us-) | ||
const sortedMappings = Object.entries(AWS_INFERENCE_PROFILE_MAPPING).sort(([a], [b]) => b.length - a.length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a comment explaining this? It would help future maintainers understand why the sorting is necessary:
// Sort by prefix length (descending) to ensure more specific prefixes match first
// This prevents "us-" from matching "us-gov-" regions, for example
const sortedMappings = Object.entries(AWS_INFERENCE_PROFILE_MAPPING).sort(([a], [b]) => b.length - a.length)
// Europe regions → eu. inference profile | ||
"eu-": "eu.", | ||
// Asia Pacific regions → apac. inference profile (updated per AWS documentation) | ||
"ap-": "apac.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice the comment mentions "apac." as the updated prefix per AWS documentation, which is great. However, the existing BEDROCK_REGION_INFO
object below (lines 422-427) still contains the old "ap." prefix entry. Is this intentional for backward compatibility? If so, it might be worth adding a note to clarify the relationship between the old and new prefixes.
@@ -978,11 +977,16 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH | |||
} | |||
|
|||
private static getPrefixForRegion(region: string): string | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be helpful to add test coverage for this new getPrefixForRegion
method? I noticed there are existing tests for cross-region inference in bedrock-custom-arn.spec.ts
, but they don't specifically test the new mapping logic. Some test cases to consider:
- Testing that
ap-northeast-1
returns"apac."
- Testing that
us-gov-west-1
returns"ug."
(not"us."
) - Testing that an unknown region pattern returns
undefined
This would help ensure the mapping works correctly and prevent regressions.
Related GitHub Issue
Closes: # <2704>
#2704
Description
Test Procedure
Type of Change
src
or test files.Pre-Submission Checklist
npm run lint
).console.log
) has been removed.npm test
).main
branch.npm run changeset
if this PR includes user-facing changes or dependency updates.Screenshots / Videos
Documentation Updates
Additional Notes
Get in Touch
Important
Updates AWS Bedrock cross-region inference profile mapping to use AWS's recommended inference profiles, addressing issue #2704.
getPrefixForRegion()
inbedrock.ts
to use AWS recommended inference profiles for cross-region inference.AWS_INFERENCE_PROFILE_MAPPING
inbedrock.ts
for mapping regions to inference profiles.AwsBedrockHandler
inbedrock.ts
to apply cross-region inference prefixes usingAWS_INFERENCE_PROFILE_MAPPING
.This description was created by
for 5be82b9. You can customize this summary. It will automatically update as commits are pushed.