symposium 0.5.4 → 0.5.5

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
@@ -179,7 +179,7 @@ export default class Agent {
179
179
  let call_function = null;
180
180
  for (let message of completion) {
181
181
  thread.addDirectMessage(message);
182
- await this.log('ai_message', message);
182
+ await this.log('ai_message', message.content);
183
183
 
184
184
  for (let m of message.content) {
185
185
  switch (m.type) {
package/Symposium.js CHANGED
@@ -41,7 +41,7 @@ export default class Symposium {
41
41
  for (let message of messages) {
42
42
  const functionResponse = message.content.filter(c => c.type === 'function');
43
43
  if (functionResponse.length)
44
- return functionResponse[0].arguments;
44
+ return functionResponse[0].content.arguments;
45
45
  }
46
46
 
47
47
  return null;
@@ -8,12 +8,6 @@ export default class OpenAIModel extends Model {
8
8
  name_for_tiktoken;
9
9
  supports_functions = true;
10
10
 
11
- constructor() {
12
- super();
13
- if (!this.name_for_tiktoken)
14
- this.name_for_tiktoken = this.name;
15
- }
16
-
17
11
  getOpenAi() {
18
12
  if (!this.openai)
19
13
  this.openai = new OpenAI({apiKey: process.env.OPENAI_API_KEY});
@@ -83,12 +77,16 @@ export default class OpenAIModel extends Model {
83
77
  }
84
78
 
85
79
  async countTokens(thread) {
86
- const encoder = encoding_for_model(this.name_for_tiktoken);
87
-
88
- const texts = [];
89
- for (let message of thread.messages)
90
- texts.push(message.content.map(m => typeof m.content === 'string' ? m.content : JSON.stringify(m.content)).join(''));
91
- return encoder.encode(texts.join('')).length;
80
+ try {
81
+ const encoder = encoding_for_model(this.name_for_tiktoken || this.name);
82
+
83
+ const texts = [];
84
+ for (let message of thread.messages)
85
+ texts.push(message.content.map(m => typeof m.content === 'string' ? m.content : JSON.stringify(m.content)).join(''));
86
+ return encoder.encode(texts.join('')).length;
87
+ } catch (e) {
88
+ throw new Error('Error while counting tokens');
89
+ }
92
90
  }
93
91
 
94
92
  convertMessage(message) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.5.4",
4
+ "version": "0.5.5",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",