Path: blob/main/extensions/copilot/src/platform/image/common/imageService.ts
13401 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { createServiceIdentifier } from '../../../util/common/services';6import { URI } from '../../../util/vs/base/common/uri';78export const IImageService = createServiceIdentifier<IImageService>('IImageService');910export interface IImageService {11readonly _serviceBrand: undefined;1213/**14* Upload image data to GitHub Copilot chat attachments endpoint15* @param binaryData The image binary data as Uint8Array16* @param name The name for the uploaded file17* @param mimeType The MIME type of the image18* @param token The authentication token for GitHub API19* @returns Promise<URI> The URI of the uploaded image20*/21uploadChatImageAttachment(binaryData: Uint8Array, name: string, mimeType: string | undefined, token: string | undefined): Promise<URI>;2223/**24* Resize an image to reduce token consumption when sending to language models.25* Returns the original data and MIME type unchanged if resizing is not available or fails.26* The output MIME type may differ from the input (e.g. GIF/WebP inputs are re-encoded as PNG).27*/28resizeImage(data: Uint8Array, mimeType: string): Promise<{ data: Uint8Array; mimeType: string }>;29}3031export const nullImageService: IImageService = {32_serviceBrand: undefined,33async uploadChatImageAttachment(): Promise<URI> {34throw new Error('Image service not implemented');35},36async resizeImage(data: Uint8Array, mimeType: string): Promise<{ data: Uint8Array; mimeType: string }> {37return { data, mimeType };38}39};404142