Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/chunking/common/chunk.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 { URI } from '../../../util/vs/base/common/uri';
7
import { Range } from '../../../util/vs/editor/common/core/range';
8
import { Embedding, EmbeddingDistance } from '../../embeddings/common/embeddingsComputer';
9
10
export interface Chunk {
11
/**
12
* The text content of the chunk.
13
*/
14
readonly text: string;
15
}
16
17
/**
18
* A single {@linkcode Chunk} from a file.
19
*
20
* File chunk {@linkcode Chunk.text text} may include `...` style markup for emitted and additional prefix and suffix text that provide context.
21
*/
22
export interface FileChunk extends Chunk {
23
24
/**
25
* Just the code in the chunk's range, without any additional prefix or suffix.
26
*/
27
readonly rawText: string | undefined;
28
29
/**
30
* File this chunk came from from.
31
*/
32
readonly file: URI;
33
34
/**
35
* The primary range the chunk was taken from.
36
*/
37
readonly range: Range;
38
39
/**
40
* Whether the chunk represents the whole file.
41
*/
42
readonly isFullFile?: boolean;
43
}
44
45
export interface FileChunkAndScore<T extends FileChunk = FileChunk> {
46
readonly chunk: T;
47
readonly distance: EmbeddingDistance | undefined;
48
}
49
50
export type FileChunkWithOptionalEmbedding = {
51
readonly chunk: FileChunk;
52
readonly chunkHash: string | undefined;
53
readonly embedding: Embedding | undefined;
54
};
55
56
export type FileChunkWithEmbedding = {
57
readonly chunk: FileChunk;
58
readonly embedding: Embedding;
59
readonly chunkHash: string | undefined;
60
};
61
62