@@ -326,11 +326,37 @@ describe("AwsBedrockHandler", () => {
326326 } )
327327 const modelInfo = customArnHandler . getModel ( )
328328 expect ( modelInfo . id ) . toBe ( "arn:aws:bedrock:us-east-1::foundation-model/custom-model" )
329- expect ( modelInfo . info . maxTokens ) . toBe ( 8192 )
329+ expect ( modelInfo . info . maxTokens ) . toBe ( 4096 )
330330 expect ( modelInfo . info . contextWindow ) . toBe ( 200_000 )
331331 expect ( modelInfo . info . supportsPromptCache ) . toBe ( false )
332332 } )
333333
334+ it ( "should correctly identify model info from inference profile ARN" , ( ) => {
335+ //this test intentionally uses a model that has different maxTokens, contextWindow and other values than the fall back option in the code
336+ const customArnHandler = new AwsBedrockHandler ( {
337+ apiModelId : "meta.llama3-8b-instruct-v1:0" , // This will be ignored when awsCustomArn is provided
338+ awsAccessKey : "test-access-key" ,
339+ awsSecretKey : "test-secret-key" ,
340+ awsRegion : "us-west-2" ,
341+ awsCustomArn :
342+ "arn:aws:bedrock:us-west-2:699475926481:inference-profile/us.meta.llama3-8b-instruct-v1:0" ,
343+ } )
344+ const modelInfo = customArnHandler . getModel ( )
345+
346+ // Verify the ARN is used as the model ID
347+ expect ( modelInfo . id ) . toBe (
348+ "arn:aws:bedrock:us-west-2:699475926481:inference-profile/us.meta.llama3-8b-instruct-v1:0" ,
349+ )
350+
351+ //
352+ expect ( modelInfo . info . maxTokens ) . toBe ( 2048 )
353+ expect ( modelInfo . info . contextWindow ) . toBe ( 4_000 )
354+ expect ( modelInfo . info . supportsImages ) . toBe ( false )
355+ expect ( modelInfo . info . supportsPromptCache ) . toBe ( false )
356+
357+ // This test highlights that the regex in getModel needs to be updated to handle inference-profile ARNs
358+ } )
359+
334360 it ( "should use default model when custom-arn is selected but no ARN is provided" , ( ) => {
335361 const customArnHandler = new AwsBedrockHandler ( {
336362 apiModelId : "custom-arn" ,
0 commit comments