vectra 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/package.json +7 -6
- package/src/ItemSelector.ts +7 -1
- package/src/LocalDocumentIndex.ts +7 -1
- package/src/LocalDocumentResult.ts +70 -22
- package/src/LocalIndex.ts +70 -3
- package/src/internals/Colorize.ts +3 -3
- package/src/internals/wink-bm25-text-search.d.ts +4 -0
- package/src/types.ts +1 -0
- package/src/vectra-cli.ts +13 -2
- package/lib/FileFetcher.d.ts +0 -5
- package/lib/FileFetcher.d.ts.map +0 -1
- package/lib/FileFetcher.js +0 -69
- package/lib/FileFetcher.js.map +0 -1
- package/lib/GPT3Tokenizer.d.ts +0 -9
- package/lib/GPT3Tokenizer.d.ts.map +0 -1
- package/lib/GPT3Tokenizer.js +0 -17
- package/lib/GPT3Tokenizer.js.map +0 -1
- package/lib/ItemSelector.d.ts +0 -41
- package/lib/ItemSelector.d.ts.map +0 -1
- package/lib/ItemSelector.js +0 -162
- package/lib/ItemSelector.js.map +0 -1
- package/lib/LocalDocument.d.ts +0 -54
- package/lib/LocalDocument.d.ts.map +0 -1
- package/lib/LocalDocument.js +0 -146
- package/lib/LocalDocument.js.map +0 -1
- package/lib/LocalDocumentIndex.d.ts +0 -128
- package/lib/LocalDocumentIndex.d.ts.map +0 -1
- package/lib/LocalDocumentIndex.js +0 -446
- package/lib/LocalDocumentIndex.js.map +0 -1
- package/lib/LocalDocumentResult.d.ts +0 -45
- package/lib/LocalDocumentResult.d.ts.map +0 -1
- package/lib/LocalDocumentResult.js +0 -282
- package/lib/LocalDocumentResult.js.map +0 -1
- package/lib/LocalIndex.d.ts +0 -136
- package/lib/LocalIndex.d.ts.map +0 -1
- package/lib/LocalIndex.js +0 -413
- package/lib/LocalIndex.js.map +0 -1
- package/lib/OpenAIEmbeddings.d.ts +0 -126
- package/lib/OpenAIEmbeddings.d.ts.map +0 -1
- package/lib/OpenAIEmbeddings.js +0 -174
- package/lib/OpenAIEmbeddings.js.map +0 -1
- package/lib/TextSplitter.d.ts +0 -20
- package/lib/TextSplitter.d.ts.map +0 -1
- package/lib/TextSplitter.js +0 -537
- package/lib/TextSplitter.js.map +0 -1
- package/lib/WebFetcher.d.ts +0 -15
- package/lib/WebFetcher.d.ts.map +0 -1
- package/lib/WebFetcher.js +0 -224
- package/lib/WebFetcher.js.map +0 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -28
- package/lib/index.js.map +0 -1
- package/lib/internals/Colorize.d.ts +0 -14
- package/lib/internals/Colorize.d.ts.map +0 -1
- package/lib/internals/Colorize.js +0 -64
- package/lib/internals/Colorize.js.map +0 -1
- package/lib/internals/index.d.ts +0 -3
- package/lib/internals/index.d.ts.map +0 -1
- package/lib/internals/index.js +0 -19
- package/lib/internals/index.js.map +0 -1
- package/lib/internals/types.d.ts +0 -43
- package/lib/internals/types.d.ts.map +0 -1
- package/lib/internals/types.js +0 -3
- package/lib/internals/types.js.map +0 -1
- package/lib/types.d.ts +0 -145
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/vectra-cli.d.ts +0 -2
- package/lib/vectra-cli.d.ts.map +0 -1
- package/lib/vectra-cli.js +0 -303
- package/lib/vectra-cli.js.map +0 -1
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LocalDocumentResult = void 0;
|
|
13
|
-
const LocalDocument_1 = require("./LocalDocument");
|
|
14
|
-
/**
|
|
15
|
-
* Represents a search result for a document stored on disk.
|
|
16
|
-
*/
|
|
17
|
-
class LocalDocumentResult extends LocalDocument_1.LocalDocument {
|
|
18
|
-
/**
|
|
19
|
-
* @private
|
|
20
|
-
* Internal constructor for `LocalDocumentResult` instances.
|
|
21
|
-
*/
|
|
22
|
-
constructor(index, id, uri, chunks, tokenizer) {
|
|
23
|
-
super(index, id, uri);
|
|
24
|
-
this._chunks = chunks;
|
|
25
|
-
this._tokenizer = tokenizer;
|
|
26
|
-
// Compute average score
|
|
27
|
-
let score = 0;
|
|
28
|
-
this._chunks.forEach(chunk => score += chunk.score);
|
|
29
|
-
this._score = score / this._chunks.length;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Returns the chunks of the document that matched the query.
|
|
33
|
-
*/
|
|
34
|
-
get chunks() {
|
|
35
|
-
return this._chunks;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns the average score of the document result.
|
|
39
|
-
*/
|
|
40
|
-
get score() {
|
|
41
|
-
return this._score;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Renders all of the results chunks as spans of text (sections.)
|
|
45
|
-
* @remarks
|
|
46
|
-
* The returned sections will be sorted by document order and limited to maxTokens in length.
|
|
47
|
-
* @param maxTokens Maximum number of tokens per section.
|
|
48
|
-
* @returns Array of rendered text sections.
|
|
49
|
-
*/
|
|
50
|
-
renderAllSections(maxTokens) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
// Load text from disk
|
|
53
|
-
const text = yield this.loadText();
|
|
54
|
-
// Add chunks to a temp array and split any chunks that are longer than maxTokens.
|
|
55
|
-
const chunks = [];
|
|
56
|
-
for (let i = 0; i < this._chunks.length; i++) {
|
|
57
|
-
const chunk = this._chunks[i];
|
|
58
|
-
const startPos = chunk.item.metadata.startPos;
|
|
59
|
-
const endPos = chunk.item.metadata.endPos;
|
|
60
|
-
const chunkText = text.substring(startPos, endPos + 1);
|
|
61
|
-
const tokens = this._tokenizer.encode(chunkText);
|
|
62
|
-
let offset = 0;
|
|
63
|
-
while (offset < tokens.length) {
|
|
64
|
-
const chunkLength = Math.min(maxTokens, tokens.length - offset);
|
|
65
|
-
chunks.push({
|
|
66
|
-
text: this._tokenizer.decode(tokens.slice(offset, offset + chunkLength)),
|
|
67
|
-
startPos: startPos + offset,
|
|
68
|
-
endPos: startPos + offset + chunkLength - 1,
|
|
69
|
-
score: chunk.score,
|
|
70
|
-
tokenCount: chunkLength
|
|
71
|
-
});
|
|
72
|
-
offset += chunkLength;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// Sort chunks by startPos
|
|
76
|
-
const sorted = chunks.sort((a, b) => a.startPos - b.startPos);
|
|
77
|
-
// Generate sections
|
|
78
|
-
const sections = [];
|
|
79
|
-
for (let i = 0; i < sorted.length; i++) {
|
|
80
|
-
const chunk = sorted[i];
|
|
81
|
-
let section = sections[sections.length - 1];
|
|
82
|
-
if (!section || section.tokenCount + chunk.tokenCount > maxTokens) {
|
|
83
|
-
section = {
|
|
84
|
-
chunks: [],
|
|
85
|
-
score: 0,
|
|
86
|
-
tokenCount: 0
|
|
87
|
-
};
|
|
88
|
-
sections.push(section);
|
|
89
|
-
}
|
|
90
|
-
section.chunks.push(chunk);
|
|
91
|
-
section.score += chunk.score;
|
|
92
|
-
section.tokenCount += chunk.tokenCount;
|
|
93
|
-
}
|
|
94
|
-
// Normalize section scores
|
|
95
|
-
sections.forEach(section => section.score /= section.chunks.length);
|
|
96
|
-
// Return final rendered sections
|
|
97
|
-
return sections.map(section => {
|
|
98
|
-
let text = '';
|
|
99
|
-
section.chunks.forEach(chunk => text += chunk.text);
|
|
100
|
-
return {
|
|
101
|
-
text: text,
|
|
102
|
-
tokenCount: section.tokenCount,
|
|
103
|
-
score: section.score
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Renders the top spans of text (sections) of the document based on the query result.
|
|
110
|
-
* @remarks
|
|
111
|
-
* The returned sections will be sorted by relevance and limited to the top `maxSections`.
|
|
112
|
-
* @param maxTokens Maximum number of tokens per section.
|
|
113
|
-
* @param maxSections Maximum number of sections to return.
|
|
114
|
-
* @param overlappingChunks Optional. If true, overlapping chunks of text will be added to each section until the maxTokens is reached.
|
|
115
|
-
* @returns Array of rendered text sections.
|
|
116
|
-
*/
|
|
117
|
-
renderSections(maxTokens, maxSections, overlappingChunks = true) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
// Load text from disk
|
|
120
|
-
const text = yield this.loadText();
|
|
121
|
-
// First check to see if the entire document is shorter than maxTokens
|
|
122
|
-
const length = yield this.getLength();
|
|
123
|
-
if (length <= maxTokens) {
|
|
124
|
-
return [{
|
|
125
|
-
text,
|
|
126
|
-
tokenCount: length,
|
|
127
|
-
score: 1.0
|
|
128
|
-
}];
|
|
129
|
-
}
|
|
130
|
-
// Otherwise, we need to split the document into sections
|
|
131
|
-
// - Add each chunk to a temp array and filter out any chunk that's longer then maxTokens.
|
|
132
|
-
// - Sort the array by startPos to arrange chunks in document order.
|
|
133
|
-
// - Generate a new array of sections by combining chunks until the maxTokens is reached for each section.
|
|
134
|
-
// - Generate an aggregate score for each section by averaging the score of each chunk in the section.
|
|
135
|
-
// - Sort the sections by score and limit to maxSections.
|
|
136
|
-
// - For each remaining section combine adjacent chunks of text.
|
|
137
|
-
// - Dynamically add overlapping chunks of text to each section until the maxTokens is reached.
|
|
138
|
-
const chunks = this._chunks.map(chunk => {
|
|
139
|
-
const startPos = chunk.item.metadata.startPos;
|
|
140
|
-
const endPos = chunk.item.metadata.endPos;
|
|
141
|
-
const chunkText = text.substring(startPos, endPos + 1);
|
|
142
|
-
return {
|
|
143
|
-
text: chunkText,
|
|
144
|
-
startPos,
|
|
145
|
-
endPos,
|
|
146
|
-
score: chunk.score,
|
|
147
|
-
tokenCount: this._tokenizer.encode(chunkText).length
|
|
148
|
-
};
|
|
149
|
-
}).filter(chunk => chunk.tokenCount <= maxTokens).sort((a, b) => a.startPos - b.startPos);
|
|
150
|
-
// Check for no chunks
|
|
151
|
-
if (chunks.length === 0) {
|
|
152
|
-
// Take the top chunk and return a subset of its text
|
|
153
|
-
const topChunk = this._chunks[0];
|
|
154
|
-
const startPos = topChunk.item.metadata.startPos;
|
|
155
|
-
const endPos = topChunk.item.metadata.endPos;
|
|
156
|
-
const chunkText = text.substring(startPos, endPos + 1);
|
|
157
|
-
const tokens = this._tokenizer.encode(chunkText);
|
|
158
|
-
return [{
|
|
159
|
-
text: this._tokenizer.decode(tokens.slice(0, maxTokens)),
|
|
160
|
-
tokenCount: maxTokens,
|
|
161
|
-
score: topChunk.score
|
|
162
|
-
}];
|
|
163
|
-
}
|
|
164
|
-
// Generate sections
|
|
165
|
-
const sections = [];
|
|
166
|
-
for (let i = 0; i < chunks.length; i++) {
|
|
167
|
-
const chunk = chunks[i];
|
|
168
|
-
let section = sections[sections.length - 1];
|
|
169
|
-
if (!section || section.tokenCount + chunk.tokenCount > maxTokens) {
|
|
170
|
-
section = {
|
|
171
|
-
chunks: [],
|
|
172
|
-
score: 0,
|
|
173
|
-
tokenCount: 0
|
|
174
|
-
};
|
|
175
|
-
sections.push(section);
|
|
176
|
-
}
|
|
177
|
-
section.chunks.push(chunk);
|
|
178
|
-
section.score += chunk.score;
|
|
179
|
-
section.tokenCount += chunk.tokenCount;
|
|
180
|
-
}
|
|
181
|
-
// Normalize section scores
|
|
182
|
-
sections.forEach(section => section.score /= section.chunks.length);
|
|
183
|
-
// Sort sections by score and limit to maxSections
|
|
184
|
-
sections.sort((a, b) => b.score - a.score);
|
|
185
|
-
if (sections.length > maxSections) {
|
|
186
|
-
sections.splice(maxSections, sections.length - maxSections);
|
|
187
|
-
}
|
|
188
|
-
// Combine adjacent chunks of text
|
|
189
|
-
sections.forEach(section => {
|
|
190
|
-
for (let i = 0; i < section.chunks.length - 1; i++) {
|
|
191
|
-
const chunk = section.chunks[i];
|
|
192
|
-
const nextChunk = section.chunks[i + 1];
|
|
193
|
-
if (chunk.endPos + 1 === nextChunk.startPos) {
|
|
194
|
-
chunk.text += nextChunk.text;
|
|
195
|
-
chunk.endPos = nextChunk.endPos;
|
|
196
|
-
chunk.tokenCount += nextChunk.tokenCount;
|
|
197
|
-
section.chunks.splice(i + 1, 1);
|
|
198
|
-
i--;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
// Add overlapping chunks of text to each section until the maxTokens is reached
|
|
203
|
-
if (overlappingChunks) {
|
|
204
|
-
const connector = {
|
|
205
|
-
text: '\n\n...\n\n',
|
|
206
|
-
startPos: -1,
|
|
207
|
-
endPos: -1,
|
|
208
|
-
score: 0,
|
|
209
|
-
tokenCount: this._tokenizer.encode('\n\n...\n\n').length
|
|
210
|
-
};
|
|
211
|
-
sections.forEach(section => {
|
|
212
|
-
// Insert connectors between chunks
|
|
213
|
-
if (section.chunks.length > 1) {
|
|
214
|
-
for (let i = 0; i < section.chunks.length - 1; i++) {
|
|
215
|
-
section.chunks.splice(i + 1, 0, connector);
|
|
216
|
-
section.tokenCount += connector.tokenCount;
|
|
217
|
-
i++;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
// Add chunks to beginning and end of the section until maxTokens is reached
|
|
221
|
-
let budget = maxTokens - section.tokenCount;
|
|
222
|
-
if (budget > 40) {
|
|
223
|
-
const sectionStart = section.chunks[0].startPos;
|
|
224
|
-
const sectionEnd = section.chunks[section.chunks.length - 1].endPos;
|
|
225
|
-
if (sectionStart > 0) {
|
|
226
|
-
const beforeTex = text.substring(0, section.chunks[0].startPos);
|
|
227
|
-
const beforeTokens = this.encodeBeforeText(beforeTex, Math.ceil(budget / 2));
|
|
228
|
-
const beforeBudget = sectionEnd < text.length - 1 ? Math.min(beforeTokens.length, Math.ceil(budget / 2)) : Math.min(beforeTokens.length, budget);
|
|
229
|
-
const chunk = {
|
|
230
|
-
text: this._tokenizer.decode(beforeTokens.slice(-beforeBudget)),
|
|
231
|
-
startPos: sectionStart - beforeBudget,
|
|
232
|
-
endPos: sectionStart - 1,
|
|
233
|
-
score: 0,
|
|
234
|
-
tokenCount: beforeBudget
|
|
235
|
-
};
|
|
236
|
-
section.chunks.unshift(chunk);
|
|
237
|
-
section.tokenCount += chunk.tokenCount;
|
|
238
|
-
budget -= chunk.tokenCount;
|
|
239
|
-
}
|
|
240
|
-
if (sectionEnd < text.length - 1) {
|
|
241
|
-
const afterText = text.substring(sectionEnd + 1);
|
|
242
|
-
const afterTokens = this.encodeAfterText(afterText, budget);
|
|
243
|
-
const afterBudget = Math.min(afterTokens.length, budget);
|
|
244
|
-
const chunk = {
|
|
245
|
-
text: this._tokenizer.decode(afterTokens.slice(0, afterBudget)),
|
|
246
|
-
startPos: sectionEnd + 1,
|
|
247
|
-
endPos: sectionEnd + afterBudget,
|
|
248
|
-
score: 0,
|
|
249
|
-
tokenCount: afterBudget
|
|
250
|
-
};
|
|
251
|
-
section.chunks.push(chunk);
|
|
252
|
-
section.tokenCount += chunk.tokenCount;
|
|
253
|
-
budget -= chunk.tokenCount;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
// Return final rendered sections
|
|
259
|
-
return sections.map(section => {
|
|
260
|
-
let text = '';
|
|
261
|
-
section.chunks.forEach(chunk => text += chunk.text);
|
|
262
|
-
return {
|
|
263
|
-
text: text,
|
|
264
|
-
tokenCount: section.tokenCount,
|
|
265
|
-
score: section.score
|
|
266
|
-
};
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
encodeBeforeText(text, budget) {
|
|
271
|
-
const maxLength = budget * 8;
|
|
272
|
-
const substr = text.length <= maxLength ? text : text.substring(text.length - maxLength);
|
|
273
|
-
return this._tokenizer.encode(substr);
|
|
274
|
-
}
|
|
275
|
-
encodeAfterText(text, budget) {
|
|
276
|
-
const maxLength = budget * 8;
|
|
277
|
-
const substr = text.length <= maxLength ? text : text.substring(0, maxLength);
|
|
278
|
-
return this._tokenizer.encode(substr);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
exports.LocalDocumentResult = LocalDocumentResult;
|
|
282
|
-
//# sourceMappingURL=LocalDocumentResult.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalDocumentResult.js","sourceRoot":"","sources":["../src/LocalDocumentResult.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAAgD;AAIhD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,6BAAa;IAKlD;;;OAGG;IACH,YAAmB,KAAyB,EAAE,EAAU,EAAE,GAAW,EAAE,MAA4C,EAAE,SAAoB;QACrI,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,wBAAwB;QACxB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACU,iBAAiB,CAAC,SAA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AAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEO,eAAe,CAAC,IAAY,EAAE,MAAc;QAChD,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;CAEJ;AA/RD,kDA+RC"}
|
package/lib/LocalIndex.d.ts
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { IndexItem, IndexStats, MetadataFilter, MetadataTypes, QueryResult } from './types';
|
|
2
|
-
export interface CreateIndexConfig {
|
|
3
|
-
version: number;
|
|
4
|
-
deleteIfExists?: boolean;
|
|
5
|
-
metadata_config?: {
|
|
6
|
-
indexed?: string[];
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Local vector index instance.
|
|
11
|
-
* @remarks
|
|
12
|
-
* This class is used to create, update, and query a local vector index.
|
|
13
|
-
* Each index is a folder on disk containing an index.json file and an optional set of metadata files.
|
|
14
|
-
*/
|
|
15
|
-
export declare class LocalIndex<TMetadata extends Record<string, MetadataTypes> = Record<string, MetadataTypes>> {
|
|
16
|
-
private readonly _folderPath;
|
|
17
|
-
private readonly _indexName;
|
|
18
|
-
private _data?;
|
|
19
|
-
private _update?;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new instance of LocalIndex.
|
|
22
|
-
* @param folderPath Path to the index folder.
|
|
23
|
-
* @param indexName Optional name of the index file. Defaults to index.json.
|
|
24
|
-
*/
|
|
25
|
-
constructor(folderPath: string, indexName?: string);
|
|
26
|
-
/**
|
|
27
|
-
* Path to the index folder.
|
|
28
|
-
*/
|
|
29
|
-
get folderPath(): string;
|
|
30
|
-
/**
|
|
31
|
-
* Optional name of the index file.
|
|
32
|
-
*/
|
|
33
|
-
get indexName(): string;
|
|
34
|
-
/**
|
|
35
|
-
* Begins an update to the index.
|
|
36
|
-
* @remarks
|
|
37
|
-
* This method loads the index into memory and prepares it for updates.
|
|
38
|
-
*/
|
|
39
|
-
beginUpdate(): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Cancels an update to the index.
|
|
42
|
-
* @remarks
|
|
43
|
-
* This method discards any changes made to the index since the update began.
|
|
44
|
-
*/
|
|
45
|
-
cancelUpdate(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Creates a new index.
|
|
48
|
-
* @remarks
|
|
49
|
-
* This method creates a new folder on disk containing an index.json file.
|
|
50
|
-
* @param config Index configuration.
|
|
51
|
-
*/
|
|
52
|
-
createIndex(config?: CreateIndexConfig): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Deletes the index.
|
|
55
|
-
* @remarks
|
|
56
|
-
* This method deletes the index folder from disk.
|
|
57
|
-
*/
|
|
58
|
-
deleteIndex(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Deletes an item from the index.
|
|
61
|
-
* @param id ID of item to delete.
|
|
62
|
-
*/
|
|
63
|
-
deleteItem(id: string): Promise<void>;
|
|
64
|
-
/**
|
|
65
|
-
* Ends an update to the index.
|
|
66
|
-
* @remarks
|
|
67
|
-
* This method saves the index to disk.
|
|
68
|
-
*/
|
|
69
|
-
endUpdate(): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Loads an index from disk and returns its stats.
|
|
72
|
-
* @returns Index stats.
|
|
73
|
-
*/
|
|
74
|
-
getIndexStats(): Promise<IndexStats>;
|
|
75
|
-
/**
|
|
76
|
-
* Returns an item from the index given its ID.
|
|
77
|
-
* @param id ID of the item to retrieve.
|
|
78
|
-
* @returns Item or undefined if not found.
|
|
79
|
-
*/
|
|
80
|
-
getItem<TItemMetadata extends TMetadata = TMetadata>(id: string): Promise<IndexItem<TItemMetadata> | undefined>;
|
|
81
|
-
/**
|
|
82
|
-
* Adds an item to the index.
|
|
83
|
-
* @remarks
|
|
84
|
-
* A new update is started if one is not already in progress. If an item with the same ID
|
|
85
|
-
* already exists, an error will be thrown.
|
|
86
|
-
* @param item Item to insert.
|
|
87
|
-
* @returns Inserted item.
|
|
88
|
-
*/
|
|
89
|
-
insertItem<TItemMetadata extends TMetadata = TMetadata>(item: Partial<IndexItem<TItemMetadata>>): Promise<IndexItem<TItemMetadata>>;
|
|
90
|
-
/**
|
|
91
|
-
* Returns true if the index exists.
|
|
92
|
-
*/
|
|
93
|
-
isIndexCreated(): Promise<boolean>;
|
|
94
|
-
/**
|
|
95
|
-
* Returns all items in the index.
|
|
96
|
-
* @remarks
|
|
97
|
-
* This method loads the index into memory and returns all its items. A copy of the items
|
|
98
|
-
* array is returned so no modifications should be made to the array.
|
|
99
|
-
* @returns Array of all items in the index.
|
|
100
|
-
*/
|
|
101
|
-
listItems<TItemMetadata extends TMetadata = TMetadata>(): Promise<IndexItem<TItemMetadata>[]>;
|
|
102
|
-
/**
|
|
103
|
-
* Returns all items in the index matching the filter.
|
|
104
|
-
* @remarks
|
|
105
|
-
* This method loads the index into memory and returns all its items matching the filter.
|
|
106
|
-
* @param filter Filter to apply.
|
|
107
|
-
* @returns Array of items matching the filter.
|
|
108
|
-
*/
|
|
109
|
-
listItemsByMetadata<TItemMetadata extends TMetadata = TMetadata>(filter: MetadataFilter): Promise<IndexItem<TItemMetadata>[]>;
|
|
110
|
-
/**
|
|
111
|
-
* Finds the top k items in the index that are most similar to the vector.
|
|
112
|
-
* @remarks
|
|
113
|
-
* This method loads the index into memory and returns the top k items that are most similar.
|
|
114
|
-
* An optional filter can be applied to the metadata of the items.
|
|
115
|
-
* @param vector Vector to query against.
|
|
116
|
-
* @param topK Number of items to return.
|
|
117
|
-
* @param filter Optional. Filter to apply.
|
|
118
|
-
* @returns Similar items to the vector that matche the supplied filter.
|
|
119
|
-
*/
|
|
120
|
-
queryItems<TItemMetadata extends TMetadata = TMetadata>(vector: number[], topK: number, filter?: MetadataFilter): Promise<QueryResult<TItemMetadata>[]>;
|
|
121
|
-
/**
|
|
122
|
-
* Adds or replaces an item in the index.
|
|
123
|
-
* @remarks
|
|
124
|
-
* A new update is started if one is not already in progress. If an item with the same ID
|
|
125
|
-
* already exists, it will be replaced.
|
|
126
|
-
* @param item Item to insert or replace.
|
|
127
|
-
* @returns Upserted item.
|
|
128
|
-
*/
|
|
129
|
-
upsertItem<TItemMetadata extends TMetadata = TMetadata>(item: Partial<IndexItem<TItemMetadata>>): Promise<IndexItem<TItemMetadata>>;
|
|
130
|
-
/**
|
|
131
|
-
* Ensures that the index has been loaded into memory.
|
|
132
|
-
*/
|
|
133
|
-
protected loadIndexData(): Promise<void>;
|
|
134
|
-
private addItemToUpdate;
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=LocalIndex.d.ts.map
|
package/lib/LocalIndex.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalIndex.d.ts","sourceRoot":"","sources":["../src/LocalIndex.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE5F,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE;QACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACL;AAED;;;;;GAKG;AACH,qBAAa,UAAU,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,EAAC,aAAa,CAAC;IACjG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,OAAO,CAAC,KAAK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