Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,403 changes: 5,514 additions & 1,889 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"prepublishOnly": "npm run clean && npm run build"
},
"dependencies": {
"@anthropic-ai/bedrock-sdk": "0.26.0",
"@anthropic-ai/sdk": "0.71.2",
"@google/genai": "1.34.0",
"@mistralai/mistralai": "1.10.0",
Expand Down
55 changes: 51 additions & 4 deletions packages/ai/scripts/generate-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ const COPILOT_STATIC_HEADERS = {
"Copilot-Integration-Id": "vscode-chat",
} as const;

function formatNumber(n: number): string {
if (!Number.isFinite(n)) return "0";
if (Object.is(n, -0)) return "0";

// Prevent float artifacts (e.g., 0.44999999999999996) in generated output.
const rounded = Number.isInteger(n) ? n : Number(n.toFixed(6));
return Object.is(rounded, -0) ? "0" : String(rounded);
}

async function fetchOpenRouterModels(): Promise<Model<any>[]> {
try {
console.log("Fetching models from OpenRouter API...");
Expand Down Expand Up @@ -131,6 +140,44 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
}
}

// Process Amazon Bedrock Anthropic models
if (data["amazon-bedrock"]?.models) {
for (const [modelId, model] of Object.entries(data["amazon-bedrock"].models)) {
if (!modelId.startsWith("anthropic.")) continue;

const m = model as ModelsDevModel;
if (m.tool_call !== true) continue;

const baseName = m.name || modelId;
const variants = [
{ id: modelId, nameSuffix: "" },
{ id: `global.${modelId}`, nameSuffix: " (global)" },
{ id: `eu.${modelId}`, nameSuffix: " (eu)" },
];

for (const variant of variants) {
models.push({
id: variant.id,
name: `${baseName}${variant.nameSuffix}`,
api: "anthropic-bedrock",
provider: "amazon-bedrock",
// Template, resolved by the anthropic-bedrock provider based on awsRegion (or AWS_REGION)
baseUrl: "https://bedrock-runtime.{region}.amazonaws.com",
reasoning: m.reasoning === true,
input: m.modalities?.input?.includes("image") ? ["text", "image"] : ["text"],
cost: {
input: m.cost?.input || 0,
output: m.cost?.output || 0,
cacheRead: m.cost?.cache_read || 0,
cacheWrite: m.cost?.cache_write || 0,
},
contextWindow: m.limit?.context || 4096,
maxTokens: m.limit?.output || 4096,
});
}
}
}

// Process Google models
if (data.google?.models) {
for (const [modelId, model] of Object.entries(data.google.models)) {
Expand Down Expand Up @@ -956,10 +1003,10 @@ export const MODELS = {
output += `\t\t\treasoning: ${model.reasoning},\n`;
output += `\t\t\tinput: [${model.input.map(i => `"${i}"`).join(", ")}],\n`;
output += `\t\t\tcost: {\n`;
output += `\t\t\t\tinput: ${model.cost.input},\n`;
output += `\t\t\t\toutput: ${model.cost.output},\n`;
output += `\t\t\t\tcacheRead: ${model.cost.cacheRead},\n`;
output += `\t\t\t\tcacheWrite: ${model.cost.cacheWrite},\n`;
output += `\t\t\t\tinput: ${formatNumber(model.cost.input)},\n`;
output += `\t\t\t\toutput: ${formatNumber(model.cost.output)},\n`;
output += `\t\t\t\tcacheRead: ${formatNumber(model.cost.cacheRead)},\n`;
output += `\t\t\t\tcacheWrite: ${formatNumber(model.cost.cacheWrite)},\n`;
output += `\t\t\t},\n`;
output += `\t\t\tcontextWindow: ${model.contextWindow},\n`;
output += `\t\t\tmaxTokens: ${model.maxTokens},\n`;
Expand Down
1 change: 1 addition & 0 deletions packages/ai/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./models.js";
export * from "./providers/anthropic.js";
export * from "./providers/anthropic-bedrock.js";
export * from "./providers/google.js";
export * from "./providers/google-gemini-cli.js";
export * from "./providers/google-vertex.js";
Expand Down
Loading