endee-llamaindex 1.0.1 → 1.0.2
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/dist/endeeClient.d.ts +8 -5
- package/dist/endeeClient.js +10 -15
- package/package.json +1 -1
package/dist/endeeClient.d.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
+
import type { Index, Endee } from "endee";
|
|
1
2
|
import { BaseNode, BaseVectorStore, Metadata, VectorStoreBaseParams, VectorStoreQuery, VectorStoreQueryResult } from "llamaindex";
|
|
2
3
|
type EndeeParams = {
|
|
3
4
|
indexName: string;
|
|
4
5
|
authToken: string;
|
|
5
6
|
chunkSize?: number;
|
|
7
|
+
textKey?: string;
|
|
6
8
|
} & VectorStoreBaseParams;
|
|
7
9
|
export declare class EndeeVectorStore extends BaseVectorStore {
|
|
8
10
|
storesText: boolean;
|
|
9
11
|
private authToken;
|
|
10
12
|
private indexName;
|
|
11
13
|
private chunkSize;
|
|
12
|
-
private db
|
|
14
|
+
private db?;
|
|
15
|
+
private textKey;
|
|
13
16
|
constructor(params: EndeeParams);
|
|
14
17
|
private getDB;
|
|
15
|
-
client():
|
|
16
|
-
index(): Promise<
|
|
18
|
+
client(): Promise<Endee>;
|
|
19
|
+
index(): Promise<Index>;
|
|
17
20
|
add(embeddingResults: BaseNode<Metadata>[]): Promise<string[]>;
|
|
18
|
-
protected saveChunk(idx:
|
|
21
|
+
protected saveChunk(idx: Index, chunk: any): Promise<boolean>;
|
|
19
22
|
nodeToRecord(node: BaseNode<Metadata>): {
|
|
20
23
|
id: string;
|
|
21
24
|
vector: number[];
|
|
22
25
|
meta: Metadata;
|
|
23
26
|
};
|
|
24
27
|
query(query: VectorStoreQuery, _options?: object): Promise<VectorStoreQueryResult>;
|
|
25
|
-
delete(refDocId: string
|
|
28
|
+
delete(refDocId: string): Promise<void>;
|
|
26
29
|
}
|
|
27
30
|
export {};
|
package/dist/endeeClient.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Endee } from "endee";
|
|
2
1
|
import { BaseVectorStore, metadataDictToNode, nodeToMetadata, } from "llamaindex";
|
|
3
2
|
export class EndeeVectorStore extends BaseVectorStore {
|
|
4
3
|
constructor(params) {
|
|
@@ -7,21 +6,21 @@ export class EndeeVectorStore extends BaseVectorStore {
|
|
|
7
6
|
this.authToken = params.authToken;
|
|
8
7
|
this.indexName = params.indexName;
|
|
9
8
|
this.chunkSize = params.chunkSize ?? 100;
|
|
10
|
-
this.
|
|
9
|
+
this.textKey = params.textKey ?? "text";
|
|
11
10
|
}
|
|
12
|
-
getDB() {
|
|
11
|
+
async getDB() {
|
|
13
12
|
if (!this.db) {
|
|
13
|
+
const { Endee } = await import("endee");
|
|
14
14
|
this.db = new Endee(this.authToken);
|
|
15
15
|
}
|
|
16
|
-
return this.db;
|
|
16
|
+
return Promise.resolve(this.db);
|
|
17
17
|
}
|
|
18
18
|
client() {
|
|
19
19
|
return this.getDB();
|
|
20
20
|
}
|
|
21
21
|
async index() {
|
|
22
|
-
const db = this.getDB();
|
|
23
|
-
|
|
24
|
-
return index;
|
|
22
|
+
const db = await this.getDB();
|
|
23
|
+
return await db.getIndex(this.indexName);
|
|
25
24
|
}
|
|
26
25
|
async add(embeddingResults) {
|
|
27
26
|
if (embeddingResults.length == 0) {
|
|
@@ -43,7 +42,7 @@ export class EndeeVectorStore extends BaseVectorStore {
|
|
|
43
42
|
return {
|
|
44
43
|
id: node.id,
|
|
45
44
|
vector: node.vector,
|
|
46
|
-
meta: {
|
|
45
|
+
meta: { [this.textKey]: nodeContent.text },
|
|
47
46
|
filter: nodeContent.relationships.SOURCE.metadata,
|
|
48
47
|
};
|
|
49
48
|
});
|
|
@@ -60,7 +59,7 @@ export class EndeeVectorStore extends BaseVectorStore {
|
|
|
60
59
|
return true;
|
|
61
60
|
}
|
|
62
61
|
catch (err) {
|
|
63
|
-
|
|
62
|
+
console.error(err);
|
|
64
63
|
return false;
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -119,12 +118,8 @@ export class EndeeVectorStore extends BaseVectorStore {
|
|
|
119
118
|
ids: results.map((row) => row.id),
|
|
120
119
|
};
|
|
121
120
|
}
|
|
122
|
-
async delete(refDocId
|
|
123
|
-
const
|
|
124
|
-
this.index(),
|
|
125
|
-
//to get the information about the index
|
|
126
|
-
this.db?.describeIndex(this.indexName),
|
|
127
|
-
]);
|
|
121
|
+
async delete(refDocId) {
|
|
122
|
+
const idx = await this.index();
|
|
128
123
|
await idx.deleteVector(refDocId);
|
|
129
124
|
}
|
|
130
125
|
}
|