vectra 0.11.0 → 0.12.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/lib/LocalIndex.spec.d.ts.map +1 -0
- package/lib/LocalIndex.spec.js +64 -0
- package/lib/LocalIndex.spec.js.map +1 -0
- package/package.json +8 -3
- package/src/LocalIndex.spec.ts +66 -0
- package/src/LocalIndex.ts +27 -1
- package/src/global.d.ts +1 -0
- 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 -168
- 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 -132
- 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 -328
- package/lib/LocalDocumentResult.js.map +0 -1
- package/lib/LocalIndex.d.ts +0 -139
- package/lib/LocalIndex.d.ts.map +0 -1
- package/lib/LocalIndex.js +0 -476
- 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 -146
- 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 -314
- package/lib/vectra-cli.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalIndex.spec.d.ts","sourceRoot":"","sources":["../src/LocalIndex.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
16
|
+
const LocalIndex_1 = require("./LocalIndex");
|
|
17
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
describe('LocalIndex', () => {
|
|
20
|
+
const testIndexDir = path_1.default.join(__dirname, 'test_index');
|
|
21
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
yield promises_1.default.rm(testIndexDir, { recursive: true, force: true });
|
|
23
|
+
}));
|
|
24
|
+
afterEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
yield promises_1.default.rm(testIndexDir, { recursive: true, force: true });
|
|
26
|
+
}));
|
|
27
|
+
it('should create a new index', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const index = new LocalIndex_1.LocalIndex(testIndexDir);
|
|
29
|
+
yield index.createIndex();
|
|
30
|
+
const created = yield index.isIndexCreated();
|
|
31
|
+
node_assert_1.default.equal(created, true);
|
|
32
|
+
}));
|
|
33
|
+
describe('batchInsertItems', () => {
|
|
34
|
+
const indexItems = [
|
|
35
|
+
{ id: '1', vector: [1, 2, 3] },
|
|
36
|
+
{ id: '2', vector: [2, 3, 4] },
|
|
37
|
+
{ id: '3', vector: [3, 4, 5] }
|
|
38
|
+
];
|
|
39
|
+
it('should insert provided items', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const index = new LocalIndex_1.LocalIndex(testIndexDir);
|
|
41
|
+
yield index.createIndex();
|
|
42
|
+
const newItems = yield index.batchInsertItems(indexItems);
|
|
43
|
+
node_assert_1.default.equal(newItems.length, 3);
|
|
44
|
+
const retrievedItems = yield index.listItems();
|
|
45
|
+
node_assert_1.default.equal(retrievedItems.length, 3);
|
|
46
|
+
}));
|
|
47
|
+
it('on id collision - cancel batch insert & bubble up error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const index = new LocalIndex_1.LocalIndex(testIndexDir);
|
|
49
|
+
yield index.createIndex();
|
|
50
|
+
yield index.insertItem({ id: '2', vector: [9, 9, 9] });
|
|
51
|
+
// ensures insert error is bubbled up to batchIndexItems caller
|
|
52
|
+
yield node_assert_1.default.rejects(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
yield index.batchInsertItems(indexItems);
|
|
54
|
+
}), {
|
|
55
|
+
name: 'Error',
|
|
56
|
+
message: 'Item with id 2 already exists'
|
|
57
|
+
});
|
|
58
|
+
// ensures no partial update is applied
|
|
59
|
+
const storedItems = yield index.listItems();
|
|
60
|
+
node_assert_1.default.equal(storedItems.length, 1);
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=LocalIndex.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalIndex.spec.js","sourceRoot":"","sources":["../src/LocalIndex.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,6CAAyC;AAEzC,2DAA4B;AAC5B,gDAAuB;AAEvB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAExD,UAAU,CAAC,GAAS,EAAE;QACpB,MAAM,kBAAE,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAA,C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YAC/C,qBAAM,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,yDAAyD,EAAE,GAAS,EAAE;YACvE,MAAM,KAAK,GAAG,IAAI,uBAAU,CAAC,YAAY,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;YAE1B,MAAM,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YAEvD,+DAA+D;YAC/D,MAAM,qBAAM,CAAC,OAAO,CAClB,GAAS,EAAE;gBACT,MAAM,KAAK,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAC3C,CAAC,CAAA,EACD;gBACE,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,+BAA+B;aACzC,CACF,CAAC;YAEF,uCAAuC;YACvC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;YAC5C,qBAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "vectra",
|
|
3
3
|
"author": "Steven Ickman",
|
|
4
4
|
"description": "A vector database that uses the local file system for storage.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.12.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"gpt"
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"openai": "^4.97.0",
|
|
39
39
|
"turndown": "^7.2.0",
|
|
40
40
|
"uuid": "^11.1.0",
|
|
41
|
+
"wink-bm25-text-search": "^3.1.2",
|
|
41
42
|
"wink-nlp": "^2.3.2",
|
|
42
43
|
"yargs": "^17.7.2"
|
|
43
44
|
},
|
|
@@ -50,9 +51,12 @@
|
|
|
50
51
|
"@types/uuid": "10.0.0",
|
|
51
52
|
"@types/yargs": "17.0.33",
|
|
52
53
|
"mocha": "11.2.2",
|
|
54
|
+
"npm-run-all": "^4.1.5",
|
|
55
|
+
"rimraf": "^5.0.1",
|
|
53
56
|
"nyc": "^17.1.0",
|
|
54
57
|
"shx": "^0.4.0",
|
|
55
58
|
"ts-mocha": "11.1.0",
|
|
59
|
+
"ts-node": "^10.9.1",
|
|
56
60
|
"typescript": "^5.8.3",
|
|
57
61
|
"wink-bm25-text-search": "^3.1.2"
|
|
58
62
|
},
|
|
@@ -64,12 +68,13 @@
|
|
|
64
68
|
"depcheck": "depcheck --config ../../.depcheckrc",
|
|
65
69
|
"lint": "eslint **/src/**/*.{j,t}s{,x} --fix --no-error-on-unmatched-pattern",
|
|
66
70
|
"test": "npm-run-all build test:mocha",
|
|
67
|
-
"test:mocha": "nyc mocha
|
|
71
|
+
"test:mocha": "nyc ts-mocha src/**/*.spec.ts --timeout 10000",
|
|
68
72
|
"test:compat": "api-extractor run --verbose"
|
|
69
73
|
},
|
|
70
74
|
"files": [
|
|
71
75
|
"_ts3.4",
|
|
72
76
|
"lib",
|
|
73
77
|
"src"
|
|
74
|
-
]
|
|
78
|
+
],
|
|
79
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
75
80
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { LocalIndex } from './LocalIndex'
|
|
3
|
+
import { IndexItem } from './types'
|
|
4
|
+
import fs from 'fs/promises'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
describe('LocalIndex', () => {
|
|
8
|
+
const testIndexDir = path.join(__dirname, 'test_index');
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await fs.rm(testIndexDir, { recursive: true, force: true });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(async () => {
|
|
15
|
+
await fs.rm(testIndexDir, { recursive: true, force: true });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create a new index', async () => {
|
|
19
|
+
const index = new LocalIndex(testIndexDir);
|
|
20
|
+
await index.createIndex();
|
|
21
|
+
const created = await index.isIndexCreated();
|
|
22
|
+
assert.equal(created, true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('batchInsertItems', () => {
|
|
26
|
+
const indexItems: Partial<IndexItem>[] = [
|
|
27
|
+
{ id: '1', vector: [1, 2, 3] },
|
|
28
|
+
{ id: '2', vector: [2, 3, 4] },
|
|
29
|
+
{ id: '3', vector: [3, 4, 5] }
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
it('should insert provided items', async () => {
|
|
33
|
+
const index = new LocalIndex(testIndexDir);
|
|
34
|
+
await index.createIndex();
|
|
35
|
+
|
|
36
|
+
const newItems = await index.batchInsertItems(indexItems);
|
|
37
|
+
|
|
38
|
+
assert.equal(newItems.length, 3);
|
|
39
|
+
|
|
40
|
+
const retrievedItems = await index.listItems();
|
|
41
|
+
assert.equal(retrievedItems.length, 3);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('on id collision - cancel batch insert & bubble up error', async () => {
|
|
45
|
+
const index = new LocalIndex(testIndexDir);
|
|
46
|
+
await index.createIndex();
|
|
47
|
+
|
|
48
|
+
await index.insertItem({ id: '2', vector: [9, 9, 9] });
|
|
49
|
+
|
|
50
|
+
// ensures insert error is bubbled up to batchIndexItems caller
|
|
51
|
+
await assert.rejects(
|
|
52
|
+
async () => {
|
|
53
|
+
await index.batchInsertItems(indexItems);
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Error',
|
|
57
|
+
message: 'Item with id 2 already exists'
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// ensures no partial update is applied
|
|
62
|
+
const storedItems = await index.listItems();
|
|
63
|
+
assert.equal(storedItems.length, 1);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
package/src/LocalIndex.ts
CHANGED
|
@@ -66,7 +66,7 @@ export class LocalIndex<TMetadata extends Record<string,MetadataTypes> = Record<
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
await this.loadIndexData();
|
|
69
|
-
this._update =
|
|
69
|
+
this._update = structuredClone(this._data);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -207,6 +207,32 @@ export class LocalIndex<TMetadata extends Record<string,MetadataTypes> = Record<
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Adds a batch of items to the index.
|
|
212
|
+
* @remarks
|
|
213
|
+
* Batch update requires no update to be in progress. This is necessary so that if any one
|
|
214
|
+
* insert operation fails, the entire update can be safely cancelled. This prevents partial
|
|
215
|
+
* updates from being applied to the local index.
|
|
216
|
+
* @param items Items to insert.
|
|
217
|
+
* @returns Inserted items.
|
|
218
|
+
*/
|
|
219
|
+
public async batchInsertItems<TItemMetadata extends TMetadata = TMetadata>(items: Partial<IndexItem<TItemMetadata>>[]): Promise<IndexItem[]> {
|
|
220
|
+
await this.beginUpdate();
|
|
221
|
+
try {
|
|
222
|
+
const newItems: IndexItem[] = [];
|
|
223
|
+
for (const item of items) {
|
|
224
|
+
const newItem = await this.addItemToUpdate(item, true);
|
|
225
|
+
newItems.push(newItem);
|
|
226
|
+
}
|
|
227
|
+
await this.endUpdate();
|
|
228
|
+
return newItems;
|
|
229
|
+
} catch (e) {
|
|
230
|
+
// cancels this update to prevent partial batch updates. allows error to bubble up.
|
|
231
|
+
await this.cancelUpdate();
|
|
232
|
+
throw e;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
210
236
|
/**
|
|
211
237
|
* Returns true if the index exists.
|
|
212
238
|
*/
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const structuredClone: <T>(value: T) => T;
|
package/lib/FileFetcher.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { TextFetcher } from './types';
|
|
2
|
-
export declare class FileFetcher implements TextFetcher {
|
|
3
|
-
fetch(uri: string, onDocument: (uri: string, text: string, docType?: string | undefined) => Promise<boolean>): Promise<boolean>;
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=FileFetcher.d.ts.map
|
package/lib/FileFetcher.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileFetcher.d.ts","sourceRoot":"","sources":["../src/FileFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,qBAAa,WAAY,YAAW,WAAW;IAC9B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAyB/I"}
|
package/lib/FileFetcher.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.FileFetcher = void 0;
|
|
36
|
-
const fs = __importStar(require("fs/promises"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
class FileFetcher {
|
|
39
|
-
fetch(uri, onDocument) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
// Does path exist and is it a directory?
|
|
42
|
-
let isDirectory;
|
|
43
|
-
try {
|
|
44
|
-
const stat = yield fs.stat(uri);
|
|
45
|
-
isDirectory = stat.isDirectory();
|
|
46
|
-
}
|
|
47
|
-
catch (_a) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
// If directory, read all files and recurse
|
|
51
|
-
if (isDirectory) {
|
|
52
|
-
const files = yield fs.readdir(uri);
|
|
53
|
-
for (const file of files) {
|
|
54
|
-
const filePath = path.join(uri, file);
|
|
55
|
-
yield this.fetch(filePath, onDocument);
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Read file and call onDocument
|
|
61
|
-
const text = yield fs.readFile(uri, 'utf8');
|
|
62
|
-
const parts = uri.split('.');
|
|
63
|
-
return yield onDocument(uri, text, parts.length > 0 ? parts[parts.length - 1].toLowerCase() : undefined);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.FileFetcher = FileFetcher;
|
|
69
|
-
//# sourceMappingURL=FileFetcher.js.map
|
package/lib/FileFetcher.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileFetcher.js","sourceRoot":"","sources":["../src/FileFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAAkC;AAClC,2CAA6B;AAE7B,MAAa,WAAW;IACP,KAAK,CAAC,GAAW,EAAE,UAAyF;;YACrH,yCAAyC;YACzC,IAAI,WAAoB,CAAC;YACzB,IAAI;gBACA,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAChC,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;aACpC;YAAC,WAAM;gBACJ,OAAO,IAAI,CAAC;aACf;YAED,2CAA2C;YAC3C,IAAI,WAAW,EAAE;gBACb,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;oBACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;oBACtC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;iBAC1C;gBACD,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,gCAAgC;gBAChC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC7B,OAAO,MAAM,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;aAC5G;QACL,CAAC;KAAA;CACJ;AA1BD,kCA0BC"}
|
package/lib/GPT3Tokenizer.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Tokenizer } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Tokenizer that uses GPT-3's encoder.
|
|
4
|
-
*/
|
|
5
|
-
export declare class GPT3Tokenizer implements Tokenizer {
|
|
6
|
-
decode(tokens: number[]): string;
|
|
7
|
-
encode(text: string): number[];
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=GPT3Tokenizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GPT3Tokenizer.d.ts","sourceRoot":"","sources":["../src/GPT3Tokenizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC;;GAEG;AACH,qBAAa,aAAc,YAAW,SAAS;IACpC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CAGxC"}
|
package/lib/GPT3Tokenizer.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GPT3Tokenizer = void 0;
|
|
4
|
-
const gpt_3_encoder_1 = require("gpt-3-encoder");
|
|
5
|
-
/**
|
|
6
|
-
* Tokenizer that uses GPT-3's encoder.
|
|
7
|
-
*/
|
|
8
|
-
class GPT3Tokenizer {
|
|
9
|
-
decode(tokens) {
|
|
10
|
-
return (0, gpt_3_encoder_1.decode)(tokens);
|
|
11
|
-
}
|
|
12
|
-
encode(text) {
|
|
13
|
-
return (0, gpt_3_encoder_1.encode)(text);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.GPT3Tokenizer = GPT3Tokenizer;
|
|
17
|
-
//# sourceMappingURL=GPT3Tokenizer.js.map
|
package/lib/GPT3Tokenizer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GPT3Tokenizer.js","sourceRoot":"","sources":["../src/GPT3Tokenizer.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAE/C;;GAEG;AACH,MAAa,aAAa;IACf,MAAM,CAAC,MAAgB;QAC1B,OAAO,IAAA,sBAAM,EAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAEM,MAAM,CAAC,IAAY;QACtB,OAAO,IAAA,sBAAM,EAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACJ;AARD,sCAQC"}
|
package/lib/ItemSelector.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { MetadataFilter, MetadataTypes } from './types';
|
|
2
|
-
export declare class ItemSelector {
|
|
3
|
-
/**
|
|
4
|
-
* Returns the similarity between two vectors using the cosine similarity.
|
|
5
|
-
* @param vector1 Vector 1
|
|
6
|
-
* @param vector2 Vector 2
|
|
7
|
-
* @returns Similarity between the two vectors
|
|
8
|
-
*/
|
|
9
|
-
static cosineSimilarity(vector1: number[], vector2: number[]): number;
|
|
10
|
-
/**
|
|
11
|
-
* Normalizes a vector.
|
|
12
|
-
* @remarks
|
|
13
|
-
* The norm of a vector is the square root of the sum of the squares of the elements.
|
|
14
|
-
* The LocalIndex pre-normalizes all vectors to improve performance.
|
|
15
|
-
* @param vector Vector to normalize
|
|
16
|
-
* @returns Normalized vector
|
|
17
|
-
*/
|
|
18
|
-
static normalize(vector: number[]): number;
|
|
19
|
-
/**
|
|
20
|
-
* Returns the similarity between two vectors using cosine similarity.
|
|
21
|
-
* @remarks
|
|
22
|
-
* The LocalIndex pre-normalizes all vectors to improve performance.
|
|
23
|
-
* This method uses the pre-calculated norms to improve performance.
|
|
24
|
-
* @param vector1 Vector 1
|
|
25
|
-
* @param norm1 Norm of vector 1
|
|
26
|
-
* @param vector2 Vector 2
|
|
27
|
-
* @param norm2 Norm of vector 2
|
|
28
|
-
* @returns Similarity between the two vectors
|
|
29
|
-
*/
|
|
30
|
-
static normalizedCosineSimilarity(vector1: number[], norm1: number, vector2: number[], norm2: number): number;
|
|
31
|
-
/**
|
|
32
|
-
* Applies a filter to the metadata of an item.
|
|
33
|
-
* @param metadata Metadata of the item
|
|
34
|
-
* @param filter Filter to apply
|
|
35
|
-
* @returns True if the item matches the filter, false otherwise
|
|
36
|
-
*/
|
|
37
|
-
static select(metadata: Record<string, MetadataTypes>, filter: MetadataFilter): boolean;
|
|
38
|
-
private static dotProduct;
|
|
39
|
-
private static metadataFilter;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=ItemSelector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSelector.d.ts","sourceRoot":"","sources":["../src/ItemSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,qBAAa,YAAY;IACrB;;;;;OAKG;WACW,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAKnE;;;;;;;OAOG;WACW,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE;IAYxC;;;;;;;;;;OAUG;WACW,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM;IAK3G;;;;;OAKG;WACW,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO;IAoC9F,OAAO,CAAC,MAAM,CAAC,UAAU;IAYzB,OAAO,CAAC,MAAM,CAAC,cAAc;CA+DhC"}
|
package/lib/ItemSelector.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ItemSelector = void 0;
|
|
4
|
-
class ItemSelector {
|
|
5
|
-
/**
|
|
6
|
-
* Returns the similarity between two vectors using the cosine similarity.
|
|
7
|
-
* @param vector1 Vector 1
|
|
8
|
-
* @param vector2 Vector 2
|
|
9
|
-
* @returns Similarity between the two vectors
|
|
10
|
-
*/
|
|
11
|
-
static cosineSimilarity(vector1, vector2) {
|
|
12
|
-
// Return the quotient of the dot product and the product of the norms
|
|
13
|
-
return this.dotProduct(vector1, vector2) / (this.normalize(vector1) * this.normalize(vector2));
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Normalizes a vector.
|
|
17
|
-
* @remarks
|
|
18
|
-
* The norm of a vector is the square root of the sum of the squares of the elements.
|
|
19
|
-
* The LocalIndex pre-normalizes all vectors to improve performance.
|
|
20
|
-
* @param vector Vector to normalize
|
|
21
|
-
* @returns Normalized vector
|
|
22
|
-
*/
|
|
23
|
-
static normalize(vector) {
|
|
24
|
-
// Initialize a variable to store the sum of the squares
|
|
25
|
-
let sum = 0;
|
|
26
|
-
// Loop through the elements of the array
|
|
27
|
-
for (let i = 0; i < vector.length; i++) {
|
|
28
|
-
// Square the element and add it to the sum
|
|
29
|
-
sum += vector[i] * vector[i];
|
|
30
|
-
}
|
|
31
|
-
// Return the square root of the sum
|
|
32
|
-
return Math.sqrt(sum);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Returns the similarity between two vectors using cosine similarity.
|
|
36
|
-
* @remarks
|
|
37
|
-
* The LocalIndex pre-normalizes all vectors to improve performance.
|
|
38
|
-
* This method uses the pre-calculated norms to improve performance.
|
|
39
|
-
* @param vector1 Vector 1
|
|
40
|
-
* @param norm1 Norm of vector 1
|
|
41
|
-
* @param vector2 Vector 2
|
|
42
|
-
* @param norm2 Norm of vector 2
|
|
43
|
-
* @returns Similarity between the two vectors
|
|
44
|
-
*/
|
|
45
|
-
static normalizedCosineSimilarity(vector1, norm1, vector2, norm2) {
|
|
46
|
-
// Return the quotient of the dot product and the product of the norms
|
|
47
|
-
return this.dotProduct(vector1, vector2) / (norm1 * norm2);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Applies a filter to the metadata of an item.
|
|
51
|
-
* @param metadata Metadata of the item
|
|
52
|
-
* @param filter Filter to apply
|
|
53
|
-
* @returns True if the item matches the filter, false otherwise
|
|
54
|
-
*/
|
|
55
|
-
static select(metadata, filter) {
|
|
56
|
-
if (filter === undefined || filter === null) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
for (const key in filter) {
|
|
60
|
-
switch (key) {
|
|
61
|
-
case '$and':
|
|
62
|
-
if (!filter[key].every((f) => this.select(metadata, f))) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
case '$or':
|
|
67
|
-
if (!filter[key].some((f) => this.select(metadata, f))) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
const value = filter[key];
|
|
73
|
-
if (value === undefined || value === null) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
else if (typeof value == 'object') {
|
|
77
|
-
if (!this.metadataFilter(metadata[key], value)) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (metadata[key] !== value) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
static dotProduct(arr1, arr2) {
|
|
92
|
-
// Initialize a variable to store the sum of the products
|
|
93
|
-
let sum = 0;
|
|
94
|
-
// Loop through the elements of the arrays
|
|
95
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
96
|
-
// Multiply the corresponding elements and add them to the sum
|
|
97
|
-
sum += arr1[i] * arr2[i];
|
|
98
|
-
}
|
|
99
|
-
// Return the sum
|
|
100
|
-
return sum;
|
|
101
|
-
}
|
|
102
|
-
static metadataFilter(value, filter) {
|
|
103
|
-
if (value === undefined || value === null) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
for (const key in filter) {
|
|
107
|
-
switch (key) {
|
|
108
|
-
case '$eq':
|
|
109
|
-
if (value !== filter[key]) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
break;
|
|
113
|
-
case '$ne':
|
|
114
|
-
if (value === filter[key]) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
case '$gt':
|
|
119
|
-
if (typeof value != 'number' || value <= filter[key]) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
case '$gte':
|
|
124
|
-
if (typeof value != 'number' || value < filter[key]) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case '$lt':
|
|
129
|
-
if (typeof value != 'number' || value >= filter[key]) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
133
|
-
case '$lte':
|
|
134
|
-
if (typeof value != 'number' || value > filter[key]) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
break;
|
|
138
|
-
case '$in':
|
|
139
|
-
if (typeof value == 'boolean') {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
else if (typeof value == 'string' && !filter[key].includes(value)) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
else if (!filter[key].some(val => typeof val == 'string' && val.includes(value))) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
149
|
-
case '$nin':
|
|
150
|
-
if (typeof value == 'boolean') {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
else if (typeof value == 'string' && filter[key].includes(value)) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
else if (filter[key].some(val => typeof val == 'string' && val.includes(value))) {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
break;
|
|
160
|
-
default:
|
|
161
|
-
return value === filter[key];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.ItemSelector = ItemSelector;
|
|
168
|
-
//# sourceMappingURL=ItemSelector.js.map
|
package/lib/ItemSelector.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSelector.js","sourceRoot":"","sources":["../src/ItemSelector.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IACrB;;;;;OAKG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAAiB,EAAE,OAAiB;QAC/D,sEAAsE;QACtE,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACnG,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,SAAS,C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IAAI,MAAM,CAAC,GAAG,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;wBAC/D,OAAO,KAAK,CAAC;qBAChB;yBACI,IAAI,MAAM,CAAC,GAAG,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAe,CAAC,CAAC,EAAE;wBACxF,OAAO,KAAK,CAAC;qBAChB;oBACD,MAAM;gBACV;oBACI,OAAO,KAAK,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;aACpC;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AArKD,oCAqKC"}
|
package/lib/LocalDocument.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { MetadataTypes } from './types';
|
|
2
|
-
import { LocalDocumentIndex } from './LocalDocumentIndex';
|
|
3
|
-
/**
|
|
4
|
-
* Represents an indexed document stored on disk.
|
|
5
|
-
*/
|
|
6
|
-
export declare class LocalDocument {
|
|
7
|
-
private readonly _index;
|
|
8
|
-
private readonly _id;
|
|
9
|
-
private readonly _uri;
|
|
10
|
-
private _metadata;
|
|
11
|
-
private _text;
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new `LocalDocument` instance.
|
|
14
|
-
* @param index Parent index that contains the document.
|
|
15
|
-
* @param id ID of the document.
|
|
16
|
-
* @param uri URI of the document.
|
|
17
|
-
*/
|
|
18
|
-
constructor(index: LocalDocumentIndex, id: string, uri: string);
|
|
19
|
-
/**
|
|
20
|
-
* Returns the folder path where the document is stored.
|
|
21
|
-
*/
|
|
22
|
-
get folderPath(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the ID of the document.
|
|
25
|
-
*/
|
|
26
|
-
get id(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the URI of the document.
|
|
29
|
-
*/
|
|
30
|
-
get uri(): string;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the length of the document in tokens.
|
|
33
|
-
* @remarks
|
|
34
|
-
* This value will be estimated for documents longer then 40k bytes.
|
|
35
|
-
* @returns Length of the document in tokens.
|
|
36
|
-
*/
|
|
37
|
-
getLength(): Promise<number>;
|
|
38
|
-
/**
|
|
39
|
-
* Determines if the document has additional metadata storred on disk.
|
|
40
|
-
* @returns True if the document has metadata; otherwise, false.
|
|
41
|
-
*/
|
|
42
|
-
hasMetadata(): Promise<boolean>;
|
|
43
|
-
/**
|
|
44
|
-
* Loads the metadata for the document from disk.
|
|
45
|
-
* @returns Metadata for the document.
|
|
46
|
-
*/
|
|
47
|
-
loadMetadata(): Promise<Record<string, MetadataTypes>>;
|
|
48
|
-
/**
|
|
49
|
-
* Loads the text for the document from disk.
|
|
50
|
-
* @returns Text for the document.
|
|
51
|
-
*/
|
|
52
|
-
loadText(): Promise<string>;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=LocalDocument.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalDocument.d.ts","sourceRoot":"","sources":["../src/LocalDocument.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;GAEG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,KAAK,CAAmB;IAEhC;;;;;OAKG;gBACgB,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAMrE;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;IACH,IAAW,EAAE,IAAI,MAAM,CAEtB;IAED;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED;;;;;OAKG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IASzC;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAS5C;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAC,aAAa,CAAC,CAAC;IAmBlE;;;OAGG;IACU,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAW3C"}
|