Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/chunking/common/chunkingEndpointClient.ts
13400 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 { CallTracker } from '../../../util/common/telemetryCorrelationId';
8
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
9
import { URI } from '../../../util/vs/base/common/uri';
10
import { EmbeddingType } from '../../embeddings/common/embeddingsComputer';
11
import { FileChunkWithEmbedding, FileChunkWithOptionalEmbedding } from './chunk';
12
13
14
export class ComputeBatchInfo {
15
recomputedFileCount = 0;
16
sentContentTextLength = 0;
17
}
18
19
export enum EmbeddingsComputeQos {
20
Batch = 'Batch',
21
Online = 'Online',
22
}
23
24
export const IChunkingEndpointClient = createServiceIdentifier<IChunkingEndpointClient>('IChunkingEndpointClient');
25
26
export interface ChunkableContent {
27
readonly uri: URI;
28
29
/**
30
* Overrides the language ID GitHub uses to chunk the file
31
*
32
* If not provided, the language ID will be inferred from path and content of the file.
33
*
34
* Ids can be found in https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml
35
*/
36
readonly githubLanguageId?: number;
37
38
getText(): Promise<string>;
39
}
40
41
42
/**
43
* The chunking and embedding endpoint client.
44
*/
45
export interface IChunkingEndpointClient {
46
readonly _serviceBrand: undefined;
47
48
computeChunks(
49
authToken: string,
50
embeddingType: EmbeddingType,
51
content: ChunkableContent,
52
batchInfo: ComputeBatchInfo,
53
qos: EmbeddingsComputeQos,
54
cache: ReadonlyMap</* hash */string, FileChunkWithEmbedding> | undefined,
55
telemetryInfo: CallTracker,
56
token: CancellationToken,
57
): Promise<readonly FileChunkWithOptionalEmbedding[] | undefined>;
58
59
computeChunksAndEmbeddings(
60
authToken: string,
61
embeddingType: EmbeddingType,
62
content: ChunkableContent,
63
batchInfo: ComputeBatchInfo,
64
qos: EmbeddingsComputeQos,
65
cache: ReadonlyMap</* hash */string, FileChunkWithEmbedding> | undefined,
66
telemetryInfo: CallTracker,
67
token: CancellationToken,
68
): Promise<readonly FileChunkWithEmbedding[] | undefined>;
69
}
70
71