@graf-research/llm-runner 0.0.20 → 0.0.21

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.
@@ -6,10 +6,10 @@ export declare namespace GenericLLM {
6
6
  stream(onMessage: OnMessage): Promise<void>;
7
7
  }
8
8
  abstract class ChatSessionManager<SessionModel, ChatModel> {
9
- abstract newSession(): Promise<SessionModel>;
10
- abstract getChatSession(id_session: string): Promise<SessionModel>;
11
- abstract saveMessage(messages: string[], role: string, id_session: string): Promise<void>;
12
- abstract retrieveHistory(id_session: string): Promise<ChatModel[]>;
9
+ abstract newSession(): SessionModel;
10
+ abstract getChatSession(id_session: string): SessionModel;
11
+ abstract saveMessage(messages: string[], role: string, id_session: string): void;
12
+ abstract retrieveHistory(id_session: string): ChatModel[];
13
13
  }
14
14
  abstract class GenericLLM {
15
15
  abstract stream(messages: string[], id_session: string): Promise<StreamResponse>;
@@ -13,11 +13,11 @@ export declare namespace LLMRunner {
13
13
  */
14
14
  class SessionManager implements GenericLLM.ChatSessionManager<ChatSession, Message> {
15
15
  list_session: ChatSession[];
16
- newSession(): Promise<ChatSession>;
17
- getSession(id_session: string): Promise<ChatSession | undefined>;
18
- getChatSession(id_session: string): Promise<ChatSession>;
19
- saveMessage(messages: string[], role: string, id_session: string): Promise<void>;
20
- retrieveHistory(id_session: string): Promise<Message[]>;
16
+ newSession(): ChatSession;
17
+ getSession(id_session: string): ChatSession | undefined;
18
+ getChatSession(id_session: string): ChatSession;
19
+ saveMessage(messages: string[], role: string, id_session: string): void;
20
+ retrieveHistory(id_session: string): Message[];
21
21
  }
22
22
  /**
23
23
  * Abstract Base LLM Class
@@ -30,43 +30,33 @@ var LLMRunner;
30
30
  this.list_session = [];
31
31
  }
32
32
  newSession() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const session = {
35
- id: (0, uuid_1.v4)(),
36
- list_message: []
37
- };
38
- this.list_session.push(session);
39
- return session;
40
- });
33
+ const session = {
34
+ id: (0, uuid_1.v4)(),
35
+ list_message: []
36
+ };
37
+ this.list_session.push(session);
38
+ return session;
41
39
  }
42
40
  getSession(id_session) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return this.list_session.find(s => s.id == id_session);
45
- });
41
+ return this.list_session.find(s => s.id == id_session);
46
42
  }
47
43
  getChatSession(id_session) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const cs = this.list_session.find(s => s.id == id_session);
50
- if (!cs) {
51
- throw new Error('Session not found.');
52
- }
53
- return cs;
54
- });
44
+ const cs = this.list_session.find(s => s.id == id_session);
45
+ if (!cs) {
46
+ throw new Error('Session not found.');
47
+ }
48
+ return cs;
55
49
  }
56
50
  saveMessage(messages, role, id_session) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const cs = yield this.getChatSession(id_session);
59
- cs.list_message.push(...messages.map(content => ({
60
- role,
61
- content
62
- })));
63
- });
51
+ const cs = this.getChatSession(id_session);
52
+ cs.list_message.push(...messages.map(content => ({
53
+ role,
54
+ content
55
+ })));
64
56
  }
65
57
  retrieveHistory(id_session) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const cs = yield this.getChatSession(id_session);
68
- return cs.list_message;
69
- });
58
+ const cs = this.getChatSession(id_session);
59
+ return cs.list_message;
70
60
  }
71
61
  }
72
62
  LLMRunner.SessionManager = SessionManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graf-research/llm-runner",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist && tsc",