symposium 1.0.3 → 1.0.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.
Files changed (2) hide show
  1. package/Agent.js +11 -4
  2. package/package.json +1 -1
package/Agent.js CHANGED
@@ -359,6 +359,10 @@ export default class Agent {
359
359
  return value;
360
360
  }
361
361
 
362
+ getEmitter() {
363
+ return new BufferedEventEmitter();
364
+ }
365
+
362
366
  async getFunctions(parsed = true) {
363
367
  if (this.functions === null) {
364
368
  this.functions = new Map();
@@ -382,23 +386,26 @@ export default class Agent {
382
386
  return this.functions;
383
387
  }
384
388
 
385
- async callFunction(thread, function_call, emitter) {
389
+ async callFunction(thread, function_call, emitter = null) {
386
390
  const functions = await this.getFunctions(false);
387
391
  if (!functions.has(function_call.name))
388
392
  throw new Error('Unrecognized function ' + function_call.name);
389
393
 
390
394
  const func = functions.get(function_call.name);
391
395
  const partialOutput = func.partialOutput ? ((typeof func.partialOutput) === 'text' ? func.partialOutput : func.partialOutput.call(this, function_call.arguments)) : 'Uso lo strumento ' + function_call.name + '...';
392
- emitter.emit('partial', partialOutput);
396
+ if (emitter)
397
+ emitter.emit('partial', partialOutput);
393
398
 
394
399
  await this.log('function_call', function_call);
395
400
 
396
401
  try {
397
402
  const response = await func.tool.callFunction(thread, function_call.name, function_call.arguments);
398
- emitter.emit('partial', 'Risposta ricevuta da ' + func.tool.name);
403
+ if (emitter)
404
+ emitter.emit('partial', 'Risposta ricevuta da ' + func.tool.name);
399
405
  return response;
400
406
  } catch (error) {
401
- emitter.emit('partial', 'Ricevuto errore da ' + func.tool.name);
407
+ if (emitter)
408
+ emitter.emit('partial', 'Ricevuto errore da ' + func.tool.name);
402
409
  return {error};
403
410
  }
404
411
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "1.0.3",
4
+ "version": "1.0.4",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",