|
| 1 | +import { describe, expect, test } from "vitest"; |
| 2 | +import { |
| 3 | + BEDROCK_MODEL_MAX_TOKENS, |
| 4 | + BEDROCK_MODELS, |
| 5 | + INFERENCE_BEDROCK_MODELS, |
| 6 | + INFERENCE_TO_BEDROCK_MAP, |
| 7 | + STREAMING_MODELS, |
| 8 | + TOOL_CALL_MODELS, |
| 9 | +} from "../src/llm/bedrock/index"; |
| 10 | + |
| 11 | +const allBedrockModelValues = Object.values(BEDROCK_MODELS); |
| 12 | +const allInferenceModelValues = Object.values(INFERENCE_BEDROCK_MODELS); |
| 13 | + |
| 14 | +describe("BEDROCK_MODELS", () => { |
| 15 | + test("all model IDs should be unique", () => { |
| 16 | + const seen = new Set<string>(); |
| 17 | + for (const value of allBedrockModelValues) { |
| 18 | + expect(seen.has(value), `Duplicate model ID: ${value}`).toBe(false); |
| 19 | + seen.add(value); |
| 20 | + } |
| 21 | + }); |
| 22 | +}); |
| 23 | + |
| 24 | +describe("INFERENCE_TO_BEDROCK_MAP", () => { |
| 25 | + test("every inference model should map to a valid BEDROCK_MODELS entry", () => { |
| 26 | + for (const [inferenceModel, bedrockModel] of Object.entries( |
| 27 | + INFERENCE_TO_BEDROCK_MAP, |
| 28 | + )) { |
| 29 | + expect( |
| 30 | + allBedrockModelValues.includes(bedrockModel), |
| 31 | + `Inference model ${inferenceModel} maps to ${bedrockModel} which is not in BEDROCK_MODELS`, |
| 32 | + ).toBe(true); |
| 33 | + } |
| 34 | + }); |
| 35 | + |
| 36 | + test("every INFERENCE_BEDROCK_MODELS value should have a mapping", () => { |
| 37 | + const mappedInferenceModels = Object.keys(INFERENCE_TO_BEDROCK_MAP); |
| 38 | + for (const inferenceModel of allInferenceModelValues) { |
| 39 | + expect( |
| 40 | + mappedInferenceModels.includes(inferenceModel), |
| 41 | + `Inference model ${inferenceModel} has no entry in INFERENCE_TO_BEDROCK_MAP`, |
| 42 | + ).toBe(true); |
| 43 | + } |
| 44 | + }); |
| 45 | +}); |
| 46 | + |
| 47 | +describe("STREAMING_MODELS", () => { |
| 48 | + test("all TOOL_CALL_MODELS should also be in STREAMING_MODELS", () => { |
| 49 | + for (const model of TOOL_CALL_MODELS) { |
| 50 | + expect( |
| 51 | + STREAMING_MODELS.has(model), |
| 52 | + `Tool call model ${model} is not in STREAMING_MODELS`, |
| 53 | + ).toBe(true); |
| 54 | + } |
| 55 | + }); |
| 56 | +}); |
| 57 | + |
| 58 | +describe("BEDROCK_MODEL_MAX_TOKENS", () => { |
| 59 | + test("new Claude models should have max tokens entries", () => { |
| 60 | + const expectedModels = [ |
| 61 | + BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6, |
| 62 | + BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6, |
| 63 | + BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_5, |
| 64 | + BEDROCK_MODELS.ANTHROPIC_CLAUDE_4_5_SONNET, |
| 65 | + BEDROCK_MODELS.ANTHROPIC_CLAUDE_HAIKU_4_5, |
| 66 | + ]; |
| 67 | + for (const model of expectedModels) { |
| 68 | + expect( |
| 69 | + BEDROCK_MODEL_MAX_TOKENS[model], |
| 70 | + `Model ${model} should have a max tokens entry`, |
| 71 | + ).toBeDefined(); |
| 72 | + } |
| 73 | + }); |
| 74 | + |
| 75 | + test("new Meta Llama 4 models should have max tokens entries", () => { |
| 76 | + const expectedModels = [ |
| 77 | + BEDROCK_MODELS.META_LLAMA4_SCOUT_17B_INSTRUCT, |
| 78 | + BEDROCK_MODELS.META_LLAMA4_MAVERICK_17B_INSTRUCT, |
| 79 | + ]; |
| 80 | + for (const model of expectedModels) { |
| 81 | + expect( |
| 82 | + BEDROCK_MODEL_MAX_TOKENS[model], |
| 83 | + `Model ${model} should have a max tokens entry`, |
| 84 | + ).toBeDefined(); |
| 85 | + } |
| 86 | + }); |
| 87 | + |
| 88 | + test("Nova 2 Lite should have max tokens entry", () => { |
| 89 | + expect( |
| 90 | + BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.AMAZON_NOVA_2_LITE], |
| 91 | + ).toBeDefined(); |
| 92 | + }); |
| 93 | +}); |
| 94 | + |
| 95 | +describe("Removed models", () => { |
| 96 | + const removedInferenceModels = [ |
| 97 | + "us.anthropic.claude-3-sonnet-20240229-v1:0", |
| 98 | + "us.anthropic.claude-3-opus-20240229-v1:0", |
| 99 | + "us.anthropic.claude-3-5-sonnet-20240620-v1:0", |
| 100 | + "eu.anthropic.claude-3-5-sonnet-20240620-v1:0", |
| 101 | + "eu.anthropic.claude-3-5-haiku-20241022-v1:0", |
| 102 | + "eu.anthropic.claude-opus-4-20250514-v1:0", |
| 103 | + "eu.anthropic.claude-opus-4-1-20250805-v1:0", |
| 104 | + "eu.amazon.nova-premier-v1:0", |
| 105 | + ]; |
| 106 | + |
| 107 | + test("removed cross-region inference models should not be present", () => { |
| 108 | + const inferenceValues: string[] = allInferenceModelValues; |
| 109 | + for (const modelId of removedInferenceModels) { |
| 110 | + expect( |
| 111 | + inferenceValues.includes(modelId), |
| 112 | + `Removed model ${modelId} should not be in INFERENCE_BEDROCK_MODELS`, |
| 113 | + ).toBe(false); |
| 114 | + } |
| 115 | + }); |
| 116 | +}); |
| 117 | + |
| 118 | +describe("Model data values", () => { |
| 119 | + test("Claude Opus 4.6 max tokens should be 128000", () => { |
| 120 | + expect( |
| 121 | + BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6], |
| 122 | + ).toBe(128000); |
| 123 | + }); |
| 124 | + |
| 125 | + test("Claude Sonnet 4.6 max tokens should be 64000", () => { |
| 126 | + expect( |
| 127 | + BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6], |
| 128 | + ).toBe(64000); |
| 129 | + }); |
| 130 | + |
| 131 | + test("Llama 4 Scout max tokens should be 16384", () => { |
| 132 | + expect( |
| 133 | + BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.META_LLAMA4_SCOUT_17B_INSTRUCT], |
| 134 | + ).toBe(16384); |
| 135 | + }); |
| 136 | + |
| 137 | + test("Llama 4 Maverick max tokens should be 16384", () => { |
| 138 | + expect( |
| 139 | + BEDROCK_MODEL_MAX_TOKENS[ |
| 140 | + BEDROCK_MODELS.META_LLAMA4_MAVERICK_17B_INSTRUCT |
| 141 | + ], |
| 142 | + ).toBe(16384); |
| 143 | + }); |
| 144 | + |
| 145 | + test("Nova 2 Lite max tokens should be 65536", () => { |
| 146 | + expect(BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]).toBe( |
| 147 | + 65536, |
| 148 | + ); |
| 149 | + }); |
| 150 | +}); |
0 commit comments