Merge pull request #1239 from unexge/push-qlzvuwsokuvn

chore(ai): clean up Bedrock-specific workarounds from `generate-models.ts`
This commit is contained in:
Mario Zechner 2026-02-04 01:40:42 +01:00 committed by GitHub
commit 1d8450ed6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 47 deletions

View file

@ -193,43 +193,12 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
continue;
}
if (id.startsWith("amazon.titan-text-express") ||
id.startsWith("mistral.mistral-7b-instruct-v0")) {
if (id.startsWith("mistral.mistral-7b-instruct-v0")) {
// These models doesn't support system messages
continue;
}
// Some Amazon Bedrock models require cross-region inference profiles to work.
// To use cross-region inference, we need to add a region prefix to the models.
// See https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html#inference-profiles-support-system
// TODO: Remove Claude models once https://github.com/anomalyco/models.dev/pull/607 is merged, and follow-up with other models.
// Models with global cross-region inference profiles
if (id.startsWith("anthropic.claude-haiku-4-5") ||
id.startsWith("anthropic.claude-sonnet-4") ||
id.startsWith("anthropic.claude-opus-4-5") ||
id.startsWith("amazon.nova-2-lite") ||
id.startsWith("cohere.embed-v4") ||
id.startsWith("twelvelabs.pegasus-1-2")) {
id = "global." + id;
}
// Models with US cross-region inference profiles
if (id.startsWith("amazon.nova-lite") ||
id.startsWith("amazon.nova-micro") ||
id.startsWith("amazon.nova-premier") ||
id.startsWith("amazon.nova-pro") ||
id.startsWith("anthropic.claude-3-7-sonnet") ||
id.startsWith("anthropic.claude-opus-4-1") ||
id.startsWith("anthropic.claude-opus-4-20250514") ||
id.startsWith("deepseek.r1") ||
id.startsWith("meta.llama3-2") ||
id.startsWith("meta.llama3-3") ||
id.startsWith("meta.llama4")) {
id = "us." + id;
}
const bedrockModel = {
models.push({
id,
name: m.name || id,
api: "bedrock-converse-stream" as const,
@ -245,19 +214,7 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
},
contextWindow: m.limit?.context || 4096,
maxTokens: m.limit?.output || 4096,
};
models.push(bedrockModel);
// Add EU cross-region inference variants for Claude models
if (modelId.startsWith("anthropic.claude-haiku-4-5") ||
modelId.startsWith("anthropic.claude-sonnet-4-5") ||
modelId.startsWith("anthropic.claude-opus-4-5")) {
models.push({
...bedrockModel,
id: "eu." + modelId,
name: (m.name || modelId) + " (EU)",
});
}
});
}
}

View file

@ -5,6 +5,57 @@ import type { Model } from "./types.js";
export const MODELS = {
"amazon-bedrock": {
"amazon.nova-lite-v1:0": {
id: "amazon.nova-lite-v1:0",
name: "Nova Lite",
api: "bedrock-converse-stream",
provider: "amazon-bedrock",
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
reasoning: false,
input: ["text", "image"],
cost: {
input: 0.06,
output: 0.24,
cacheRead: 0.015,
cacheWrite: 0,
},
contextWindow: 300000,
maxTokens: 8192,
} satisfies Model<"bedrock-converse-stream">,
"amazon.nova-micro-v1:0": {
id: "amazon.nova-micro-v1:0",
name: "Nova Micro",
api: "bedrock-converse-stream",
provider: "amazon-bedrock",
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
reasoning: false,
input: ["text"],
cost: {
input: 0.035,
output: 0.14,
cacheRead: 0.00875,
cacheWrite: 0,
},
contextWindow: 128000,
maxTokens: 8192,
} satisfies Model<"bedrock-converse-stream">,
"amazon.nova-pro-v1:0": {
id: "amazon.nova-pro-v1:0",
name: "Nova Pro",
api: "bedrock-converse-stream",
provider: "amazon-bedrock",
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",
reasoning: false,
input: ["text", "image"],
cost: {
input: 0.8,
output: 3.2,
cacheRead: 0.2,
cacheWrite: 0,
},
contextWindow: 300000,
maxTokens: 8192,
} satisfies Model<"bedrock-converse-stream">,
"anthropic.claude-3-5-haiku-20241022-v1:0": {
id: "anthropic.claude-3-5-haiku-20241022-v1:0",
name: "Claude Haiku 3.5",
@ -1010,7 +1061,7 @@ export const MODELS = {
} satisfies Model<"bedrock-converse-stream">,
"us.amazon.nova-pro-v1:0": {
id: "us.amazon.nova-pro-v1:0",
name: "Nova Pro",
name: "Nova Pro (US)",
api: "bedrock-converse-stream",
provider: "amazon-bedrock",
baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com",