symposium 0.1.2 → 0.1.4

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/Agent.js CHANGED
@@ -20,19 +20,6 @@ class Agent {
20
20
  if (this.options.memory_handler)
21
21
  this.options.memory_handler.setAgent(this);
22
22
 
23
- this.models = [
24
- {
25
- label: 'gpt-3.5',
26
- name: 'gpt-3.5-turbo-16k',
27
- tokens: 16384,
28
- },
29
- {
30
- label: 'gpt-4',
31
- name: 'gpt-4',
32
- tokens: 8192
33
- }
34
- ];
35
-
36
23
  this.commands = new Map();
37
24
 
38
25
  this.commands.set('start', {
@@ -48,15 +35,15 @@ class Agent {
48
35
  show_in_help: true,
49
36
  exec: async (conversation, args) => {
50
37
  if (args) {
51
- const model_to_switch = this.getModelFromLabel(args);
38
+ const model_to_switch = Symposium.getModelByLabel(args);
52
39
  if (model_to_switch) {
53
40
  await conversation.setState({model: model_to_switch.name});
54
41
  await conversation.reply('# Da ora in poi uso ' + model_to_switch.label + '!');
55
42
  } else {
56
- await conversation.reply("# Versione modello non riconosciuta!\nModelli disponibili:\n" + this.models.map(m => m.label).join("\n"));
43
+ await conversation.reply("# Versione modello non riconosciuta!\nModelli disponibili:\n" + Symposium.models.map(m => m.label).join("\n"));
57
44
  }
58
45
  } else {
59
- const currentModel = this.getModelFromName(conversation.state.model);
46
+ const currentModel = Symposium.getModelByName(conversation.state.model);
60
47
  await conversation.reply('# Il modello attualmente in uso è ' + currentModel.label);
61
48
  }
62
49
  },
@@ -112,14 +99,6 @@ class Agent {
112
99
  await conversation.storeState();
113
100
  }
114
101
 
115
- getModelFromLabel(label) {
116
- return this.models.find(model => model.label === label);
117
- }
118
-
119
- getModelFromName(name) {
120
- return this.models.find(model => model.name === name);
121
- }
122
-
123
102
  async resetState(conversation) {
124
103
  conversation.state = await this.getDefaultState();
125
104
  }
package/Model.js ADDED
@@ -0,0 +1,13 @@
1
+ class Model {
2
+ name;
3
+ label;
4
+ tokens;
5
+
6
+ constructor(name, label, tokens) {
7
+ this.name = name;
8
+ this.label = label;
9
+ this.tokens = tokens;
10
+ }
11
+ }
12
+
13
+ export {Model};
package/Summarizer.js CHANGED
@@ -1,3 +1,4 @@
1
+ import {Symposium} from "./Symposium.js";
1
2
  import {MemoryHandler} from "./MemoryHandler.js";
2
3
  import {encoding_for_model} from "tiktoken";
3
4
 
@@ -9,7 +10,7 @@ class Summarizer extends MemoryHandler {
9
10
  }
10
11
 
11
12
  async handle(conversation) {
12
- const model = this.agent.models.find(model => model.name === conversation.state.model);
13
+ const model = Symposium.getModelByName(conversation.state.model);
13
14
  if (!model)
14
15
  return conversation;
15
16
 
package/Symposium.js CHANGED
@@ -1,13 +1,23 @@
1
1
  import Redis from "@travio/redis";
2
2
  import OpenAI from "openai";
3
+ import {Model} from "./Model.js";
3
4
 
4
5
  class Symposium {
5
6
  static openai;
7
+ static models = [];
6
8
 
7
9
  static async init() {
10
+ this.loadModel(new Model('gpt-3.5-turbo-16k', 'gpt-3.5', 16384));
11
+ this.loadModel(new Model('gpt-4', 'gpt-4', 8192));
12
+ this.loadModel(new Model('gpt-4-1106-preview', 'gpt-4-turbo', 128000));
13
+
8
14
  return Redis.init();
9
15
  }
10
16
 
17
+ static loadModel(model) {
18
+ this.models.push(model);
19
+ }
20
+
11
21
  static async getOpenAi() {
12
22
  if (!this.openai)
13
23
  this.openai = new OpenAI({apiKey: process.env.OPENAI_API_KEY});
@@ -15,6 +25,14 @@ class Symposium {
15
25
  return this.openai;
16
26
  }
17
27
 
28
+ static getModelByLabel(label) {
29
+ return this.models.find(model => model.label === label);
30
+ }
31
+
32
+ static getModelByName(name) {
33
+ return this.models.find(model => model.name === name);
34
+ }
35
+
18
36
  static async transcribe(agent, file, conversation) {
19
37
  let words = await agent.getPromptWordsForTranscription(conversation);
20
38
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "scripts": {