Skip to content

Commit 86df915

Browse files
committed
chore: cleanup provider code to assign copilot sdk earlier in flow
1 parent 6f847a7 commit 86df915

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

packages/opencode/src/provider/provider.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,14 @@ export namespace Provider {
598598
providerID: provider.id,
599599
name: model.name,
600600
family: model.family,
601-
api: {
602-
id: model.id,
603-
url: provider.api!,
604-
npm: model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible",
605-
},
601+
api: {
602+
id: model.id,
603+
url: provider.api!,
604+
npm: iife(() => {
605+
if (provider.id.startsWith("github-copilot")) return "@ai-sdk/github-copilot"
606+
return model.provider?.npm ?? provider.npm ?? "@ai-sdk/openai-compatible"
607+
}),
608+
},
606609
status: model.status ?? "active",
607610
headers: model.headers ?? {},
608611
options: model.options ?? {},
@@ -908,16 +911,6 @@ export namespace Provider {
908911
continue
909912
}
910913

911-
if (providerID === "github-copilot" || providerID === "github-copilot-enterprise") {
912-
provider.models = mapValues(provider.models, (model) => ({
913-
...model,
914-
api: {
915-
...model.api,
916-
npm: "@ai-sdk/github-copilot",
917-
},
918-
}))
919-
}
920-
921914
const configProvider = config.provider?.[providerID]
922915

923916
for (const [modelID, model] of Object.entries(provider.models)) {

0 commit comments

Comments
 (0)