Skip to content

Commit 135c98c

Browse files
chat summary added
1 parent 3c3546c commit 135c98c

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.58",
3+
"version": "1.1.59",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import debug from './modules/debug'
2222
import tokenizer from './modules/tokenizer'
2323
import WebSocket from 'ws';
2424
import { EventEmitter } from 'events';
25+
import {chatSummary} from './modules/history'
2526

2627

2728
/**
@@ -89,6 +90,7 @@ class Codebolt { // Extend EventEmitter
8990
vectordb = vectorDB;
9091
debug = debug;
9192
tokenizer = tokenizer;
93+
chatSummary=chatSummary
9294
}
9395

9496
export default new Codebolt();

src/modules/history.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import cbws from './websocket';
2+
3+
export enum logType {
4+
info = "info",
5+
error = "error",
6+
warning = "warning"
7+
}
8+
9+
10+
export const chatSummary = {
11+
12+
summarizeAll: (): Promise<{
13+
role: string;
14+
content: string;
15+
}[]> => {
16+
return new Promise((resolve, reject) => {
17+
cbws.getWebsocket.send(JSON.stringify({
18+
"type": "chatSummaryEvent",
19+
"action": "summarizeAll",
20+
21+
}));
22+
cbws.getWebsocket.on('message', (data: string) => {
23+
const response = JSON.parse(data);
24+
if (response.type === "getSummarizeAllResponse") {
25+
resolve(response.payload); // Resolve the Promise with the response data
26+
}
27+
})
28+
})
29+
30+
31+
},
32+
summarize: (messages: {
33+
role: string;
34+
content: string;
35+
}[], depth: number): Promise<{
36+
role: string;
37+
content: string;
38+
}[]> => {
39+
return new Promise((resolve, reject) => {
40+
cbws.getWebsocket.send(JSON.stringify({
41+
"type": "chatSummaryEvent",
42+
"action": "summarize",
43+
messages,
44+
depth
45+
}));
46+
cbws.getWebsocket.on('message', (data: string) => {
47+
const response = JSON.parse(data);
48+
if (response.type === "getSummarizeResponse") {
49+
resolve(response.payload); // Resolve the Promise with the response data
50+
}
51+
})
52+
})
53+
54+
}
55+
}
56+
57+
58+
export default debug;
59+
60+
61+

0 commit comments

Comments
 (0)