mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
This builds the model catalog from per-provider definitions and models.dev v2 data. It eplacer `generate-models.ts` with one `defineProvider()` file per built-in provider, shared model-family rules (Claude, GPT, DeepSeek, Kimi, Google), and source adapters. models.dev is read through its v2 API. Outputs and CLI flags are unchanged.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { defineProvider, modelsDevModels, withInputLimits } from "../define.ts";
|
|
|
|
// Opus 5 is only callable through cross-region inference profiles.
|
|
const INFERENCE_PROFILE_ONLY_MODEL_IDS = new Set(["anthropic.claude-opus-5"]);
|
|
|
|
function bedrockBaseUrl(modelId: string): string {
|
|
return modelId.startsWith("eu.")
|
|
? "https://bedrock-runtime.eu-central-1.amazonaws.com"
|
|
: "https://bedrock-runtime.us-east-1.amazonaws.com";
|
|
}
|
|
|
|
export default defineProvider({
|
|
id: "amazon-bedrock",
|
|
models: (ctx) =>
|
|
modelsDevModels(ctx, "amazon-bedrock", {
|
|
api: "bedrock-converse-stream",
|
|
baseUrl: "",
|
|
include: (source) =>
|
|
!INFERENCE_PROFILE_ONLY_MODEL_IDS.has(source.id) &&
|
|
// Jamba does not support tool use in streaming mode.
|
|
!source.id.startsWith("ai21.jamba") &&
|
|
// Mistral 7B Instruct does not support system messages.
|
|
!source.id.startsWith("mistral.mistral-7b-instruct-v0"),
|
|
// Includes models.dev pricing tiers, e.g. the long-context tier for OpenAI models (#10326).
|
|
map: (model, source) => ({
|
|
...model,
|
|
baseUrl: bedrockBaseUrl(model.id),
|
|
...(source.structuredOutput ? { compat: { supportsStrictMode: true } } : {}),
|
|
}),
|
|
}),
|
|
finalize: (model) => withInputLimits(model, { images: { maxPerMessage: 20 } }),
|
|
});
|