Skip to content

Commit 5eb87d8

Browse files
committed
feat: prepare VS Code LM API for image support
- Updated VS Code engine requirement to 1.95.0 for image API support - Added TODO comment in vscode-lm.ts for future image capability detection - Improved image placeholder messages in convertToVsCodeLmMessages - Updated tests to match new placeholder format This prepares the codebase for when VS Code fully exposes the image support capabilities through the LanguageModelChat interface.
1 parent 87b45de commit 5eb87d8

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

pnpm-lock.yaml

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/providers/vscode-lm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,10 @@ export class VsCodeLmHandler extends BaseProvider implements SingleCompletionHan
510510
typeof this.client.maxInputTokens === "number"
511511
? Math.max(0, this.client.maxInputTokens)
512512
: openAiModelInfoSaneDefaults.contextWindow,
513-
supportsImages: false, // VSCode Language Model API currently doesn't support image inputs
513+
// TODO: Enable image support when VS Code LM API provides capability detection
514+
// The newer VS Code API (1.95+) includes LanguageModelChatInformation.capabilities.imageInput
515+
// but it's not directly accessible from the LanguageModelChat interface yet
516+
supportsImages: false,
514517
supportsPromptCache: true,
515518
inputPrice: 0,
516519
outputPrice: 0,

src/api/transform/__tests__/vscode-lm-format.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ describe("convertToVsCodeLmMessages", () => {
170170

171171
expect(result).toHaveLength(1)
172172
const imagePlaceholder = result[0].content[1] as MockLanguageModelTextPart
173-
expect(imagePlaceholder.value).toContain("[Image (base64): image/png not supported by VSCode LM API]")
173+
expect(imagePlaceholder.value).toContain(
174+
"[Image placeholder: base64 (image/png) - VS Code LM API image support pending]",
175+
)
174176
})
175177
})
176178

src/api/transform/vscode-lm-format.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ export function convertToVsCodeLmMessages(
8585
// Convert non-tool messages to TextParts after tool messages
8686
...nonToolMessages.map((part) => {
8787
if (part.type === "image") {
88+
// TODO: When VS Code LM API adds LanguageModelImagePart support, convert images properly
89+
// For now, we provide a placeholder text description
90+
const imageType = part.source?.type || "unknown"
91+
const mediaType = part.source?.media_type || "unknown"
8892
return new vscode.LanguageModelTextPart(
89-
`[Image (${part.source?.type || "Unknown source-type"}): ${part.source?.media_type || "unknown media-type"} not supported by VSCode LM API]`,
93+
`[Image placeholder: ${imageType} (${mediaType}) - VS Code LM API image support pending]`,
9094
)
9195
}
9296
return new vscode.LanguageModelTextPart(part.text)
@@ -129,7 +133,10 @@ export function convertToVsCodeLmMessages(
129133
// Convert non-tool messages to TextParts after tool messages
130134
...nonToolMessages.map((part) => {
131135
if (part.type === "image") {
132-
return new vscode.LanguageModelTextPart("[Image generation not supported by VSCode LM API]")
136+
// Assistant-generated images are not yet supported
137+
return new vscode.LanguageModelTextPart(
138+
"[Image generation not yet supported by VS Code LM API]",
139+
)
133140
}
134141
return new vscode.LanguageModelTextPart(part.text)
135142
}),

src/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"theme": "dark"
1111
},
1212
"engines": {
13-
"vscode": "^1.84.0",
13+
"vscode": "^1.95.0",
1414
"node": "20.19.2"
1515
},
1616
"author": {
@@ -531,7 +531,7 @@
531531
"@types/string-similarity": "^4.0.2",
532532
"@types/tmp": "^0.2.6",
533533
"@types/turndown": "^5.0.5",
534-
"@types/vscode": "^1.84.0",
534+
"@types/vscode": "^1.104.0",
535535
"@vscode/test-electron": "^2.5.2",
536536
"@vscode/vsce": "3.3.2",
537537
"esbuild": "^0.25.0",

0 commit comments

Comments
 (0)