symposium 0.14.3 → 0.14.5
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 +18 -12
- 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
|
-
|
|
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
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
}
|