Skip to content

Commit d1ca5ea

Browse files
committed
Playground: local experiments
1 parent ff81ec6 commit d1ca5ea

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../ui/src/custom-elements.d.ts
1+
/// <reference path="../../ui/src/custom-elements.d.ts" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../ui/src/custom-elements.d.ts
1+
/// <reference path="../../ui/src/custom-elements.d.ts" />

packages/opencode/src/provider/provider.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ import { createOpenaiCompatible as createGitHubCopilotOpenAICompatible } from ".
2929
export namespace Provider {
3030
const log = Log.create({ service: "provider" })
3131

32+
function isGpt5OrLater(modelID: string): boolean {
33+
const match = /^gpt-(\d+)/.exec(modelID)
34+
if (!match) {
35+
return false
36+
}
37+
return Number(match[1]) >= 5
38+
}
39+
3240
const BUNDLED_PROVIDERS: Record<string, (options: any) => SDK> = {
3341
"@ai-sdk/amazon-bedrock": createAmazonBedrock,
3442
"@ai-sdk/anthropic": createAnthropic,
@@ -91,25 +99,41 @@ export namespace Provider {
9199
options: {},
92100
}
93101
},
94-
"github-copilot": async () => {
102+
"github-copilot": async (input) => {
95103
return {
96104
autoload: false,
97105
async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
106+
// GitHub Copilot can optionally route supported models through the Responses API.
107+
// This enables settings like reasoningEffort/reasoningSummary for GPT-5.* models.
108+
const useResponsesApi = Boolean(input.options?.useResponsesApi)
109+
98110
if (modelID.includes("codex")) {
99111
return sdk.responses(modelID)
100112
}
113+
114+
if (useResponsesApi && isGpt5OrLater(modelID)) {
115+
return sdk.responses(modelID)
116+
}
117+
101118
return sdk.chat(modelID)
102119
},
103120
options: {},
104121
}
105122
},
106-
"github-copilot-enterprise": async () => {
123+
"github-copilot-enterprise": async (input) => {
107124
return {
108125
autoload: false,
109126
async getModel(sdk: any, modelID: string, _options?: Record<string, any>) {
127+
const useResponsesApi = Boolean(input.options?.useResponsesApi)
128+
110129
if (modelID.includes("codex")) {
111130
return sdk.responses(modelID)
112131
}
132+
133+
if (useResponsesApi && isGpt5OrLater(modelID)) {
134+
return sdk.responses(modelID)
135+
}
136+
113137
return sdk.chat(modelID)
114138
},
115139
options: {},

0 commit comments

Comments
 (0)