mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: add 1M context window checkbox for Claude 3.5 Sonnet v2 in Bedrock provider
- Added BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID constant for the newer model - Updated Bedrock.tsx UI component to show 1M context checkbox for both Sonnet models - Updated bedrock.ts provider to handle 1M context for both models - Updated useSelectedModel hook to apply 1M context for both models Fixes #8381
This commit is contained in:
parent
f3b3751b48
commit
5d5182b5ce
5 changed files with 22 additions and 6 deletions
1
.tmp/Roo-Code
Submodule
1
.tmp/Roo-Code
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 86debeef43acbea9bdc1aa4b38d514541e164c91
|
||||
|
|
@ -458,3 +458,4 @@ export const BEDROCK_REGIONS = [
|
|||
].sort((a, b) => a.value.localeCompare(b.value))
|
||||
|
||||
export const BEDROCK_CLAUDE_SONNET_4_MODEL_ID = "anthropic.claude-sonnet-4-20250514-v1:0"
|
||||
export const BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID = "anthropic.claude-sonnet-4-5-20250929-v1:0"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
BEDROCK_DEFAULT_CONTEXT,
|
||||
AWS_INFERENCE_PROFILE_MAPPING,
|
||||
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
|
||||
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
|
||||
} from "@roo-code/types"
|
||||
|
||||
import { ApiStream } from "../transform/stream"
|
||||
|
|
@ -381,7 +382,9 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
// Check if 1M context is enabled for Claude Sonnet 4
|
||||
// Use parseBaseModelId to handle cross-region inference prefixes
|
||||
const baseModelId = this.parseBaseModelId(modelConfig.id)
|
||||
const is1MContextEnabled = baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext
|
||||
const is1MContextEnabled =
|
||||
(baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || baseModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
|
||||
this.options.awsBedrock1MContext
|
||||
|
||||
// Add anthropic_beta for 1M context to additionalModelRequestFields
|
||||
if (is1MContextEnabled) {
|
||||
|
|
@ -979,7 +982,10 @@ export class AwsBedrockHandler extends BaseProvider implements SingleCompletionH
|
|||
// Check if 1M context is enabled for Claude Sonnet 4
|
||||
// Use parseBaseModelId to handle cross-region inference prefixes
|
||||
const baseModelId = this.parseBaseModelId(modelConfig.id)
|
||||
if (baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && this.options.awsBedrock1MContext) {
|
||||
if (
|
||||
(baseModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || baseModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
|
||||
this.options.awsBedrock1MContext
|
||||
) {
|
||||
// Update context window to 1M tokens when 1M context beta is enabled
|
||||
modelConfig.info = {
|
||||
...modelConfig.info,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
type ModelInfo,
|
||||
BEDROCK_REGIONS,
|
||||
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
|
||||
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
|
||||
} from "@roo-code/types"
|
||||
|
||||
import { useAppTranslation } from "@src/i18n/TranslationContext"
|
||||
|
|
@ -24,8 +25,10 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
|
|||
const { t } = useAppTranslation()
|
||||
const [awsEndpointSelected, setAwsEndpointSelected] = useState(!!apiConfiguration?.awsBedrockEndpointEnabled)
|
||||
|
||||
// Check if the selected model supports 1M context (Claude Sonnet 4)
|
||||
const supports1MContextBeta = apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID
|
||||
// Check if the selected model supports 1M context (Claude Sonnet 4 or 4.5)
|
||||
const supports1MContextBeta =
|
||||
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_MODEL_ID ||
|
||||
apiConfiguration?.apiModelId === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID
|
||||
|
||||
// Update the endpoint enabled state when the configuration changes
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import {
|
|||
qwenCodeModels,
|
||||
vercelAiGatewayDefaultModelId,
|
||||
BEDROCK_CLAUDE_SONNET_4_MODEL_ID,
|
||||
BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID,
|
||||
deepInfraDefaultModelId,
|
||||
} from "@roo-code/types"
|
||||
|
||||
|
|
@ -200,8 +201,12 @@ function getSelectedModel({
|
|||
}
|
||||
}
|
||||
|
||||
// Apply 1M context for Claude Sonnet 4 when enabled
|
||||
if (id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID && apiConfiguration.awsBedrock1MContext && baseInfo) {
|
||||
// Apply 1M context for Claude Sonnet 4 or 4.5 when enabled
|
||||
if (
|
||||
(id === BEDROCK_CLAUDE_SONNET_4_MODEL_ID || id === BEDROCK_CLAUDE_SONNET_4_5_MODEL_ID) &&
|
||||
apiConfiguration.awsBedrock1MContext &&
|
||||
baseInfo
|
||||
) {
|
||||
// Create a new ModelInfo object with updated context window
|
||||
const info: ModelInfo = {
|
||||
...baseInfo,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue