fix(copilot): ensure available variants sync from api (#24734)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Aiden Cline
2026-04-28 14:58:51 -05:00
committed by GitHub
parent 276d162044
commit 0acac216ae
5 changed files with 176 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ function build(key: string, remote: Item, url: string, prev?: Model): Model {
const isMsgApi = remote.supported_endpoints?.includes("/v1/messages")
return {
const model: Model = {
id: key,
providerID: "github-copilot",
api: {
@@ -107,8 +107,50 @@ function build(key: string, remote: Item, url: string, prev?: Model): Model {
release_date:
prev?.release_date ??
(remote.version.startsWith(`${remote.id}-`) ? remote.version.slice(remote.id.length + 1) : remote.version),
variants: prev?.variants ?? {},
}
const efforts = remote.capabilities.supports.reasoning_effort
const variants: NonNullable<Model["variants"]> = {}
if (!isMsgApi && efforts?.length) {
efforts.forEach((effort) => {
variants[effort] = {
reasoningEffort: effort,
reasoningSummary: "auto",
include: ["reasoning.encrypted_content"],
}
})
} else {
if (efforts?.length && remote.capabilities.supports.adaptive_thinking) {
efforts.forEach((effort) => {
variants[effort] = {
thinking: {
type: "adaptive",
...(model.api.id.includes("opus-4.7") ? { display: "summarized" } : {}),
},
effort,
}
})
} else if (remote.capabilities.supports.max_thinking_budget) {
const max = remote.capabilities.supports.max_thinking_budget
variants["max"] = {
thinking: {
type: "enabled",
budgetTokens: max - 1,
},
}
variants["high"] = {
thinking: {
type: "enabled",
budgetTokens: Math.floor(max / 2),
},
}
}
}
if (Object.keys(variants).length > 0) {
model.variants = variants
}
return model
}
export async function get(