Explorar el Código

fix(provider): split providerOptions key on dot for openai-compatible, openai, and anthropic providers (#25145)

Sewer. hace 3 meses
padre
commit
a12333310f
Se han modificado 1 ficheros con 14 adiciones y 1 borrados
  1. 14 1
      packages/opencode/src/provider/transform.ts

+ 14 - 1
packages/opencode/src/provider/transform.ts

@@ -1058,7 +1058,20 @@ export function providerOptions(model: Provider.Model, options: { [x: string]: a
     return result
   }
 
-  const key = sdkKey(model.api.npm) ?? model.providerID
+  // AI SDK packages that resolve providerOptionsName by splitting the
+  // provider name on "." (e.g. "wafer.ai" -> "wafer") need the same
+  // logic here so the key we write matches the key they read.
+  // Other SDKs (xai, mistral, groq, cohere, etc.) use hardcoded keys
+  // like "xai" or "cohere" - applying .split(".")[0] would break those.
+  const usesDotSplitOptions =
+    model.api.npm === "@ai-sdk/openai-compatible" ||
+    model.api.npm === "@ai-sdk/openai" ||
+    model.api.npm === "@ai-sdk/anthropic"
+  const key =
+    sdkKey(model.api.npm) ??
+    (usesDotSplitOptions
+      ? model.providerID.split(".")[0]
+      : model.providerID)
   // @ai-sdk/azure delegates to OpenAIChatLanguageModel which reads from
   // providerOptions["openai"], but OpenAIResponsesLanguageModel checks
   // "azure" first. Pass both so model options work on either code path.