@livekit/agents-plugin-openai 1.5.3 → 1.6.0
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/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/realtime/realtime_model.cjs +20 -2
- package/dist/realtime/realtime_model.cjs.map +1 -1
- package/dist/realtime/realtime_model.d.ts.map +1 -1
- package/dist/realtime/realtime_model.js +20 -2
- package/dist/realtime/realtime_model.js.map +1 -1
- package/dist/realtime/realtime_model.test.cjs +40 -0
- package/dist/realtime/realtime_model.test.cjs.map +1 -1
- package/dist/realtime/realtime_model.test.js +40 -0
- package/dist/realtime/realtime_model.test.js.map +1 -1
- package/dist/ws/llm.cjs +1 -1
- package/dist/ws/llm.cjs.map +1 -1
- package/dist/ws/llm.d.ts.map +1 -1
- package/dist/ws/llm.js +1 -1
- package/dist/ws/llm.js.map +1 -1
- package/package.json +10 -7
- package/src/realtime/realtime_model.test.ts +55 -0
- package/src/realtime/realtime_model.ts +23 -2
- package/src/ws/llm.ts +1 -0
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -473,7 +473,7 @@ class RealtimeSession extends import_agents.llm.RealtimeSession {
|
|
|
473
473
|
const timeoutController = new AbortController();
|
|
474
474
|
const timeoutPromise = (0, import_agents.delay)(5e3, { signal: timeoutController.signal }).then(() => {
|
|
475
475
|
cleanupTimedOutFutures();
|
|
476
|
-
throw new
|
|
476
|
+
throw new import_agents.llm.RealtimeError("update_chat_ctx timed out.");
|
|
477
477
|
});
|
|
478
478
|
try {
|
|
479
479
|
await Promise.race([Promise.all(futures), timeoutPromise]);
|
|
@@ -512,7 +512,7 @@ class RealtimeSession extends import_agents.llm.RealtimeSession {
|
|
|
512
512
|
event_id: (0, import_agents.shortuuid)("chat_ctx_delete_")
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
const createItem = async (previousId, id) => {
|
|
516
516
|
const chatItem = newChatCtx.getById(id);
|
|
517
517
|
if (!chatItem) {
|
|
518
518
|
throw new Error(`Chat item ${id} not found`);
|
|
@@ -523,6 +523,24 @@ class RealtimeSession extends import_agents.llm.RealtimeSession {
|
|
|
523
523
|
previous_item_id: previousId ?? void 0,
|
|
524
524
|
event_id: (0, import_agents.shortuuid)("chat_ctx_create_")
|
|
525
525
|
});
|
|
526
|
+
};
|
|
527
|
+
const isContentEmpty = (id) => {
|
|
528
|
+
const remoteItem = remoteCtx.getById(id);
|
|
529
|
+
return (remoteItem == null ? void 0 : remoteItem.type) === "message" && remoteItem.content.length === 0;
|
|
530
|
+
};
|
|
531
|
+
for (const [previousId, id] of diffOps.toCreate) {
|
|
532
|
+
await createItem(previousId, id);
|
|
533
|
+
}
|
|
534
|
+
for (const [previousId, id] of diffOps.toUpdate) {
|
|
535
|
+
if (isContentEmpty(id)) {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
events.push({
|
|
539
|
+
type: "conversation.item.delete",
|
|
540
|
+
item_id: id,
|
|
541
|
+
event_id: (0, import_agents.shortuuid)("chat_ctx_delete_")
|
|
542
|
+
});
|
|
543
|
+
await createItem(previousId, id);
|
|
526
544
|
}
|
|
527
545
|
return events;
|
|
528
546
|
}
|