@hienlh/ppm 0.2.9 → 0.2.11
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/package.json +1 -1
- package/src/server/ws/chat.ts +9 -0
package/package.json
CHANGED
package/src/server/ws/chat.ts
CHANGED
|
@@ -83,15 +83,24 @@ export const chatWebSocket = {
|
|
|
83
83
|
if (entryRef) entryRef.abort = abortController;
|
|
84
84
|
|
|
85
85
|
try {
|
|
86
|
+
console.log(`[chat] session=${sessionId} sending message to provider=${providerId}`);
|
|
87
|
+
let eventCount = 0;
|
|
86
88
|
for await (const event of chatService.sendMessage(
|
|
87
89
|
providerId,
|
|
88
90
|
sessionId,
|
|
89
91
|
parsed.content,
|
|
90
92
|
)) {
|
|
91
93
|
if (abortController.signal.aborted) break;
|
|
94
|
+
eventCount++;
|
|
95
|
+
const evType = (event as any).type ?? "unknown";
|
|
96
|
+
if (evType === "error" || evType === "result") {
|
|
97
|
+
console.log(`[chat] session=${sessionId} event#${eventCount}: ${evType}`, JSON.stringify(event).slice(0, 300));
|
|
98
|
+
}
|
|
92
99
|
ws.send(JSON.stringify(event));
|
|
93
100
|
}
|
|
101
|
+
console.log(`[chat] session=${sessionId} stream completed (${eventCount} events)`);
|
|
94
102
|
} catch (e) {
|
|
103
|
+
console.error(`[chat] session=${sessionId} error:`, (e as Error).message);
|
|
95
104
|
if (!abortController.signal.aborted) {
|
|
96
105
|
ws.send(
|
|
97
106
|
JSON.stringify({
|