symposium 0.15.0 → 0.15.1
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 +9 -11
- package/package.json +1 -1
package/Agent.js
CHANGED
|
@@ -183,9 +183,8 @@ export default class Agent {
|
|
|
183
183
|
case 'utility':
|
|
184
184
|
return new Promise((resolve, reject) => {
|
|
185
185
|
emitter.on('data', data => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
resolve(parsed.content);
|
|
186
|
+
if (data.type === 'response')
|
|
187
|
+
resolve(data.content);
|
|
189
188
|
});
|
|
190
189
|
|
|
191
190
|
emitter.on('error', error => reject(error));
|
|
@@ -194,8 +193,7 @@ export default class Agent {
|
|
|
194
193
|
case 'chat':
|
|
195
194
|
if (!existing_emitter) {
|
|
196
195
|
emitter.on('data', data => {
|
|
197
|
-
|
|
198
|
-
if (parsed.type === 'response' && parsed.content.type === 'continue')
|
|
196
|
+
if (data.type === 'response' && data.content.type === 'continue')
|
|
199
197
|
this.execute(thread, 0, emitter);
|
|
200
198
|
}, false);
|
|
201
199
|
}
|
|
@@ -329,13 +327,13 @@ export default class Agent {
|
|
|
329
327
|
response = await this.afterHandle(thread, completion, 'return', JSON.parse(m.content));
|
|
330
328
|
|
|
331
329
|
if (response) {
|
|
332
|
-
emitter.emit('data',
|
|
330
|
+
emitter.emit('data', {type: 'response', content: response});
|
|
333
331
|
emitter.emit('end');
|
|
334
332
|
return emitter;
|
|
335
333
|
}
|
|
336
334
|
}
|
|
337
335
|
|
|
338
|
-
emitter.emit('data',
|
|
336
|
+
emitter.emit('data', {type: 'output', content: m.content});
|
|
339
337
|
break;
|
|
340
338
|
|
|
341
339
|
case 'function':
|
|
@@ -375,7 +373,7 @@ export default class Agent {
|
|
|
375
373
|
|
|
376
374
|
response
|
|
377
375
|
.then(content => {
|
|
378
|
-
emitter.emit('data',
|
|
376
|
+
emitter.emit('data', {type: 'response', content});
|
|
379
377
|
emitter.emit('end');
|
|
380
378
|
})
|
|
381
379
|
.catch(error => {
|
|
@@ -422,16 +420,16 @@ export default class Agent {
|
|
|
422
420
|
|
|
423
421
|
const func = functions.get(function_call.name);
|
|
424
422
|
const partialOutput = func.partialOutput ? ((typeof func.partialOutput) === 'text' ? func.partialOutput : func.partialOutput.call(this, function_call.arguments)) : 'Uso lo strumento ' + function_call.name + '...';
|
|
425
|
-
emitter.emit('data',
|
|
423
|
+
emitter.emit('data', {type: 'partial', content: partialOutput});
|
|
426
424
|
|
|
427
425
|
await this.log('function_call', function_call);
|
|
428
426
|
|
|
429
427
|
try {
|
|
430
428
|
const response = await func.tool.callFunction(thread, function_call.name, function_call.arguments);
|
|
431
|
-
emitter.emit('data',
|
|
429
|
+
emitter.emit('data', {type: 'partial', content: 'Risposta ricevuta da ' + func.tool.name});
|
|
432
430
|
return response;
|
|
433
431
|
} catch (error) {
|
|
434
|
-
emitter.emit('data',
|
|
432
|
+
emitter.emit('data', {type: 'partial', content: 'Ricevuto errore da ' + func.tool.name});
|
|
435
433
|
return {error};
|
|
436
434
|
}
|
|
437
435
|
}
|