mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
feat(core): wire native Vercel AI Gateway provider (#53432)
This commit is contained in:
committed by
GitHub
Unverified
parent
d1e6104087
commit
8186b7313a
@@ -345,7 +345,6 @@
|
||||
"version": "2.0.23",
|
||||
"dependencies": {
|
||||
"@ai-sdk/cohere": "3.0.27",
|
||||
"@ai-sdk/gateway": "3.0.104",
|
||||
"@ai-sdk/perplexity": "3.0.26",
|
||||
"@ai-sdk/provider": "3.0.8",
|
||||
"@ai-sdk/provider-utils": "4.0.23",
|
||||
@@ -1234,8 +1233,6 @@
|
||||
|
||||
"@ai-sdk/cohere": ["@ai-sdk/cohere@3.0.27", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.21" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-OqcCq2PiFY1dbK/0Ck45KuvE8jfdxRuuAE9Y5w46dAk6U+9vPOeg1CDcmR+ncqmrYrhRl3nmyDttyDahyjCzAw=="],
|
||||
|
||||
"@ai-sdk/gateway": ["@ai-sdk/gateway@3.0.104", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.23", "@vercel/oidc": "3.2.0" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-ZKX5n74io8VIRlhIMSLWVlvT3sXC8Z7cZ9GHuWBWZDVi96+62AIsWuLGvMfcBA1STYuSoDrp6rIziZmvrTq0TA=="],
|
||||
|
||||
"@ai-sdk/openai-compatible": ["@ai-sdk/openai-compatible@2.0.41", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.23" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-kNAGINk71AlOXx10Dq/PXw4t/9XjdK8uxfpVElRwtSFMdeSiLVt58p9TPx4/FJD+hxZuVhvxYj9r42osxWq79g=="],
|
||||
|
||||
"@ai-sdk/perplexity": ["@ai-sdk/perplexity@3.0.26", "", { "dependencies": { "@ai-sdk/provider": "3.0.8", "@ai-sdk/provider-utils": "4.0.21" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-dXzrVsLR5f6tr+U04jq4AXoRroGFBTvODnLgss0SWbzNjGGQg3XqtQ9j7rCLo6o8qbYGuAHvqUrIpUCuiscuFg=="],
|
||||
@@ -3288,8 +3285,6 @@
|
||||
|
||||
"@upstash/redis": ["@upstash/redis@1.38.0", "", { "dependencies": { "uncrypto": "^0.1.3" } }, "sha512-wu+dZBptlLy0+MCUEoHmzrY/TnmgDey3+c7EbIGwrLqAvkP8yi5MWZHYGIFtAygmL4Bkz2TdFu+eU0vFPncIcg=="],
|
||||
|
||||
"@vercel/oidc": ["@vercel/oidc@3.2.0", "", {}, "sha512-UycprH3T6n3jH0k44NHMa7pnFHGu/N05MjojYr+Mc6I7obkoLIJujSWwin1pCvdy/eOxrI/l3uDLQsmcrOb4ug=="],
|
||||
|
||||
"@vitejs/plugin-react": ["@vitejs/plugin-react@4.7.0", "", { "dependencies": { "@babel/core": "^7.28.0", "@babel/plugin-transform-react-jsx-self": "^7.27.1", "@babel/plugin-transform-react-jsx-source": "^7.27.1", "@rolldown/pluginutils": "1.0.0-beta.27", "@types/babel__core": "^7.20.5", "react-refresh": "^0.17.0" }, "peerDependencies": { "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA=="],
|
||||
|
||||
"@vitest/expect": ["@vitest/expect@3.2.4", "", { "dependencies": { "@types/chai": "^5.2.2", "@vitest/spy": "3.2.4", "@vitest/utils": "3.2.4", "chai": "^5.2.0", "tinyrainbow": "^2.0.0" } }, "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig=="],
|
||||
|
||||
@@ -96,7 +96,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ai-sdk/cohere": "3.0.27",
|
||||
"@ai-sdk/gateway": "3.0.104",
|
||||
"@ai-sdk/perplexity": "3.0.26",
|
||||
"@ai-sdk/provider": "3.0.8",
|
||||
"@ai-sdk/provider-utils": "4.0.23",
|
||||
|
||||
@@ -73,6 +73,7 @@ const PACKAGES: Readonly<Record<string, string>> = {
|
||||
"@ai-sdk/openai-compatible": "@opencode/ai/providers/openai-compatible",
|
||||
"@ai-sdk/togetherai": "@opencode/ai/providers/togetherai",
|
||||
"@ai-sdk/xai": "@opencode/ai/providers/xai",
|
||||
"@ai-sdk/gateway": "@opencode/ai/providers/vercel-ai-gateway",
|
||||
"@openrouter/ai-sdk-provider": "@opencode/ai/providers/openrouter",
|
||||
"ai-gateway-provider": "@opencode/ai/providers/cloudflare-ai-gateway",
|
||||
"venice-ai-sdk-provider": "@opencode/ai/providers/venice",
|
||||
|
||||
@@ -459,6 +459,7 @@ function usesAPIKeyAuth(packageName: string | undefined) {
|
||||
name === "@opencode/ai/providers/groq" ||
|
||||
name === "@opencode/ai/providers/mistral" ||
|
||||
name === "@opencode/ai/providers/togetherai" ||
|
||||
name === "@opencode/ai/providers/vercel-ai-gateway" ||
|
||||
name === "@opencode/ai/providers/xai" ||
|
||||
name === "@opencode/ai/providers/openrouter" ||
|
||||
name === "@opencode/ai/providers/azure" ||
|
||||
|
||||
@@ -7,7 +7,6 @@ import { CloudflareWorkersAIPlugin } from "./provider/cloudflare-workers-ai.js"
|
||||
import { CoherePlugin } from "./provider/cohere.js"
|
||||
import { DigitalOceanPlugin } from "./provider/digitalocean.js"
|
||||
import { DynamicProviderPlugin } from "./provider/dynamic.js"
|
||||
import { GatewayPlugin } from "./provider/gateway.js"
|
||||
import { GithubCopilotPlugin } from "./provider/github-copilot.js"
|
||||
import { GitLabPlugin } from "./provider/gitlab.js"
|
||||
import { GoogleVertexPlugin } from "./provider/google-vertex.js"
|
||||
@@ -40,7 +39,6 @@ export const ProviderPlugins: PluginInternal.InternalPlugin[] = [
|
||||
CloudflareWorkersAIPlugin,
|
||||
CoherePlugin,
|
||||
DigitalOceanPlugin,
|
||||
GatewayPlugin,
|
||||
GithubCopilotPlugin,
|
||||
GitLabPlugin,
|
||||
GoogleVertexPlugin,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { createProviderPlugin } from "./factory.js"
|
||||
|
||||
export const GatewayPlugin = createProviderPlugin({
|
||||
id: "opencode.provider.gateway",
|
||||
package: "@ai-sdk/gateway",
|
||||
load: async (options) => {
|
||||
const { createGateway } = await import("@ai-sdk/gateway")
|
||||
return createGateway(options)
|
||||
},
|
||||
})
|
||||
@@ -13,7 +13,11 @@ const direct = new Set([
|
||||
"@opencode/ai/providers/azure",
|
||||
"@opencode/ai/providers/azure/responses",
|
||||
])
|
||||
const gateways = new Set(["@opencode/ai/providers/cloudflare-ai-gateway", Provider.aisdk("@ai-sdk/gateway")])
|
||||
const gateways = new Set([
|
||||
"@opencode/ai/providers/cloudflare-ai-gateway",
|
||||
"@opencode/ai/providers/vercel-ai-gateway",
|
||||
Provider.aisdk("@ai-sdk/gateway"),
|
||||
])
|
||||
|
||||
export const Plugin = define({
|
||||
id: "opencode.prompt.verbosity",
|
||||
|
||||
@@ -98,6 +98,7 @@ const builtins = new Map<string, () => Promise<unknown>>([
|
||||
["@opencode/ai/providers/openrouter", () => import("@opencode/ai/providers/openrouter")],
|
||||
["@opencode/ai/providers/togetherai", () => import("@opencode/ai/providers/togetherai")],
|
||||
["@opencode/ai/providers/venice", () => import("@opencode/ai/providers/venice")],
|
||||
["@opencode/ai/providers/vercel-ai-gateway", () => import("@opencode/ai/providers/vercel-ai-gateway")],
|
||||
["@opencode/ai/providers/xai", () => import("@opencode/ai/providers/xai")],
|
||||
["@opencode/ai/providers/zai/chat", () => import("@opencode/ai/providers/zai/chat")],
|
||||
["@opencode/ai/providers/zai-coding-plan/chat", () => import("@opencode/ai/providers/zai-coding-plan/chat")],
|
||||
|
||||
@@ -300,10 +300,12 @@ const anthropicMessages: Protocol = (model, support) => {
|
||||
const thinking = opus45 ? manualThinking(model) : { settings: { thinking: ADAPTIVE_THINKING } }
|
||||
if (!thinking) return []
|
||||
const defaults = info.major === 4 && info.minor === 6 ? [...EFFORTS, "max"] : [...EFFORTS, "xhigh", "max"]
|
||||
const values = support.values ?? defaults
|
||||
return efforts(values, (effort) => ({
|
||||
settings: { ...thinking.settings, effort },
|
||||
}))
|
||||
const values = (support.values ?? defaults).filter((effort) => !info.always || effort !== "none")
|
||||
return efforts(values, (effort) =>
|
||||
effort === "none"
|
||||
? { settings: { thinking: { type: "disabled" } } }
|
||||
: { settings: { ...thinking.settings, effort } },
|
||||
)
|
||||
}
|
||||
case "toggle": {
|
||||
if (info.always) return []
|
||||
@@ -439,22 +441,6 @@ const bedrockConverse: Protocol = (model, support) => {
|
||||
}
|
||||
}
|
||||
|
||||
const alibabaAISDK: Protocol = (model, support) => {
|
||||
switch (support.type) {
|
||||
case "effort":
|
||||
return []
|
||||
case "toggle":
|
||||
return toggle({ settings: { enableThinking: false } }, { settings: { enableThinking: true } })
|
||||
case "budget_tokens":
|
||||
return budgets(
|
||||
model,
|
||||
support,
|
||||
(tokens) => ({ settings: { enableThinking: true, thinkingBudget: tokens } }),
|
||||
ALIBABA_THINKING_BUDGET_MAX,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const cohere: Protocol = (model, support) => {
|
||||
switch (support.type) {
|
||||
case "effort":
|
||||
@@ -466,49 +452,26 @@ const cohere: Protocol = (model, support) => {
|
||||
}
|
||||
}
|
||||
|
||||
const bedrockAISDK: Protocol = (model, support) => {
|
||||
const claude = modelID(model).includes("anthropic")
|
||||
const vercelGateway: Protocol = (model, support) => {
|
||||
const id = modelID(model)
|
||||
if (id.startsWith("openai/gpt-")) return openaiResponses(model, support)
|
||||
if (id.startsWith("spacexai/grok-")) return xaiResponses(model, support)
|
||||
if (id.startsWith("anthropic/")) return anthropicMessages(model, support)
|
||||
switch (support.type) {
|
||||
case "effort":
|
||||
return efforts(support.values ?? EFFORTS, (effort) => ({
|
||||
settings: claude
|
||||
? {
|
||||
reasoningConfig: {
|
||||
...(claudeInfo(model).manual ? {} : ADAPTIVE_THINKING),
|
||||
maxReasoningEffort: effort,
|
||||
},
|
||||
}
|
||||
: { reasoningConfig: { type: "enabled", maxReasoningEffort: effort } },
|
||||
}))
|
||||
return openaiChat(model, support)
|
||||
case "toggle":
|
||||
return claude
|
||||
? toggle(
|
||||
{ settings: { additionalModelRequestFields: { thinking: { type: "disabled" } } } },
|
||||
{ settings: { additionalModelRequestFields: { thinking: ADAPTIVE_THINKING } } },
|
||||
)
|
||||
: toggle(
|
||||
{ settings: { additionalModelRequestFields: { reasoningConfig: { type: "disabled" } } } },
|
||||
{ settings: { additionalModelRequestFields: { reasoningConfig: { type: "enabled" } } } },
|
||||
)
|
||||
return toggle({ settings: { thinking: { type: "disabled" } } }, { settings: { thinking: { type: "adaptive" } } })
|
||||
case "budget_tokens":
|
||||
return budgets(
|
||||
model,
|
||||
support,
|
||||
(tokens) => ({ settings: { reasoningConfig: { type: "enabled", budgetTokens: tokens } } }),
|
||||
claude ? ANTHROPIC_OUTPUT_TOKEN_MAX : model.limit.output,
|
||||
(tokens) => ({ settings: { thinking: { type: "enabled", budgetTokens: tokens } } }),
|
||||
id.startsWith("alibaba/") ? ALIBABA_THINKING_BUDGET_MAX : model.limit.output,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const vercelGateway: Protocol = (model, support) => {
|
||||
const prefix = modelID(model).split("/")[0]
|
||||
if (prefix === "anthropic") return anthropicMessages(model, support)
|
||||
if (prefix === "google") return gemini(model, support)
|
||||
if (prefix === "amazon") return bedrockAISDK(model, support)
|
||||
if (prefix === "alibaba") return alibabaAISDK(model, support)
|
||||
return support.type === "effort" ? openaiChat(model, support) : openrouter(model, support)
|
||||
}
|
||||
|
||||
const sapAICore: Protocol = (model, support) => {
|
||||
const id = modelID(model)
|
||||
const sap = (modelParams: Record<string, unknown>): Overlay => ({ settings: { modelParams } })
|
||||
@@ -614,6 +577,7 @@ const PROTOCOLS: Readonly<Record<string, Protocol>> = {
|
||||
|
||||
[Provider.aisdk("venice-ai-sdk-provider")]: veniceChat,
|
||||
"@opencode/ai/providers/cloudflare-ai-gateway": cloudflareAIGateway,
|
||||
"@opencode/ai/providers/vercel-ai-gateway": vercelGateway,
|
||||
[Provider.aisdk("@ai-sdk/gateway")]: vercelGateway,
|
||||
[Provider.aisdk("@jerome-benoit/sap-ai-provider-v2")]: sapAICore,
|
||||
}
|
||||
|
||||
@@ -34,6 +34,32 @@ describe("AISDKNative", () => {
|
||||
}
|
||||
})
|
||||
|
||||
test("maps Vercel AI Gateway packages to native routes", () => {
|
||||
expect(
|
||||
map(
|
||||
"@ai-sdk/gateway",
|
||||
{
|
||||
apiKey: "secret",
|
||||
headers: { "x-gateway": "test" },
|
||||
extraBody: { custom: true },
|
||||
gateway: { order: ["anthropic"] },
|
||||
reasoningEffort: "high",
|
||||
},
|
||||
"anthropic/claude-sonnet-5.5",
|
||||
"vercel",
|
||||
),
|
||||
).toEqual({
|
||||
package: "@opencode/ai/providers/vercel-ai-gateway",
|
||||
settings: {
|
||||
apiKey: "secret",
|
||||
gateway: { order: ["anthropic"] },
|
||||
reasoningEffort: "high",
|
||||
},
|
||||
headers: { "x-gateway": "test" },
|
||||
body: { custom: true },
|
||||
})
|
||||
})
|
||||
|
||||
test("maps OpenAI-family packages and request options to native providers", () => {
|
||||
expect(
|
||||
map("@ai-sdk/openai", {
|
||||
|
||||
@@ -1092,6 +1092,7 @@ describe("ModelResolver", () => {
|
||||
["@ai-sdk/openai-compatible", "@opencode/ai/providers/openai-compatible", "api-model"],
|
||||
["@openrouter/ai-sdk-provider", "@opencode/ai/providers/openrouter", "api-model"],
|
||||
["@ai-sdk/togetherai", "@opencode/ai/providers/togetherai", "api-model"],
|
||||
["@ai-sdk/gateway", "@opencode/ai/providers/vercel-ai-gateway", "openai/gpt-5.4"],
|
||||
["@ai-sdk/xai", "@opencode/ai/providers/xai", "api-model"],
|
||||
["ai-gateway-provider", "@opencode/ai/providers/cloudflare-ai-gateway", "xai/grok-4.6"],
|
||||
] as const
|
||||
|
||||
@@ -1112,14 +1112,14 @@ describe("ModelsDevPlugin", () => {
|
||||
|
||||
const gateway = yield* modelState.get(Provider.ID.make("vercel"), Model.ID.make("alibaba/qwen-toggle"))
|
||||
expect(gateway?.variants).toEqual([
|
||||
{ id: Model.VariantID.make("none"), settings: { enableThinking: false } },
|
||||
{ id: Model.VariantID.make("none"), settings: { thinking: { type: "disabled" } } },
|
||||
{
|
||||
id: Model.VariantID.make("high"),
|
||||
settings: { enableThinking: true, thinkingBudget: 8000 },
|
||||
settings: { thinking: { type: "enabled", budgetTokens: 8000 } },
|
||||
},
|
||||
{
|
||||
id: Model.VariantID.make("max"),
|
||||
settings: { enableThinking: true, thinkingBudget: 16000 },
|
||||
settings: { thinking: { type: "enabled", budgetTokens: 16000 } },
|
||||
},
|
||||
])
|
||||
|
||||
@@ -1127,15 +1127,15 @@ describe("ModelsDevPlugin", () => {
|
||||
expect(gatewayNova?.variants).toEqual([
|
||||
{
|
||||
id: Model.VariantID.make("none"),
|
||||
settings: { additionalModelRequestFields: { reasoningConfig: { type: "disabled" } } },
|
||||
settings: { thinking: { type: "disabled" } },
|
||||
},
|
||||
{
|
||||
id: Model.VariantID.make("low"),
|
||||
settings: { reasoningConfig: { type: "enabled", maxReasoningEffort: "low" } },
|
||||
settings: { reasoningEffort: "low" },
|
||||
},
|
||||
{
|
||||
id: Model.VariantID.make("high"),
|
||||
settings: { reasoningConfig: { type: "enabled", maxReasoningEffort: "high" } },
|
||||
settings: { reasoningEffort: "high" },
|
||||
},
|
||||
])
|
||||
|
||||
@@ -1146,7 +1146,7 @@ describe("ModelsDevPlugin", () => {
|
||||
expect(gatewayFallback?.variants).toEqual([
|
||||
{
|
||||
id: Model.VariantID.make("none"),
|
||||
settings: { reasoning: { enabled: false } },
|
||||
settings: { thinking: { type: "disabled" } },
|
||||
},
|
||||
{
|
||||
id: Model.VariantID.make("low"),
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Model } from "@opencode/core/model"
|
||||
import { Plugin } from "@opencode/core/plugin"
|
||||
import { PluginHost } from "@opencode/core/plugin/host"
|
||||
import { CoherePlugin } from "@opencode/core/plugin/provider/cohere"
|
||||
import { GatewayPlugin } from "@opencode/core/plugin/provider/gateway"
|
||||
import { PerplexityPlugin } from "@opencode/core/plugin/provider/perplexity"
|
||||
import { Provider } from "@opencode/core/provider"
|
||||
import { testEffect } from "../lib/effect"
|
||||
@@ -15,7 +14,6 @@ const modelID = Model.ID.make("test-model")
|
||||
const options = { name: "custom-provider", apiKey: "test", baseURL: "https://example.test" }
|
||||
const providers = [
|
||||
{ id: "cohere", plugin: CoherePlugin, package: "@ai-sdk/cohere", provider: "cohere.chat" },
|
||||
{ id: "gateway", plugin: GatewayPlugin, package: "@ai-sdk/gateway", provider: "gateway" },
|
||||
{ id: "perplexity", plugin: PerplexityPlugin, package: "@ai-sdk/perplexity", provider: "perplexity" },
|
||||
] as const
|
||||
|
||||
|
||||
@@ -94,11 +94,11 @@ it.effect("sets known OpenAI Responses defaults without overriding configured or
|
||||
["azure", "@opencode/ai/providers/azure/responses", "gpt-5.5"],
|
||||
["bedrock-mantle", "@opencode/ai/providers/amazon-bedrock/mantle/responses", "openai.gpt-6-sol"],
|
||||
["cloudflare", "@opencode/ai/providers/cloudflare-ai-gateway", "openai/gpt-5.6-sol"],
|
||||
["vercel", Provider.aisdk("@ai-sdk/gateway"), "openai/gpt-6-astra-fast"],
|
||||
["vercel", "@opencode/ai/providers/vercel-ai-gateway", "openai/gpt-6-astra-fast"],
|
||||
["azure-chat", "@opencode/ai/providers/azure/chat", "gpt-5.5"],
|
||||
["bedrock-converse", "@opencode/ai/providers/amazon-bedrock", "global.openai.gpt-6-sol"],
|
||||
["cloudflare-chat", "@opencode/ai/providers/cloudflare-ai-gateway", "workers-ai/gpt-5.5"],
|
||||
["vercel-other", Provider.aisdk("@ai-sdk/gateway"), "anthropic/gpt-5.5"],
|
||||
["vercel-other", "@opencode/ai/providers/vercel-ai-gateway", "anthropic/gpt-5.5"],
|
||||
] as const) {
|
||||
editor.add({
|
||||
info: { ...Provider.Info.empty(Provider.ID.make(providerID)), package: packageName },
|
||||
|
||||
@@ -22,6 +22,7 @@ describe("Provider", () => {
|
||||
"@opencode/ai/providers/groq",
|
||||
"@opencode/ai/providers/mistral",
|
||||
"@opencode/ai/providers/togetherai",
|
||||
"@opencode/ai/providers/vercel-ai-gateway",
|
||||
]
|
||||
|
||||
for (const specifier of packages) {
|
||||
|
||||
@@ -126,6 +126,46 @@ test("spells Cloudflare AI Gateway variants for their upstream routes", () => {
|
||||
])
|
||||
})
|
||||
|
||||
test("spells Vercel AI Gateway variants for their selected routes", () => {
|
||||
const pkg = "@opencode/ai/providers/vercel-ai-gateway"
|
||||
expect(resolve(model(pkg, "openai/gpt-5.4"), [{ type: "effort", values: ["low", "xhigh"] }])).toEqual([
|
||||
{
|
||||
id: "low",
|
||||
settings: { reasoningEffort: "low", reasoningSummary: "auto", include: ["reasoning.encrypted_content"] },
|
||||
},
|
||||
{
|
||||
id: "xhigh",
|
||||
settings: { reasoningEffort: "xhigh", reasoningSummary: "auto", include: ["reasoning.encrypted_content"] },
|
||||
},
|
||||
])
|
||||
expect(resolve(model(pkg, "spacexai/grok-4.7"), [{ type: "effort" }]).map((item) => item.id)).toEqual([
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
])
|
||||
expect(
|
||||
resolve(model(pkg, "anthropic/claude-sonnet-4.6"), [{ type: "effort", values: ["none", "low", "high"] }]),
|
||||
).toEqual([
|
||||
{ id: "none", settings: { thinking: { type: "disabled" } } },
|
||||
{ id: "low", settings: { effort: "low", thinking: { type: "adaptive", display: "summarized" } } },
|
||||
{ id: "high", settings: { effort: "high", thinking: { type: "adaptive", display: "summarized" } } },
|
||||
])
|
||||
expect(resolve(model(pkg, "meta/muse-spark-1.3"), [{ type: "effort", values: ["low", "high"] }])).toEqual([
|
||||
{ id: "low", settings: { reasoningEffort: "low" } },
|
||||
{ id: "high", settings: { reasoningEffort: "high" } },
|
||||
])
|
||||
expect(
|
||||
resolve(model(pkg, "alibaba/qwen-3-32b", 38_912), [
|
||||
{ type: "toggle" },
|
||||
{ type: "budget_tokens", min: 1, max: 38_912 },
|
||||
]),
|
||||
).toEqual([
|
||||
{ id: "none", settings: { thinking: { type: "disabled" } } },
|
||||
{ id: "high", settings: { thinking: { type: "enabled", budgetTokens: 19_456 } } },
|
||||
{ id: "max", settings: { thinking: { type: "enabled", budgetTokens: 38_911 } } },
|
||||
])
|
||||
})
|
||||
|
||||
test("spells xAI Responses variants with catalog effort levels", () => {
|
||||
const supports: Variant.Support[] = [{ type: "effort", values: ["low", "medium", "high", "xhigh"] }]
|
||||
expect(resolve(model("@opencode/ai/providers/xai", "grok-4.6"), supports)).toEqual(
|
||||
|
||||
Reference in New Issue
Block a user