Skip to content

Commit d5c8909

Browse files
changes
1 parent d90cee3 commit d5c8909

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/modules/vectordb.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,30 @@ const VectorDB = {
7373
});
7474
});
7575
},
76+
/**
77+
* Queries a vector item from the vector database based on the provided key.
78+
*
79+
* @param {string} key - The key of the vector to query the item from.
80+
* @returns {Promise<QueryVectorItemResponse>} A promise that resolves with the queried vector item.
81+
*/
82+
queryVectorItems: async (items: [],dbPath:string): Promise<QueryVectorItemResponse> => {
83+
return new Promise((resolve, reject) => {
84+
cbws.getWebsocket.send(JSON.stringify({
85+
"type":"vectordbEvent",
86+
"action": "queryVectorItem",
87+
"message": {
88+
items,
89+
dbPath
90+
},
91+
}));
92+
cbws.getWebsocket.on('message', (data: string) => {
93+
const response = JSON.parse(data);
94+
if (response.type === "qeryVectorItemsResponse") {
95+
resolve(response);
96+
}
97+
});
98+
});
99+
},
76100
};
77101

78102
export default VectorDB;

0 commit comments

Comments
 (0)