MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getModel

Method getModel

src/api/providers/bedrock.ts:1120–1229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1118 }
1119
1120 override getModel(): {
1121 id: BedrockModelId | string
1122 info: ModelInfo
1123 maxTokens?: number
1124 temperature?: number
1125 reasoning?: any
1126 reasoningBudget?: number
1127 } {
1128 if (this.costModelConfig?.id?.trim().length > 0) {
1129 // Get model params for cost model config
1130 const params = getModelParams({
1131 format: "anthropic",
1132 modelId: this.costModelConfig.id,
1133 model: this.costModelConfig.info,
1134 settings: this.options,
1135 defaultTemperature: BEDROCK_DEFAULT_TEMPERATURE,
1136 })
1137 return { ...this.costModelConfig, ...params }
1138 }
1139
1140 let modelConfig = undefined
1141
1142 // If custom ARN is provided, use it
1143 if (this.options.awsCustomArn) {
1144 modelConfig = this.getModelById(this.arnInfo.modelId, this.arnInfo.modelType)
1145
1146 //If the user entered an ARN for a foundation-model they've done the same thing as picking from our list of options.
1147 //We leave the model data matching the same as if a drop-down input method was used by not overwriting the model ID with the user input ARN
1148 //Otherwise the ARN is not a foundation-model resource type that ARN should be used as the identifier in Bedrock interactions
1149 if (this.arnInfo.modelType !== "foundation-model") modelConfig.id = this.options.awsCustomArn
1150 } else {
1151 //a model was selected from the drop down
1152 modelConfig = this.getModelById(this.options.apiModelId as string)
1153
1154 // Apply Global Inference prefix if enabled and supported (takes precedence over cross-region)
1155 const baseIdForGlobal = this.parseBaseModelId(modelConfig.id)
1156 if (
1157 this.options.awsUseGlobalInference &&
1158 BEDROCK_GLOBAL_INFERENCE_MODEL_IDS.includes(baseIdForGlobal as any)
1159 ) {
1160 modelConfig.id = `global.${baseIdForGlobal}`
1161 }
1162 // Otherwise, add cross-region inference prefix if enabled
1163 else if (this.options.awsUseCrossRegionInference && this.options.awsRegion) {
1164 const prefix = AwsBedrockHandler.getPrefixForRegion(this.options.awsRegion)
1165 if (prefix) {
1166 modelConfig.id = `${prefix}${modelConfig.id}`
1167 }
1168 }
1169 }
1170
1171 // Check if 1M context is enabled for supported Claude 4 models
1172 // Use parseBaseModelId to handle cross-region inference prefixes
1173 const baseModelId = this.parseBaseModelId(modelConfig.id)
1174 if (BEDROCK_1M_CONTEXT_MODEL_IDS.includes(baseModelId as any) && this.options.awsBedrock1MContext) {
1175 // Update context window and pricing to 1M tier when 1M context beta is enabled
1176 const tier = modelConfig.info.tiers?.[0]
1177 modelConfig.info = {

Callers 4

constructorMethod · 0.95
createMessageMethod · 0.95
completePromptMethod · 0.95
formatErrorMessageMethod · 0.95

Calls 4

getModelByIdMethod · 0.95
parseBaseModelIdMethod · 0.95
getModelParamsFunction · 0.90
getPrefixForRegionMethod · 0.80

Tested by

no test coverage detected