File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @codebolt/codeboltjs" ,
3- "version" : " 1.1.22 " ,
3+ "version" : " 1.1.23 " ,
44 "description" : " " ,
55 "keywords" : [],
66 "author" : " " ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import cbstate from './modules/state';
1919import task from './modules/task' ;
2020import vectorDB from './modules/vectordb' ;
2121import debug from './modules/debug'
22+ import tokenizer from './modules/tokenizer'
2223import WebSocket from 'ws' ;
2324
2425
@@ -95,6 +96,7 @@ class Codebolt {
9596 taskplaner = task ;
9697 vectordb = vectorDB ;
9798 debug = debug ;
99+ tokenizer = tokenizer ;
98100}
99101
100102export default new Codebolt ( ) ;
Original file line number Diff line number Diff line change 1+ import cbws from './websocket' ;
2+
3+ /**
4+ * Tokenizer module for handling token-related operations.
5+ */
6+ const tokenizer = {
7+
8+ /**
9+ * Adds a token asynchronously.
10+ * @param {string } key - The key of the token to add.
11+ * @returns {Promise<any> } A promise that resolves with the response.
12+ */
13+ addToken : async ( key : string ) : Promise < any > => {
14+ return new Promise ( ( resolve , reject ) => {
15+ cbws . getWebsocket . send ( JSON . stringify ( {
16+ "type" :"tokenizerEvent" ,
17+ "action" : "addToken" ,
18+ "message" : {
19+ item : key
20+ } ,
21+ } ) ) ;
22+ cbws . getWebsocket . on ( 'message' , ( data : string ) => {
23+ const response = JSON . parse ( data ) ;
24+ if ( response . type === "addTokenResponse" ) {
25+ resolve ( response ) ;
26+ }
27+ } ) ;
28+ } ) ;
29+ }
30+ }
31+
32+ export default tokenizer
You can’t perform that action at this time.
0 commit comments