fix(provider): normalize null reasoning efforts to none
The generated SDK flattens Schema.NullOr to plain strings, so the runtime schema with (string | null)[] effort values no longer matched the generated Provider type and typecheck failed on dev. models.dev uses null to mean reasoning can be disabled; map it to "none" at parse time and keep the public schema plain strings.
This commit is contained in:
parent
cf7503687a
commit
8eef79784e
2 changed files with 8 additions and 4 deletions
|
|
@ -984,7 +984,7 @@ const ProviderInterleaved = Schema.Union([
|
|||
const ProviderReasoningOption = Schema.Union([
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("effort"),
|
||||
values: Schema.Array(Schema.NullOr(Schema.String)),
|
||||
values: Schema.Array(Schema.String),
|
||||
}),
|
||||
Schema.Struct({
|
||||
type: Schema.Literal("toggle"),
|
||||
|
|
@ -1234,7 +1234,11 @@ function normalizeReasoningOption(option: unknown): ReasoningOption | undefined
|
|||
if (!Array.isArray(option.values)) return
|
||||
return {
|
||||
type: "effort",
|
||||
values: option.values.filter((value): value is string | null => value === null || typeof value === "string"),
|
||||
// models.dev uses null to mean reasoning can be disabled; expose it as "none".
|
||||
values: option.values.flatMap((value) => {
|
||||
if (value === null) return ["none"]
|
||||
return typeof value === "string" ? [value] : []
|
||||
}),
|
||||
}
|
||||
}
|
||||
if (option.type === "toggle") return { type: "toggle" }
|
||||
|
|
|
|||
|
|
@ -1439,7 +1439,7 @@ test("models.dev reasoning options normalize to known shapes", () => {
|
|||
reasoning: true,
|
||||
reasoning_options: [
|
||||
{ type: "future_control", value: true },
|
||||
{ type: "effort", values: ["high", null, 42] },
|
||||
{ type: "effort", values: [null, "high", 42] },
|
||||
{ type: "toggle" },
|
||||
{ type: "budget_tokens", min: 1024, max: "invalid" },
|
||||
],
|
||||
|
|
@ -1449,7 +1449,7 @@ test("models.dev reasoning options normalize to known shapes", () => {
|
|||
} as unknown as ModelsDev.Provider)
|
||||
|
||||
expect(provider.models.reasoner.reasoning_options).toEqual([
|
||||
{ type: "effort", values: ["high", null] },
|
||||
{ type: "effort", values: ["none", "high"] },
|
||||
{ type: "toggle" },
|
||||
{ type: "budget_tokens", min: 1024 },
|
||||
])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue