Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/image/common/imageService.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { createServiceIdentifier } from '../../../util/common/services';
7
import { URI } from '../../../util/vs/base/common/uri';
8
9
export const IImageService = createServiceIdentifier<IImageService>('IImageService');
10
11
export interface IImageService {
12
readonly _serviceBrand: undefined;
13
14
/**
15
* Upload image data to GitHub Copilot chat attachments endpoint
16
* @param binaryData The image binary data as Uint8Array
17
* @param name The name for the uploaded file
18
* @param mimeType The MIME type of the image
19
* @param token The authentication token for GitHub API
20
* @returns Promise<URI> The URI of the uploaded image
21
*/
22
uploadChatImageAttachment(binaryData: Uint8Array, name: string, mimeType: string | undefined, token: string | undefined): Promise<URI>;
23
24
/**
25
* Resize an image to reduce token consumption when sending to language models.
26
* Returns the original data and MIME type unchanged if resizing is not available or fails.
27
* The output MIME type may differ from the input (e.g. GIF/WebP inputs are re-encoded as PNG).
28
*/
29
resizeImage(data: Uint8Array, mimeType: string): Promise<{ data: Uint8Array; mimeType: string }>;
30
}
31
32
export const nullImageService: IImageService = {
33
_serviceBrand: undefined,
34
async uploadChatImageAttachment(): Promise<URI> {
35
throw new Error('Image service not implemented');
36
},
37
async resizeImage(data: Uint8Array, mimeType: string): Promise<{ data: Uint8Array; mimeType: string }> {
38
return { data, mimeType };
39
}
40
};
41
42