symposium 0.11.1 → 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.
- package/Agent.js +15 -2
- package/Thread.js +1 -1
- 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