Skip to content

Commit 82d433c

Browse files
committed
fix(app): derive reasoning from variants and reasoningField when the catalog is silent
Custom providers and models absent from models.dev have no catalog reasoning flag, so the tooltip still said "No reasoning" for them. Fall back to signals the server already sends — a non-empty variants list or compatibility.reasoningField — while an explicit catalog value still wins. Coverage per the 83-model inventory in anomalyco#50257 (40 variants-only, 24 reasoningField-only, 19 both, 0 neither): the OR of the two signals labels all of them, with no false positives. Tests cover the variants fallback, the reasoningField fallback, and explicit catalog false taking precedence.
1 parent 9fbcd3c commit 82d433c

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

‎packages/app/src/runtime/server/global-sync/utils.test.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,46 @@ describe("normalizeProviderList", () => {
8282
enabled: true,
8383
limit: { context: 1, output: 1 },
8484
},
85+
{
86+
id: "gpt-variants-only",
87+
modelID: "gpt-variants-only",
88+
providerID: "openai",
89+
name: "GPT Variants Only",
90+
capabilities: { tools: true, input: ["text"], output: ["text"] },
91+
variants: [{ id: "high" }],
92+
time: { released: 0 },
93+
cost: [],
94+
status: "active",
95+
enabled: true,
96+
limit: { context: 1, output: 1 },
97+
},
98+
{
99+
id: "gpt-field-only",
100+
modelID: "gpt-field-only",
101+
providerID: "openai",
102+
name: "GPT Field Only",
103+
compatibility: { reasoningField: "reasoning_content" },
104+
capabilities: { tools: true, input: ["text"], output: ["text"] },
105+
variants: [],
106+
time: { released: 0 },
107+
cost: [],
108+
status: "active",
109+
enabled: true,
110+
limit: { context: 1, output: 1 },
111+
},
112+
{
113+
id: "gpt-off-with-variants",
114+
modelID: "gpt-off-with-variants",
115+
providerID: "openai",
116+
name: "GPT Off With Variants",
117+
capabilities: { tools: true, reasoning: false, input: ["text"], output: ["text"] },
118+
variants: [{ id: "high" }],
119+
time: { released: 0 },
120+
cost: [],
121+
status: "active",
122+
enabled: true,
123+
limit: { context: 1, output: 1 },
124+
},
85125
] as ModelListOutput["data"],
86126
)
87127

@@ -97,6 +137,12 @@ describe("normalizeProviderList", () => {
97137
})
98138
// 目录未标注 reasoning 的模型映射为 false,而不是被硬编码覆盖
99139
expect(result.all.get("openai")?.models["gpt-classic"]?.capabilities.reasoning).toBe(false)
140+
// 目录没标 reasoning 时,用服务端已有的两个信号兜底:
141+
// 已解析出的 variants、或 compatibility.reasoningField
142+
expect(result.all.get("openai")?.models["gpt-variants-only"]?.capabilities.reasoning).toBe(true)
143+
expect(result.all.get("openai")?.models["gpt-field-only"]?.capabilities.reasoning).toBe(true)
144+
// 目录显式标 false 时以目录为准,不被兜底信号覆盖
145+
expect(result.all.get("openai")?.models["gpt-off-with-variants"]?.capabilities.reasoning).toBe(false)
100146
})
101147
})
102148

‎packages/app/src/runtime/server/global-sync/utils.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ export function normalizeProviderList(
8181
family: model.family,
8282
capabilities: {
8383
temperature: false,
84-
reasoning: model.capabilities.reasoning ?? false,
84+
// 目录没标 reasoning 时(自定义供应商、目录未收录的模型)用服务端本来就带着的
85+
// 两个信号兜底:compatibility.reasoningField 或已解析出的 variants。
86+
// 目录里显式标了值就以目录为准。
87+
reasoning:
88+
model.capabilities.reasoning ??
89+
(model.compatibility?.reasoningField !== undefined || model.variants.length > 0),
8590
attachment: model.capabilities.input.some((item) => item !== "text"),
8691
toolcall: model.capabilities.tools,
8792
input: {

0 commit comments

Comments
 (0)