@@ -69,12 +69,18 @@ const MODELS: Record<string, ModelSpec> = {
|
69 | 69 | "twelvelabs.marengo-embed-3-0-v1:0": { maxTokens: 512, dims: 512, family: "twelvelabs" }, |
70 | 70 | }; |
71 | 71 | |
| 72 | +/** Strip AWS inference profile prefix (us., eu., ap., apac., au., jp., global.) from model ID. */ |
| 73 | +function stripInferenceProfilePrefix(modelId: string): string { |
| 74 | +return modelId.replace(/^(?:us|eu|ap|apac|au|jp|global)\./, ""); |
| 75 | +} |
| 76 | + |
72 | 77 | /** Resolve spec, stripping throughput suffixes like `:2:8k` or `:0:512`. */ |
73 | 78 | function resolveSpec(modelId: string): ModelSpec | undefined { |
74 | | -if (MODELS[modelId]) { |
75 | | -return MODELS[modelId]; |
| 79 | +const bare = stripInferenceProfilePrefix(modelId); |
| 80 | +if (MODELS[bare]) { |
| 81 | +return MODELS[bare]; |
76 | 82 | } |
77 | | -const parts = modelId.split(":"); |
| 83 | +const parts = bare.split(":"); |
78 | 84 | for (let i = parts.length - 1; i >= 1; i--) { |
79 | 85 | const spec = MODELS[parts.slice(0, i).join(":")]; |
80 | 86 | if (spec) { |
@@ -86,7 +92,7 @@ function resolveSpec(modelId: string): ModelSpec | undefined {
|
86 | 92 | |
87 | 93 | /** Infer family from model ID prefix when not in catalog. */ |
88 | 94 | function inferFamily(modelId: string): Family { |
89 | | -const id = normalizeLowercaseStringOrEmpty(modelId); |
| 95 | +const id = normalizeLowercaseStringOrEmpty(stripInferenceProfilePrefix(modelId)); |
90 | 96 | if (id.startsWith("amazon.titan-embed-text-v2")) { |
91 | 97 | return "titan-v2"; |
92 | 98 | } |
@@ -312,6 +318,7 @@ function parseCohereBatch(family: Family, raw: string): number[][] {
|
312 | 318 | export const testing = { |
313 | 319 | parseCohereBatch, |
314 | 320 | parseSingle, |
| 321 | + stripInferenceProfilePrefix, |
315 | 322 | }; |
316 | 323 | |
317 | 324 | // --------------------------------------------------------------------------- |
|