fix(model-capabilities): align gemini aliases and alias lookup
This commit is contained in:
@@ -27,8 +27,8 @@ describe("getModelCapabilities", () => {
|
||||
},
|
||||
toolCall: true,
|
||||
},
|
||||
"gemini-3.1-pro-preview": {
|
||||
id: "gemini-3.1-pro-preview",
|
||||
"gemini-3.1-pro": {
|
||||
id: "gemini-3.1-pro",
|
||||
family: "gemini",
|
||||
reasoning: true,
|
||||
temperature: true,
|
||||
@@ -193,7 +193,7 @@ describe("getModelCapabilities", () => {
|
||||
})
|
||||
|
||||
expect(result).toMatchObject({
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
family: "gemini",
|
||||
supportsThinking: true,
|
||||
supportsTemperature: true,
|
||||
|
||||
@@ -18,12 +18,22 @@ describe("model-capability-aliases", () => {
|
||||
|
||||
expect(result).toEqual({
|
||||
requestedModelID: "gemini-3.1-pro-high",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
source: "exact-alias",
|
||||
ruleID: "gemini-3.1-pro-tier-alias",
|
||||
})
|
||||
})
|
||||
|
||||
test("does not resolve prototype keys as aliases", () => {
|
||||
const result = resolveModelIDAlias("constructor")
|
||||
|
||||
expect(result).toEqual({
|
||||
requestedModelID: "constructor",
|
||||
canonicalModelID: "constructor",
|
||||
source: "canonical",
|
||||
})
|
||||
})
|
||||
|
||||
test("normalizes legacy Claude thinking aliases through a named exact rule", () => {
|
||||
const result = resolveModelIDAlias("claude-opus-4-6-thinking")
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ const EXACT_ALIAS_RULES: ReadonlyArray<ExactAliasRule> = [
|
||||
{
|
||||
aliasModelID: "gemini-3.1-pro-high",
|
||||
ruleID: "gemini-3.1-pro-tier-alias",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
rationale: "OmO historically encoded Gemini tier selection in the model name instead of variant metadata.",
|
||||
},
|
||||
{
|
||||
aliasModelID: "gemini-3.1-pro-low",
|
||||
ruleID: "gemini-3.1-pro-tier-alias",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
rationale: "OmO historically encoded Gemini tier selection in the model name instead of variant metadata.",
|
||||
},
|
||||
{
|
||||
@@ -52,7 +52,7 @@ const EXACT_ALIAS_RULES: ReadonlyArray<ExactAliasRule> = [
|
||||
},
|
||||
]
|
||||
|
||||
const EXACT_ALIAS_RULES_BY_MODEL: Readonly<Record<string, ExactAliasRule>> = Object.fromEntries(
|
||||
const EXACT_ALIAS_RULES_BY_MODEL: ReadonlyMap<string, ExactAliasRule> = new Map(
|
||||
EXACT_ALIAS_RULES.map((rule) => [rule.aliasModelID, rule]),
|
||||
)
|
||||
|
||||
@@ -64,7 +64,7 @@ function normalizeLookupModelID(modelID: string): string {
|
||||
|
||||
export function resolveModelIDAlias(modelID: string): ModelIDAliasResolution {
|
||||
const normalizedModelID = normalizeLookupModelID(modelID)
|
||||
const exactRule = EXACT_ALIAS_RULES_BY_MODEL[normalizedModelID]
|
||||
const exactRule = EXACT_ALIAS_RULES_BY_MODEL.get(normalizedModelID)
|
||||
if (exactRule) {
|
||||
return {
|
||||
requestedModelID: normalizedModelID,
|
||||
|
||||
@@ -29,7 +29,7 @@ describe("model-capability-guardrails", () => {
|
||||
const brokenSnapshot: ModelCapabilitiesSnapshot = {
|
||||
...bundledSnapshot,
|
||||
models: Object.fromEntries(
|
||||
Object.entries(bundledSnapshot.models).filter(([modelID]) => modelID !== "gemini-3.1-pro-preview"),
|
||||
Object.entries(bundledSnapshot.models).filter(([modelID]) => modelID !== "gemini-3.1-pro"),
|
||||
),
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ describe("model-capability-guardrails", () => {
|
||||
expect.objectContaining({
|
||||
kind: "alias-target-missing-from-snapshot",
|
||||
aliasModelID: "gemini-3.1-pro-high",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
}),
|
||||
)
|
||||
})
|
||||
@@ -70,7 +70,7 @@ describe("model-capability-guardrails", () => {
|
||||
expect.objectContaining({
|
||||
kind: "exact-alias-collides-with-snapshot",
|
||||
aliasModelID: "gemini-3.1-pro-high",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
}),
|
||||
)
|
||||
})
|
||||
@@ -84,7 +84,7 @@ describe("model-capability-guardrails", () => {
|
||||
expect.objectContaining({
|
||||
kind: "built-in-model-relies-on-alias",
|
||||
modelID: "gemini-3.1-pro-high",
|
||||
canonicalModelID: "gemini-3.1-pro-preview",
|
||||
canonicalModelID: "gemini-3.1-pro",
|
||||
ruleID: "gemini-3.1-pro-tier-alias",
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user