(modelId: string, modelType?: string)
| 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 |
no test coverage detected