Path: blob/main/extensions/copilot/src/platform/chunking/common/chunkingEndpointClient.ts
13400 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 { CallTracker } from '../../../util/common/telemetryCorrelationId';7import { CancellationToken } from '../../../util/vs/base/common/cancellation';8import { URI } from '../../../util/vs/base/common/uri';9import { EmbeddingType } from '../../embeddings/common/embeddingsComputer';10import { FileChunkWithEmbedding, FileChunkWithOptionalEmbedding } from './chunk';111213export class ComputeBatchInfo {14recomputedFileCount = 0;15sentContentTextLength = 0;16}1718export enum EmbeddingsComputeQos {19Batch = 'Batch',20Online = 'Online',21}2223export const IChunkingEndpointClient = createServiceIdentifier<IChunkingEndpointClient>('IChunkingEndpointClient');2425export interface ChunkableContent {26readonly uri: URI;2728/**29* Overrides the language ID GitHub uses to chunk the file30*31* If not provided, the language ID will be inferred from path and content of the file.32*33* Ids can be found in https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml34*/35readonly githubLanguageId?: number;3637getText(): Promise<string>;38}394041/**42* The chunking and embedding endpoint client.43*/44export interface IChunkingEndpointClient {45readonly _serviceBrand: undefined;4647computeChunks(48authToken: string,49embeddingType: EmbeddingType,50content: ChunkableContent,51batchInfo: ComputeBatchInfo,52qos: EmbeddingsComputeQos,53cache: ReadonlyMap</* hash */string, FileChunkWithEmbedding> | undefined,54telemetryInfo: CallTracker,55token: CancellationToken,56): Promise<readonly FileChunkWithOptionalEmbedding[] | undefined>;5758computeChunksAndEmbeddings(59authToken: string,60embeddingType: EmbeddingType,61content: ChunkableContent,62batchInfo: ComputeBatchInfo,63qos: EmbeddingsComputeQos,64cache: ReadonlyMap</* hash */string, FileChunkWithEmbedding> | undefined,65telemetryInfo: CallTracker,66token: CancellationToken,67): Promise<readonly FileChunkWithEmbedding[] | undefined>;68}697071