Path: blob/main/extensions/copilot/src/platform/chunking/common/chunk.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 { URI } from '../../../util/vs/base/common/uri';6import { Range } from '../../../util/vs/editor/common/core/range';7import { Embedding, EmbeddingDistance } from '../../embeddings/common/embeddingsComputer';89export interface Chunk {10/**11* The text content of the chunk.12*/13readonly text: string;14}1516/**17* A single {@linkcode Chunk} from a file.18*19* File chunk {@linkcode Chunk.text text} may include `...` style markup for emitted and additional prefix and suffix text that provide context.20*/21export interface FileChunk extends Chunk {2223/**24* Just the code in the chunk's range, without any additional prefix or suffix.25*/26readonly rawText: string | undefined;2728/**29* File this chunk came from from.30*/31readonly file: URI;3233/**34* The primary range the chunk was taken from.35*/36readonly range: Range;3738/**39* Whether the chunk represents the whole file.40*/41readonly isFullFile?: boolean;42}4344export interface FileChunkAndScore<T extends FileChunk = FileChunk> {45readonly chunk: T;46readonly distance: EmbeddingDistance | undefined;47}4849export type FileChunkWithOptionalEmbedding = {50readonly chunk: FileChunk;51readonly chunkHash: string | undefined;52readonly embedding: Embedding | undefined;53};5455export type FileChunkWithEmbedding = {56readonly chunk: FileChunk;57readonly embedding: Embedding;58readonly chunkHash: string | undefined;59};606162