@codebolt/codeboltjs 1.1.18 → 1.1.19
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/index.js +2 -0
- package/modules/vectordb.d.ts +25 -0
- package/modules/vectordb.js +76 -0
- package/package.json +1 -1
- package/src/index.ts +4 -1
- package/src/modules/vectordb.ts +75 -0
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const git_1 = __importDefault(require("./modules/git"));
|
|
|
22
22
|
const dbmemory_1 = __importDefault(require("./modules/dbmemory"));
|
|
23
23
|
const state_1 = __importDefault(require("./modules/state"));
|
|
24
24
|
const task_1 = __importDefault(require("./modules/task"));
|
|
25
|
+
const vectordb_1 = __importDefault(require("./modules/vectordb"));
|
|
25
26
|
const ws_1 = __importDefault(require("ws"));
|
|
26
27
|
/**
|
|
27
28
|
* @class Codebolt
|
|
@@ -52,6 +53,7 @@ class Codebolt {
|
|
|
52
53
|
this.dbmemory = dbmemory_1.default;
|
|
53
54
|
this.cbstate = state_1.default;
|
|
54
55
|
this.taskplaner = task_1.default;
|
|
56
|
+
this.vectordb = vectordb_1.default;
|
|
55
57
|
this.websocket = websocket_1.default.getWebsocket;
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const VectorDB: {
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
6
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
7
|
+
*/
|
|
8
|
+
getVector: (key: string) => Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Adds a new vector item to the vector database.
|
|
11
|
+
*
|
|
12
|
+
|
|
13
|
+
* @param {any} item - The item to add to the vector.
|
|
14
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
15
|
+
*/
|
|
16
|
+
addVectorItem: (item: any) => Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} key - The key of the vector to query the item from.
|
|
21
|
+
* @returns {Promise<any>} A promise that resolves with the queried vector item.
|
|
22
|
+
*/
|
|
23
|
+
queryVectorItem: (key: string) => Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
export default VectorDB;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
+
const VectorDB = {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
12
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
13
|
+
*/
|
|
14
|
+
getVector: async (key) => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
17
|
+
"type": "getVector",
|
|
18
|
+
"message": {
|
|
19
|
+
item: key
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
23
|
+
const response = JSON.parse(data);
|
|
24
|
+
if (response.type === "getVectorResponse") {
|
|
25
|
+
resolve(response);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Adds a new vector item to the vector database.
|
|
32
|
+
*
|
|
33
|
+
|
|
34
|
+
* @param {any} item - The item to add to the vector.
|
|
35
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
36
|
+
*/
|
|
37
|
+
addVectorItem: async (item) => {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
40
|
+
"type": "addVectorItem",
|
|
41
|
+
"message": {
|
|
42
|
+
item: item
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
46
|
+
const response = JSON.parse(data);
|
|
47
|
+
if (response.type === "addVectorItemResponse") {
|
|
48
|
+
resolve(response);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} key - The key of the vector to query the item from.
|
|
57
|
+
* @returns {Promise<any>} A promise that resolves with the queried vector item.
|
|
58
|
+
*/
|
|
59
|
+
queryVectorItem: async (key) => {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
62
|
+
"type": "queryVectorItem",
|
|
63
|
+
"message": {
|
|
64
|
+
item: key
|
|
65
|
+
},
|
|
66
|
+
}));
|
|
67
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
68
|
+
const response = JSON.parse(data);
|
|
69
|
+
if (response.type === "qeryVectorItemResponse") {
|
|
70
|
+
resolve(response);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
exports.default = VectorDB;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ import git from './modules/git';
|
|
|
17
17
|
import dbmemory from './modules/dbmemory';
|
|
18
18
|
import cbstate from './modules/state';
|
|
19
19
|
import task from './modules/task';
|
|
20
|
+
|
|
21
|
+
import vectorDB from './modules/vectordb';
|
|
20
22
|
import WebSocket from 'ws';
|
|
21
23
|
|
|
22
24
|
|
|
@@ -90,7 +92,8 @@ class Codebolt {
|
|
|
90
92
|
project = cbproject;
|
|
91
93
|
dbmemory = dbmemory;
|
|
92
94
|
cbstate=cbstate;
|
|
93
|
-
taskplaner=task
|
|
95
|
+
taskplaner=task;
|
|
96
|
+
vectordb=vectorDB;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
// export default new Codebolt();
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import cbws from './websocket';
|
|
2
|
+
|
|
3
|
+
const VectorDB = {
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves a vector from the vector database based on the provided key.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} key - The key of the vector to retrieve.
|
|
8
|
+
* @returns {Promise<any>} A promise that resolves with the retrieved vector.
|
|
9
|
+
*/
|
|
10
|
+
getVector: async (key: string): Promise<any> => {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
13
|
+
"type": "getVector",
|
|
14
|
+
"message": {
|
|
15
|
+
item: key
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
19
|
+
const response = JSON.parse(data);
|
|
20
|
+
if (response.type === "getVectorResponse") {
|
|
21
|
+
resolve(response);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds a new vector item to the vector database.
|
|
29
|
+
*
|
|
30
|
+
|
|
31
|
+
* @param {any} item - The item to add to the vector.
|
|
32
|
+
* @returns {Promise<any>} A promise that resolves when the item is successfully added.
|
|
33
|
+
*/
|
|
34
|
+
addVectorItem: async ( item: any): Promise<any> => {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
37
|
+
"type": "addVectorItem",
|
|
38
|
+
"message": {
|
|
39
|
+
item: item
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
43
|
+
const response = JSON.parse(data);
|
|
44
|
+
if (response.type === "addVectorItemResponse") {
|
|
45
|
+
resolve(response);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Queries a vector item from the vector database based on the provided key.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} key - The key of the vector to query the item from.
|
|
55
|
+
* @returns {Promise<any>} A promise that resolves with the queried vector item.
|
|
56
|
+
*/
|
|
57
|
+
queryVectorItem: async (key: string): Promise<any> => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
60
|
+
"type": "queryVectorItem",
|
|
61
|
+
"message": {
|
|
62
|
+
item: key
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
66
|
+
const response = JSON.parse(data);
|
|
67
|
+
if (response.type === "qeryVectorItemResponse") {
|
|
68
|
+
resolve(response);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default VectorDB;
|