GeezerVison is showing github.com — fix(opencode): detect Copilot PDF input support (#41522) · Draugur-AI/opencode@561afb4
File treeExpand file treeCollapse file tree Open diff view settings src/plugin/github-copilot
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/plugin/github-copilot/models.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,6 +88,9 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model): | 88 | 88 | const image = | 89 | 89 | (remote.capabilities.supports.vision ?? false) || | 90 | 90 | (remote.capabilities.limits.vision?.supported_media_types ?? []).some((item) => item.startsWith("image/")) | | 91 | + const pdf = | | 92 | + (remote.capabilities.supports.vision ?? false) && | | 93 | + (remote.capabilities.limits.vision?.supported_media_types?.includes("application/pdf") ?? false) | 91 | 94 |
| 92 | 95 | const isMsgApi = remote.supported_endpoints?.includes("/v1/messages") | 93 | 96 | const endpoint: CopilotEndpoint | undefined = isMsgApi | @@ -127,7 +130,7 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model): | 127 | 130 | audio: false, | 128 | 131 | image, | 129 | 132 | video: false, | 130 | | - pdf: false, | | 133 | + pdf, | 131 | 134 | }, | 132 | 135 | output: { | 133 | 136 | text: true, | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/plugin/github-copilot-models.test.ts +68Lines changed: 68 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -187,6 +187,74 @@ test("converts Copilot AIC token prices to USD per million tokens", async () => | 187 | 187 | expect(models["ignored-non-chat-record"]).toBeUndefined() | 188 | 188 | }) | 189 | 189 |
| | 190 | +test("detects PDF input support when vision and media type are advertised", async () => { | | 191 | + globalThis.fetch = mock(() => | | 192 | + Promise.resolve( | | 193 | + new Response( | | 194 | + JSON.stringify({ | | 195 | + data: [ | | 196 | + { | | 197 | + model_picker_enabled: true, | | 198 | + id: "pdf-model", | | 199 | + name: "PDF Model", | | 200 | + version: "pdf-model-2026-06-01", | | 201 | + capabilities: { | | 202 | + family: "pdf-model", | | 203 | + limits: { | | 204 | + max_context_window_tokens: 128000, | | 205 | + max_output_tokens: 16384, | | 206 | + max_prompt_tokens: 128000, | | 207 | + vision: { | | 208 | + max_prompt_image_size: 10000000, | | 209 | + max_prompt_images: 10, | | 210 | + supported_media_types: ["application/pdf"], | | 211 | + }, | | 212 | + }, | | 213 | + supports: { | | 214 | + streaming: true, | | 215 | + vision: true, | | 216 | + tool_calls: true, | | 217 | + }, | | 218 | + }, | | 219 | + }, | | 220 | + { | | 221 | + model_picker_enabled: true, | | 222 | + id: "vision-only-model", | | 223 | + name: "Vision Only Model", | | 224 | + version: "vision-only-model-2026-06-01", | | 225 | + capabilities: { | | 226 | + family: "vision-only-model", | | 227 | + limits: { | | 228 | + max_context_window_tokens: 128000, | | 229 | + max_output_tokens: 16384, | | 230 | + max_prompt_tokens: 128000, | | 231 | + vision: { | | 232 | + max_prompt_image_size: 10000000, | | 233 | + max_prompt_images: 10, | | 234 | + supported_media_types: ["image/png"], | | 235 | + }, | | 236 | + }, | | 237 | + supports: { | | 238 | + streaming: true, | | 239 | + vision: true, | | 240 | + tool_calls: true, | | 241 | + }, | | 242 | + }, | | 243 | + }, | | 244 | + ], | | 245 | + }), | | 246 | + { status: 200 }, | | 247 | + ), | | 248 | + ), | | 249 | + ) as unknown as typeof fetch | | 250 | + | | 251 | + const models = (await CopilotModels.get("https://api.githubcopilot.com")).models | | 252 | + const model = models["pdf-model"] | | 253 | + | | 254 | + expect(model.capabilities.input.pdf).toBe(true) | | 255 | + expect(models["vision-only-model"].capabilities.input.pdf).toBe(false) | | 256 | +}) | | 257 | + | 190 | 258 | test("uses zero cost when Copilot reports a zero billing batch size", async () => { | 191 | 259 | globalThis.fetch = mock(() => | 192 | 260 | Promise.resolve( | |
|