@ash-ai/ui 0.0.5 → 0.0.7
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 +23 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -402,6 +402,22 @@ ${fileRefs}` : fileRefs;
|
|
|
402
402
|
setMessages((prev) => prev.map(
|
|
403
403
|
(m) => m.id === assistantId ? { ...m, content: fullContent || "(no response)", toolCalls: [...toolCalls], isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
|
|
404
404
|
));
|
|
405
|
+
} else if (event.type === "message") {
|
|
406
|
+
const data = event.data;
|
|
407
|
+
if (data.type === "assistant" && Array.isArray(data.message?.content)) {
|
|
408
|
+
let text = "";
|
|
409
|
+
for (const block of data.message.content) {
|
|
410
|
+
if (block.type === "text" && block.text) {
|
|
411
|
+
text += (text ? "\n" : "") + block.text;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (text) {
|
|
415
|
+
fullContent = text;
|
|
416
|
+
setMessages((prev) => prev.map(
|
|
417
|
+
(m) => m.id === assistantId ? { ...m, content: fullContent, toolCalls: [...toolCalls], isStreaming: true } : m
|
|
418
|
+
));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
405
421
|
} else if (event.type === "error") {
|
|
406
422
|
const data = event.data;
|
|
407
423
|
const errText = data.error || "Unknown error";
|
|
@@ -410,12 +426,14 @@ ${fileRefs}` : fileRefs;
|
|
|
410
426
|
));
|
|
411
427
|
}
|
|
412
428
|
}
|
|
413
|
-
|
|
414
|
-
|
|
429
|
+
if (fullContent || toolCalls.length > 0) {
|
|
430
|
+
for (const tc of toolCalls) {
|
|
431
|
+
if (tc.state === "running" || tc.state === "pending") tc.state = "completed";
|
|
432
|
+
}
|
|
433
|
+
setMessages((prev) => prev.map(
|
|
434
|
+
(m) => m.id === assistantId && m.isStreaming ? { ...m, content: fullContent || "(no response)", toolCalls: toolCalls.length > 0 ? [...toolCalls] : void 0, isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
|
|
435
|
+
));
|
|
415
436
|
}
|
|
416
|
-
setMessages((prev) => prev.map(
|
|
417
|
-
(m) => m.id === assistantId && m.isStreaming ? { ...m, content: fullContent || "(no response)", toolCalls: toolCalls.length > 0 ? [...toolCalls] : void 0, isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
|
|
418
|
-
));
|
|
419
437
|
} catch (err) {
|
|
420
438
|
const errMsg = err instanceof Error ? err.message : "Failed to send";
|
|
421
439
|
setMessages((prev) => prev.map(
|