fix(provider): restore gateway openai fallback efforts
This commit is contained in:
parent
36ed0f4878
commit
3f0f90e94e
4 changed files with 11 additions and 6 deletions
|
|
@ -590,6 +590,10 @@ function openAIReasoningEffortVariants() {
|
|||
)
|
||||
}
|
||||
|
||||
function openAICompatibleReasoningEffortVariants() {
|
||||
return Object.fromEntries(OPENAI_EFFORTS.map((effort) => [effort, { reasoningEffort: effort }]))
|
||||
}
|
||||
|
||||
type ReasoningOption = NonNullable<Provider.Model["reasoning_options"]>[number]
|
||||
type ReasoningEffortOption = Extract<ReasoningOption, { type: "effort" }>
|
||||
type ReasoningBudgetOption = Extract<ReasoningOption, { type: "budget_tokens" }>
|
||||
|
|
@ -828,6 +832,7 @@ export function variants(model: Provider.Model): Record<string, Record<string, a
|
|||
return Object.fromEntries(WIDELY_SUPPORTED_EFFORTS.map((effort) => [effort, { reasoning: { effort } }]))
|
||||
|
||||
case "ai-gateway-provider":
|
||||
if (idIncludes(model, "openai")) return openAICompatibleReasoningEffortVariants()
|
||||
return Object.fromEntries(WIDELY_SUPPORTED_EFFORTS.map((effort) => [effort, { reasoningEffort: effort }]))
|
||||
|
||||
case "@ai-sdk/gateway":
|
||||
|
|
|
|||
|
|
@ -3881,12 +3881,15 @@ describe("ProviderTransform.variants", () => {
|
|||
release_date: releaseDate,
|
||||
})
|
||||
|
||||
test("falls back to widely-supported OAI efforts", () => {
|
||||
test("OpenAI upstreams fall back to broad OAI efforts", () => {
|
||||
const result = ProviderTransform.variants(cfModel("openai/gpt-future", "2026-03-05"))
|
||||
expect(result).toEqual({
|
||||
none: { reasoningEffort: "none" },
|
||||
minimal: { reasoningEffort: "minimal" },
|
||||
low: { reasoningEffort: "low" },
|
||||
medium: { reasoningEffort: "medium" },
|
||||
high: { reasoningEffort: "high" },
|
||||
xhigh: { reasoningEffort: "xhigh" },
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -316,9 +316,7 @@ describe("tool.read truncation", () => {
|
|||
it.instance("truncates large file by bytes and sets truncated metadata", () =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const base = yield* load(path.join(FIXTURES_DIR, "models-api.json"))
|
||||
const target = 60 * 1024
|
||||
const content = base.length >= target ? base : base.repeat(Math.ceil(target / base.length))
|
||||
const content = `${"x".repeat(80)}\n`.repeat(1_000)
|
||||
yield* put(path.join(test.directory, "large.json"), content)
|
||||
|
||||
const result = yield* run({ filePath: path.join(test.directory, "large.json") })
|
||||
|
|
|
|||
|
|
@ -163,8 +163,7 @@ describe("Truncate", () => {
|
|||
it.live("large single-line file truncates with byte message", () =>
|
||||
Effect.gen(function* () {
|
||||
const svc = yield* Truncate.Service
|
||||
const fsys = yield* FSUtil.Service
|
||||
const content = yield* fsys.readFileString(path.join(FIXTURES_DIR, "models-api.json"))
|
||||
const content = "a".repeat(Truncate.MAX_BYTES + 1)
|
||||
const result = yield* svc.output(content)
|
||||
|
||||
expect(result.truncated).toBe(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue