Skip to content

Commit 0d69b37

Browse files
committed
refactor: Conditionally set copilot-vision-request header
1 parent 7d84220 commit 0d69b37

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/lib/api-config.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,26 @@ const API_VERSION = "2025-04-01"
1515

1616
export const copilotBaseUrl = (state: State) =>
1717
`https://api.${state.accountType}.githubcopilot.com`
18-
export const copilotHeaders = (state: State) => ({
19-
Authorization: `Bearer ${state.copilotToken}`,
20-
"content-type": standardHeaders()["content-type"],
21-
"copilot-integration-id": "vscode-chat",
22-
"editor-version": `vscode/${state.vsCodeVersion}`,
23-
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
24-
"user-agent": USER_AGENT,
25-
"openai-intent": "conversation-panel",
26-
"x-github-api-version": API_VERSION,
27-
"x-request-id": randomUUID(),
28-
"x-vscode-user-agent-library-version": "electron-fetch",
29-
"copilot-vision-request": state.visionEnabled ? "true" : "false",
30-
})
18+
export const copilotHeaders = (state: State) => {
19+
const headers: Record<string, string> = {
20+
Authorization: `Bearer ${state.copilotToken}`,
21+
"content-type": standardHeaders()["content-type"],
22+
"copilot-integration-id": "vscode-chat",
23+
"editor-version": `vscode/${state.vsCodeVersion}`,
24+
"editor-plugin-version": EDITOR_PLUGIN_VERSION,
25+
"user-agent": USER_AGENT,
26+
"openai-intent": "conversation-panel",
27+
"x-github-api-version": API_VERSION,
28+
"x-request-id": randomUUID(),
29+
"x-vscode-user-agent-library-version": "electron-fetch",
30+
}
31+
32+
if (state.visionEnabled) {
33+
headers["copilot-vision-request"] = "true"
34+
}
35+
36+
return headers
37+
}
3138

3239
export const GITHUB_API_BASE_URL = "https://api.github.com"
3340
export const githubHeaders = (state: State) => ({

0 commit comments

Comments
 (0)