@ash-ai/ui 0.0.5 → 0.0.6
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.js
CHANGED
|
@@ -347,6 +347,22 @@ ${fileRefs}` : fileRefs;
|
|
|
347
347
|
setMessages((prev) => prev.map(
|
|
348
348
|
(m) => m.id === assistantId ? { ...m, content: fullContent || "(no response)", toolCalls: [...toolCalls], isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
|
|
349
349
|
));
|
|
350
|
+
} else if (event.type === "message") {
|
|
351
|
+
const data = event.data;
|
|
352
|
+
if (data.type === "assistant" && Array.isArray(data.message?.content)) {
|
|
353
|
+
let text = "";
|
|
354
|
+
for (const block of data.message.content) {
|
|
355
|
+
if (block.type === "text" && block.text) {
|
|
356
|
+
text += (text ? "\n" : "") + block.text;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (text) {
|
|
360
|
+
fullContent = text;
|
|
361
|
+
setMessages((prev) => prev.map(
|
|
362
|
+
(m) => m.id === assistantId ? { ...m, content: fullContent, toolCalls: [...toolCalls], isStreaming: true } : m
|
|
363
|
+
));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
350
366
|
} else if (event.type === "error") {
|
|
351
367
|
const data = event.data;
|
|
352
368
|
const errText = data.error || "Unknown error";
|
|
@@ -355,12 +371,14 @@ ${fileRefs}` : fileRefs;
|
|
|
355
371
|
));
|
|
356
372
|
}
|
|
357
373
|
}
|
|
358
|
-
|
|
359
|
-
|
|
374
|
+
if (fullContent || toolCalls.length > 0) {
|
|
375
|
+
for (const tc of toolCalls) {
|
|
376
|
+
if (tc.state === "running" || tc.state === "pending") tc.state = "completed";
|
|
377
|
+
}
|
|
378
|
+
setMessages((prev) => prev.map(
|
|
379
|
+
(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
|
|
380
|
+
));
|
|
360
381
|
}
|
|
361
|
-
setMessages((prev) => prev.map(
|
|
362
|
-
(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
|
|
363
|
-
));
|
|
364
382
|
} catch (err) {
|
|
365
383
|
const errMsg = err instanceof Error ? err.message : "Failed to send";
|
|
366
384
|
setMessages((prev) => prev.map(
|