symposium 0.14.3 → 0.14.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 +18 -12
  2. package/package.json +1 -1
package/Agent.js CHANGED
@@ -414,22 +414,28 @@ export default class Agent {
414
414
  }
415
415
 
416
416
  async createRealtimeSession() {
417
- const model = Symposium.getModelByName(thread.state.model);
418
- if(!model.hasOwnProperty('openai'))
419
- throw new Error('Model does not support real-time sessions');
420
-
421
- // Recupero il messaggio di sistema
417
+ // Thread fittizio
422
418
  const thread = new Thread('temp', 'default', this);
423
419
  await this.resetState(thread);
424
420
  await this.initThread(thread);
425
421
 
426
422
  const instructions = thread.messages.filter(m => m.role === 'system').map(m => m.content.map(c => c.content).join("\n")).join("\n");
427
-
428
- const openai = model.getOpenAi();
429
- return openai.realtime.sessions.create({
430
- model: 'gpt-4o-realtime-preview',
431
- instructions,
432
- tools: await this.getFunctions(),
433
- });
423
+ const tools = (await this.getFunctions()).map(t => ({
424
+ type: 'function',
425
+ ...t,
426
+ }));
427
+
428
+ return fetch('https://api.openai.com/v1/realtime/sessions', {
429
+ method: 'POST',
430
+ headers: {
431
+ "Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
432
+ "Content-Type": 'application/json',
433
+ },
434
+ body: JSON.stringify({
435
+ model: 'gpt-4o-realtime-preview',
436
+ instructions,
437
+ tools,
438
+ }),
439
+ }).then(response => response.json());
434
440
  }
435
441
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "0.14.3",
4
+ "version": "0.14.4",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",