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

Method getModelById

src/api/providers/bedrock.ts:1082–1118  ·  view source on GitHub ↗
(modelId: string, modelType?: string)

Source from the content-addressed store, hash-verified

1080
1081 //Prompt Router responses come back in a different sequence and the model used is in the response and must be fetched by name
1082 getModelById(modelId: string, modelType?: string): { id: BedrockModelId | string; info: ModelInfo } {
1083 // Try to find the model in bedrockModels
1084 const baseModelId = this.parseBaseModelId(modelId) as BedrockModelId
1085
1086 let model
1087 if (baseModelId in bedrockModels) {
1088 //Do a deep copy of the model info so that later in the code the model id and maxTokens can be set.
1089 // The bedrockModels array is a constant and updating the model ID from the returned invokedModelID value
1090 // in a prompt router response isn't possible on the constant.
1091 model = { id: baseModelId, info: JSON.parse(JSON.stringify(bedrockModels[baseModelId])) }
1092 } else if (modelType && modelType.includes("router")) {
1093 model = {
1094 id: bedrockDefaultPromptRouterModelId,
1095 info: JSON.parse(JSON.stringify(bedrockModels[bedrockDefaultPromptRouterModelId])),
1096 }
1097 } else {
1098 // Use heuristics for model info, then allow overrides from ProviderSettings
1099 const guessed = this.guessModelInfoFromId(modelId)
1100 model = {
1101 id: bedrockDefaultModelId,
1102 info: {
1103 ...JSON.parse(JSON.stringify(bedrockModels[bedrockDefaultModelId])),
1104 ...guessed,
1105 },
1106 }
1107 }
1108
1109 // Always allow user to override detected/guessed maxTokens and contextWindow
1110 if (this.options.modelMaxTokens && this.options.modelMaxTokens > 0) {
1111 model.info.maxTokens = this.options.modelMaxTokens
1112 }
1113 if (this.options.awsModelContextWindow && this.options.awsModelContextWindow > 0) {
1114 model.info.contextWindow = this.options.awsModelContextWindow
1115 }
1116
1117 return model
1118 }
1119
1120 override getModel(): {
1121 id: BedrockModelId | string

Callers 2

createMessageMethod · 0.95
getModelMethod · 0.95

Calls 3

parseBaseModelIdMethod · 0.95
guessModelInfoFromIdMethod · 0.95
parseMethod · 0.80

Tested by

no test coverage detected