Skip to content

Commit 8d30b6f

Browse files
Update src/api/providers/bedrock.ts
agree, sorry old Javascript habits Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
1 parent f767524 commit 8d30b6f

File tree

3 files changed

+46
-263
lines changed

3 files changed

+46
-263
lines changed

src/api/providers/__tests__/bedrock-createMessage.test.ts

Lines changed: 0 additions & 151 deletions
This file was deleted.

src/api/providers/__tests__/bedrock.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)