Roo-Code/src/shared/aws_regions.ts
Smartsheet-JB-Brown 919bb121d0
Jbbrown/bedrock caching (#2071)
* Bedrock prompt caching

* remove whitespace only change to src/api/providers/base-provider.ts

* remove integration test that calls bedrock

* PR prep cleanup

* test file and redundant code cleanup

* updated multi-cache-point

* optimized cache strategy

* cache logic updated. commit before trying to simplify newConversationPlacements

* simplified initial cachePoint logic

* fix the missing caching params for claude 3.7 on bedrock

* undo unintentional changes to README.md files

* fix merge bug that hid use prompt cache checkbox

* prep for PR

* remove unintended changes

* revert .gitignore change

* undo unintended changes

* Issue 1998 - Unable to use ARN. https://github.com/RooVetGit/Roo-Code/issues/1998 - Simplify region extraction from Arns. Change example of ARN use from the foundational model ARN to an inference profile ARN which is what is needed.

* small updates to error message

* more flexible support for ARNs and hardening of ARN handling

* update comment on regex use for platform indipendent cosideration

* small code comment update

* remove duplicative logic to add a region to the arn when cross-region is selected

* Update README files from main branch

* improve error handling when on-demand throughput is not avialable for a foundational model

* fix prompt router bug

* minor tweaks for simplicity

* error messgae formatting

* set new version of bedrock runtime package

* fixes: 2229 - complete prompt doesn't work and appears like a no-op

* remove commented out logger.debug blocks per PR review request

* localize new prompt cache UI inputs

* single source of truth for AWS Region information

---------

Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
2025-04-03 13:05:29 -04:00

78 lines
4.2 KiB
TypeScript

/**
* AWS Region information mapping
* Maps region prefixes to their full region IDs and descriptions
*/
export const AWS_BEDROCK_REGION_INFO: Record<
string,
{
regionId: string
description: string
pattern?: string
multiRegion?: boolean
}
> = {
/*
* This JSON generated by AWS's AI assistant - Amazon Q on March 29, 2025
*
* - Africa (Cape Town) region does not appear to support Amazon Bedrock at this time.
* - Some Asia Pacific regions, such as Asia Pacific (Hong Kong) and Asia Pacific (Jakarta), are not listed among the supported regions for Bedrock services.
* - Middle East regions, including Middle East (Bahrain) and Middle East (UAE), are not mentioned in the list of supported regions for Bedrock. [3]
* - China regions (Beijing and Ningxia) are not listed as supported for Amazon Bedrock.
* - Some newer or specialized AWS regions may not have Bedrock support yet.
*/
"us.": { regionId: "us-east-1", description: "US East (N. Virginia)", pattern: "us-", multiRegion: true },
"use.": { regionId: "us-east-1", description: "US East (N. Virginia)" },
"use1.": { regionId: "us-east-1", description: "US East (N. Virginia)" },
"use2.": { regionId: "us-east-2", description: "US East (Ohio)" },
"usw.": { regionId: "us-west-2", description: "US West (Oregon)" },
"usw2.": { regionId: "us-west-2", description: "US West (Oregon)" },
"ug.": {
regionId: "us-gov-west-1",
description: "AWS GovCloud (US-West)",
pattern: "us-gov-",
multiRegion: true,
},
"uge1.": { regionId: "us-gov-east-1", description: "AWS GovCloud (US-East)" },
"ugw1.": { regionId: "us-gov-west-1", description: "AWS GovCloud (US-West)" },
"eu.": { regionId: "eu-west-1", description: "Europe (Ireland)", pattern: "eu-", multiRegion: true },
"euw1.": { regionId: "eu-west-1", description: "Europe (Ireland)" },
"euw2.": { regionId: "eu-west-2", description: "Europe (London)" },
"euw3.": { regionId: "eu-west-3", description: "Europe (Paris)" },
"euc1.": { regionId: "eu-central-1", description: "Europe (Frankfurt)" },
"eun1.": { regionId: "eu-north-1", description: "Europe (Stockholm)" },
"eus1.": { regionId: "eu-south-1", description: "Europe (Milan)" },
"euz1.": { regionId: "eu-central-2", description: "Europe (Zurich)" },
"ap.": {
regionId: "ap-southeast-1",
description: "Asia Pacific (Singapore)",
pattern: "ap-",
multiRegion: true,
},
"ape1.": { regionId: "ap-east-1", description: "Asia Pacific (Hong Kong)" },
"apne1.": { regionId: "ap-northeast-1", description: "Asia Pacific (Tokyo)" },
"apne2.": { regionId: "ap-northeast-2", description: "Asia Pacific (Seoul)" },
"apne3.": { regionId: "ap-northeast-3", description: "Asia Pacific (Osaka)" },
"aps1.": { regionId: "ap-south-1", description: "Asia Pacific (Mumbai)" },
"apse1.": { regionId: "ap-southeast-1", description: "Asia Pacific (Singapore)" },
"apse2.": { regionId: "ap-southeast-2", description: "Asia Pacific (Sydney)" },
"ca.": { regionId: "ca-central-1", description: "Canada (Central)", pattern: "ca-", multiRegion: true },
"cac1.": { regionId: "ca-central-1", description: "Canada (Central)" },
"sa.": { regionId: "sa-east-1", description: "South America (São Paulo)", pattern: "sa-", multiRegion: true },
"sae1.": { regionId: "sa-east-1", description: "South America (São Paulo)" },
//these are not official - they weren't generated by Amazon Q nor were found in
//the AWS documentation but another roo contributor found apac. was needed so I've
//added the pattern of the other geo zones
"apac.": { regionId: "ap-southeast-1", description: "Default APAC region", pattern: "ap-", multiRegion: true },
"emea.": { regionId: "eu-west-1", description: "Default EMEA region", pattern: "eu-", multiRegion: true },
"amer.": { regionId: "us-east-1", description: "Default Americas region", pattern: "us-", multiRegion: true },
}
// Extract unique region IDs from REGION_INFO and create the AWS_REGIONS array
export const AWS_REGIONS = Object.values(AWS_BEDROCK_REGION_INFO)
// Extract all region IDs
.map((info) => ({ value: info.regionId, label: info.regionId }))
// Filter to unique region IDs (remove duplicates)
.filter((region, index, self) => index === self.findIndex((r) => r.value === region.value))
// Sort alphabetically by region ID
.sort((a, b) => a.value.localeCompare(b.value))