@agno-hq/chat-react 0.1.0 → 0.1.1
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/README.md +3 -2
- package/dist/index.cjs +30 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -35
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -251,6 +251,7 @@ A symptom of a CORS mismatch is an empty entity dropdown and a
|
|
|
251
251
|
git clone https://github.com/agno-agi/agno-chat-react.git
|
|
252
252
|
cd agno-chat-react
|
|
253
253
|
npm install
|
|
254
|
+
npm test # Node test runner
|
|
254
255
|
npm run typecheck # tsc --noEmit
|
|
255
256
|
npm run build # tsup -> dist/ (ESM + CJS + .d.ts)
|
|
256
257
|
```
|
|
@@ -260,8 +261,8 @@ The published package is built with [tsup](https://tsup.egoist.dev) into
|
|
|
260
261
|
`styles.css`). The `example/` app, however, resolves the library straight from
|
|
261
262
|
`src/` via a Vite alias, so you can develop against live changes without
|
|
262
263
|
rebuilding — see [Running the example](#running-the-example). `prepublishOnly`
|
|
263
|
-
runs the typecheck and build automatically, so `npm publish` always
|
|
264
|
-
fresh `dist/`.
|
|
264
|
+
runs the tests, typecheck, and build automatically, so `npm publish` always
|
|
265
|
+
ships a fresh `dist/`.
|
|
265
266
|
|
|
266
267
|
---
|
|
267
268
|
|
package/dist/index.cjs
CHANGED
|
@@ -305,6 +305,35 @@ function toolsFromEvent(e) {
|
|
|
305
305
|
if (Array.isArray(e.tools)) out.push(...e.tools);
|
|
306
306
|
return out;
|
|
307
307
|
}
|
|
308
|
+
function applyContentEvent(message, e) {
|
|
309
|
+
const next = { ...message };
|
|
310
|
+
if (typeof e.content === "string" && e.content) {
|
|
311
|
+
next.content = message.content + e.content;
|
|
312
|
+
} else if (e.content && typeof e.content === "object") {
|
|
313
|
+
next.content = message.content + "\n```json\n" + JSON.stringify(e.content, null, 2) + "\n```\n";
|
|
314
|
+
}
|
|
315
|
+
if (e.reasoning_steps?.length) next.reasoning_steps = e.reasoning_steps;
|
|
316
|
+
if (e.extra_data?.reasoning_steps?.length) next.reasoning_steps = e.extra_data.reasoning_steps;
|
|
317
|
+
if (e.references?.length) next.references = e.references;
|
|
318
|
+
if (e.extra_data?.references?.length) next.references = e.extra_data.references;
|
|
319
|
+
if (e.citations) next.citations = e.citations;
|
|
320
|
+
const tools = toolsFromEvent(e);
|
|
321
|
+
if (tools.length) {
|
|
322
|
+
let toolCalls = message.tool_calls ?? [];
|
|
323
|
+
for (const tool of tools) toolCalls = mergeTool(toolCalls, tool);
|
|
324
|
+
next.tool_calls = toolCalls;
|
|
325
|
+
}
|
|
326
|
+
if (e.images?.length) next.images = e.images;
|
|
327
|
+
if (e.videos?.length) next.videos = e.videos;
|
|
328
|
+
if (e.audio?.length) next.audio = e.audio;
|
|
329
|
+
if (e.response_audio?.transcript) {
|
|
330
|
+
next.response_audio = {
|
|
331
|
+
...message.response_audio,
|
|
332
|
+
transcript: (message.response_audio?.transcript ?? "") + e.response_audio.transcript
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return next;
|
|
336
|
+
}
|
|
308
337
|
function activityLabel(e) {
|
|
309
338
|
const ev = name(e);
|
|
310
339
|
switch (ev) {
|
|
@@ -493,7 +522,6 @@ function useAgnoChat(options) {
|
|
|
493
522
|
const [sessionsLoading, setSessionsLoading] = react.useState(false);
|
|
494
523
|
const abortRef = react.useRef(null);
|
|
495
524
|
const activeMsgIdRef = react.useRef(null);
|
|
496
|
-
const lastContentRef = react.useRef("");
|
|
497
525
|
const runIdRef = react.useRef(void 0);
|
|
498
526
|
const entityRef = react.useRef(entity);
|
|
499
527
|
const sessionIdRef = react.useRef(options.sessionId);
|
|
@@ -546,37 +574,7 @@ function useAgnoChat(options) {
|
|
|
546
574
|
return;
|
|
547
575
|
}
|
|
548
576
|
if (isContentEvent(e)) {
|
|
549
|
-
patchActive((m) =>
|
|
550
|
-
const next = { ...m };
|
|
551
|
-
if (typeof e.content === "string" && e.content) {
|
|
552
|
-
const unique = e.content.startsWith(lastContentRef.current) ? e.content.slice(lastContentRef.current.length) : e.content;
|
|
553
|
-
next.content = (m.content ?? "") + unique;
|
|
554
|
-
lastContentRef.current = e.content.length >= lastContentRef.current.length ? e.content : lastContentRef.current;
|
|
555
|
-
} else if (e.content && typeof e.content === "object") {
|
|
556
|
-
next.content = (m.content ?? "") + "\n```json\n" + JSON.stringify(e.content, null, 2) + "\n```\n";
|
|
557
|
-
}
|
|
558
|
-
if (e.reasoning_steps?.length) next.reasoning_steps = e.reasoning_steps;
|
|
559
|
-
if (e.extra_data?.reasoning_steps?.length) next.reasoning_steps = e.extra_data.reasoning_steps;
|
|
560
|
-
if (e.references?.length) next.references = e.references;
|
|
561
|
-
if (e.extra_data?.references?.length) next.references = e.extra_data.references;
|
|
562
|
-
if (e.citations) next.citations = e.citations;
|
|
563
|
-
const tools = toolsFromEvent(e);
|
|
564
|
-
if (tools.length) {
|
|
565
|
-
let tc = m.tool_calls ?? [];
|
|
566
|
-
for (const t of tools) tc = mergeTool(tc, t);
|
|
567
|
-
next.tool_calls = tc;
|
|
568
|
-
}
|
|
569
|
-
if (e.images?.length) next.images = e.images;
|
|
570
|
-
if (e.videos?.length) next.videos = e.videos;
|
|
571
|
-
if (e.audio?.length) next.audio = e.audio;
|
|
572
|
-
if (e.response_audio?.transcript) {
|
|
573
|
-
next.response_audio = {
|
|
574
|
-
...m.response_audio,
|
|
575
|
-
transcript: (m.response_audio?.transcript ?? "") + e.response_audio.transcript
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
return next;
|
|
579
|
-
});
|
|
577
|
+
patchActive((m) => applyContentEvent(m, e));
|
|
580
578
|
return;
|
|
581
579
|
}
|
|
582
580
|
if (isReasoningStepEvent(e)) {
|
|
@@ -647,7 +645,6 @@ function useAgnoChat(options) {
|
|
|
647
645
|
abortRef.current = controller;
|
|
648
646
|
setError(null);
|
|
649
647
|
setStatus("streaming");
|
|
650
|
-
lastContentRef.current = "";
|
|
651
648
|
await starter({
|
|
652
649
|
signal: controller.signal,
|
|
653
650
|
onEvent: applyEvent,
|
|
@@ -808,7 +805,6 @@ function useAgnoChat(options) {
|
|
|
808
805
|
abortRef.current?.abort();
|
|
809
806
|
activeMsgIdRef.current = null;
|
|
810
807
|
runIdRef.current = void 0;
|
|
811
|
-
lastContentRef.current = "";
|
|
812
808
|
setEvents([]);
|
|
813
809
|
setCurrentEvent(null);
|
|
814
810
|
setStatus("idle");
|
|
@@ -846,7 +842,6 @@ function useAgnoChat(options) {
|
|
|
846
842
|
abortRef.current = null;
|
|
847
843
|
activeMsgIdRef.current = null;
|
|
848
844
|
runIdRef.current = void 0;
|
|
849
|
-
lastContentRef.current = "";
|
|
850
845
|
sessionIdRef.current = void 0;
|
|
851
846
|
setMessages([]);
|
|
852
847
|
setEvents([]);
|