fix(opencode): detect Copilot PDF input support (#41522)
This commit is contained in:
@@ -88,6 +88,9 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model):
|
|||||||
const image =
|
const image =
|
||||||
(remote.capabilities.supports.vision ?? false) ||
|
(remote.capabilities.supports.vision ?? false) ||
|
||||||
(remote.capabilities.limits.vision?.supported_media_types ?? []).some((item) => item.startsWith("image/"))
|
(remote.capabilities.limits.vision?.supported_media_types ?? []).some((item) => item.startsWith("image/"))
|
||||||
|
const pdf =
|
||||||
|
(remote.capabilities.supports.vision ?? false) &&
|
||||||
|
(remote.capabilities.limits.vision?.supported_media_types?.includes("application/pdf") ?? false)
|
||||||
|
|
||||||
const isMsgApi = remote.supported_endpoints?.includes("/v1/messages")
|
const isMsgApi = remote.supported_endpoints?.includes("/v1/messages")
|
||||||
const endpoint: CopilotEndpoint | undefined = isMsgApi
|
const endpoint: CopilotEndpoint | undefined = isMsgApi
|
||||||
@@ -127,7 +130,7 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model):
|
|||||||
audio: false,
|
audio: false,
|
||||||
image,
|
image,
|
||||||
video: false,
|
video: false,
|
||||||
pdf: false,
|
pdf,
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
text: true,
|
text: true,
|
||||||
|
|||||||
@@ -187,6 +187,74 @@ test("converts Copilot AIC token prices to USD per million tokens", async () =>
|
|||||||
expect(models["ignored-non-chat-record"]).toBeUndefined()
|
expect(models["ignored-non-chat-record"]).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("detects PDF input support when vision and media type are advertised", async () => {
|
||||||
|
globalThis.fetch = mock(() =>
|
||||||
|
Promise.resolve(
|
||||||
|
new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
model_picker_enabled: true,
|
||||||
|
id: "pdf-model",
|
||||||
|
name: "PDF Model",
|
||||||
|
version: "pdf-model-2026-06-01",
|
||||||
|
capabilities: {
|
||||||
|
family: "pdf-model",
|
||||||
|
limits: {
|
||||||
|
max_context_window_tokens: 128000,
|
||||||
|
max_output_tokens: 16384,
|
||||||
|
max_prompt_tokens: 128000,
|
||||||
|
vision: {
|
||||||
|
max_prompt_image_size: 10000000,
|
||||||
|
max_prompt_images: 10,
|
||||||
|
supported_media_types: ["application/pdf"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
supports: {
|
||||||
|
streaming: true,
|
||||||
|
vision: true,
|
||||||
|
tool_calls: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
model_picker_enabled: true,
|
||||||
|
id: "vision-only-model",
|
||||||
|
name: "Vision Only Model",
|
||||||
|
version: "vision-only-model-2026-06-01",
|
||||||
|
capabilities: {
|
||||||
|
family: "vision-only-model",
|
||||||
|
limits: {
|
||||||
|
max_context_window_tokens: 128000,
|
||||||
|
max_output_tokens: 16384,
|
||||||
|
max_prompt_tokens: 128000,
|
||||||
|
vision: {
|
||||||
|
max_prompt_image_size: 10000000,
|
||||||
|
max_prompt_images: 10,
|
||||||
|
supported_media_types: ["image/png"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
supports: {
|
||||||
|
streaming: true,
|
||||||
|
vision: true,
|
||||||
|
tool_calls: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
{ status: 200 },
|
||||||
|
),
|
||||||
|
),
|
||||||
|
) as unknown as typeof fetch
|
||||||
|
|
||||||
|
const models = (await CopilotModels.get("https://api.githubcopilot.com")).models
|
||||||
|
const model = models["pdf-model"]
|
||||||
|
|
||||||
|
expect(model.capabilities.input.pdf).toBe(true)
|
||||||
|
expect(models["vision-only-model"].capabilities.input.pdf).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
test("uses zero cost when Copilot reports a zero billing batch size", async () => {
|
test("uses zero cost when Copilot reports a zero billing batch size", async () => {
|
||||||
globalThis.fetch = mock(() =>
|
globalThis.fetch = mock(() =>
|
||||||
Promise.resolve(
|
Promise.resolve(
|
||||||
|
|||||||
Reference in New Issue
Block a user