Skip to content

Commit 7cb080a

Browse files
committed
fix(bedrock): add missing regional inference profile prefixes for Japan and Australia
- Add jp. prefix for ap-northeast- regions (Tokyo/Osaka) - Add au. prefix for ap-southeast-2 region (Sydney) - Reorder mappings by pattern length descending for correct matching - Update tests to reflect new regional mappings - Allow numbers in region pattern validation regex Addresses feedback from XL-Lewis per AWS documentation: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
1 parent 4493873 commit 7cb080a

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

packages/types/src/providers/bedrock.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,21 @@ export const BEDROCK_DEFAULT_CONTEXT = 128_000
401401
// https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
402402
// This mapping is pre-ordered by pattern length (descending) to ensure more specific patterns match first
403403
export const AWS_INFERENCE_PROFILE_MAPPING: Array<[string, string]> = [
404-
// US Government Cloud → ug. inference profile (most specific prefix first)
404+
// Australia region (Sydney) → au. inference profile (most specific - 14 chars)
405+
["ap-southeast-2", "au."],
406+
// Japan regions (Tokyo and Osaka) → jp. inference profile (13 chars)
407+
["ap-northeast-", "jp."],
408+
// US Government Cloud → ug. inference profile (7 chars)
405409
["us-gov-", "ug."],
406-
// Americas regions → us. inference profile
410+
// Americas regions → us. inference profile (3 chars)
407411
["us-", "us."],
408-
// Europe regions → eu. inference profile
412+
// Europe regions → eu. inference profile (3 chars)
409413
["eu-", "eu."],
410-
// Asia Pacific regions → apac. inference profile
414+
// Asia Pacific regions → apac. inference profile (3 chars)
411415
["ap-", "apac."],
412-
// Canada regions → ca. inference profile
416+
// Canada regions → ca. inference profile (3 chars)
413417
["ca-", "ca."],
414-
// South America regions → sa. inference profile
418+
// South America regions → sa. inference profile (3 chars)
415419
["sa-", "sa."],
416420
]
417421

src/api/providers/__tests__/bedrock-inference-profiles.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ describe("Amazon Bedrock Inference Profiles", () => {
3030
describe("AWS_INFERENCE_PROFILE_MAPPING constant", () => {
3131
it("should contain all expected region mappings", () => {
3232
expect(AWS_INFERENCE_PROFILE_MAPPING).toEqual([
33+
["ap-southeast-2", "au."],
34+
["ap-northeast-", "jp."],
3335
["us-gov-", "ug."],
3436
["us-", "us."],
3537
["eu-", "eu."],
@@ -47,7 +49,7 @@ describe("Amazon Bedrock Inference Profiles", () => {
4749

4850
it("should have valid inference profile prefixes", () => {
4951
AWS_INFERENCE_PROFILE_MAPPING.forEach(([regionPattern, inferenceProfile]) => {
50-
expect(regionPattern).toMatch(/^[a-z-]+$/)
52+
expect(regionPattern).toMatch(/^[a-z0-9-]+$/)
5153
expect(inferenceProfile).toMatch(/^[a-z]+\.$/)
5254
})
5355
})
@@ -77,8 +79,13 @@ describe("Amazon Bedrock Inference Profiles", () => {
7779

7880
it("should return correct prefix for Asia Pacific regions", () => {
7981
const handler = createHandler()
82+
// Australia (Sydney) gets au. prefix
83+
expect((handler as any).constructor.getPrefixForRegion("ap-southeast-2")).toBe("au.")
84+
// Japan regions (Tokyo and Osaka) get jp. prefix
85+
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-1")).toBe("jp.")
86+
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-3")).toBe("jp.")
87+
// Other APAC regions get apac. prefix
8088
expect((handler as any).constructor.getPrefixForRegion("ap-southeast-1")).toBe("apac.")
81-
expect((handler as any).constructor.getPrefixForRegion("ap-northeast-1")).toBe("apac.")
8289
expect((handler as any).constructor.getPrefixForRegion("ap-south-1")).toBe("apac.")
8390
expect((handler as any).constructor.getPrefixForRegion("ap-east-1")).toBe("apac.")
8491
})

src/api/providers/__tests__/bedrock.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,13 @@ describe("AwsBedrockHandler", () => {
114114
it("should return correct prefix for APAC regions", () => {
115115
const getPrefixForRegion = (AwsBedrockHandler as any).getPrefixForRegion
116116

117+
// Australia (Sydney) gets au. prefix
118+
expect(getPrefixForRegion("ap-southeast-2")).toBe("au.")
119+
// Japan regions (Tokyo and Osaka) get jp. prefix
120+
expect(getPrefixForRegion("ap-northeast-1")).toBe("jp.")
121+
expect(getPrefixForRegion("ap-northeast-3")).toBe("jp.")
122+
// Other APAC regions get apac. prefix
117123
expect(getPrefixForRegion("ap-southeast-1")).toBe("apac.")
118-
expect(getPrefixForRegion("ap-northeast-1")).toBe("apac.")
119124
expect(getPrefixForRegion("ap-south-1")).toBe("apac.")
120125
})
121126

0 commit comments

Comments
 (0)