symposium 0.11.0 → 0.11.2

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.
Files changed (3) hide show
  1. package/Agent.js +15 -2
  2. package/Thread.js +2 -3
  3. package/package.json +1 -1
package/Agent.js CHANGED
@@ -10,6 +10,7 @@ export default class Agent {
10
10
  tools = new Map();
11
11
  default_model = 'gpt-4o';
12
12
  max_retries = 5;
13
+ callbacks = {};
13
14
 
14
15
  constructor(options) {
15
16
  this.options = {
@@ -76,10 +77,16 @@ export default class Agent {
76
77
  return thread;
77
78
  }
78
79
 
79
- async message(thread, i, content) {
80
+ async message(thread, i, content, callback = null) {
80
81
  if (typeof thread !== 'object')
81
82
  thread = await this.getThread(thread, i);
82
83
 
84
+ if (callback) {
85
+ if (!this.callbacks.hasOwnProperty(i + '-' + thread.id))
86
+ this.callbacks[i + '-' + thread.id] = [];
87
+ this.callbacks[i + '-' + thread.id].push(callback);
88
+ }
89
+
83
90
  await this.log('user_message', content);
84
91
  thread.addMessage('user', content);
85
92
 
@@ -155,8 +162,14 @@ export default class Agent {
155
162
 
156
163
  async output(thread, msg) {
157
164
  const i = this.options.interfaces.find(i => i.name === thread.interface);
158
- if (i)
165
+ if (i) {
166
+ if (this.callbacks.hasOwnProperty(i + '-' + thread.id) && this.callbacks[i + '-' + thread.id].length) {
167
+ const callback = this.callbacks[i + '-' + thread.id].shift();
168
+ await callback(thread, msg);
169
+ }
170
+
159
171
  return i.output(thread, msg);
172
+ }
160
173
  }
161
174
 
162
175
  parseFunctions(message) {
package/Thread.js CHANGED
@@ -5,21 +5,20 @@ export default class Thread {
5
5
  id;
6
6
  unique;
7
7
  agent;
8
- reply;
9
8
  messages = [];
10
9
  state = {};
11
10
  interface = null;
12
11
 
13
12
  constructor(id, i, agent) {
14
13
  this.id = id;
15
- this.unique = agent.name + '-' + id;
14
+ this.unique = agent.name + '-' + i + '-' + id;
16
15
  this.agent = agent;
17
16
  this.interface = i;
18
17
  }
19
18
 
20
19
  clone(keepMessages = true) {
21
20
  let newThread = new Thread(this.id, this.interface, this.agent);
22
- newThread.reply = this.reply;
21
+ newThread.interface = this.interface;
23
22
  newThread.state = this.state;
24
23
  if (keepMessages)
25
24
  newThread.messages = [...this.messages];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.11.0",
4
+ "version": "0.11.2",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",