@vegintech/langchain-react-agent 0.0.9 → 0.0.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/dist/index.d.mts +2 -0
- package/dist/index.mjs +460 -29
- package/package.json +8 -9
package/dist/index.d.mts
CHANGED
|
@@ -241,6 +241,8 @@ interface AgentChatProps {
|
|
|
241
241
|
agentState?: Record<string, unknown>;
|
|
242
242
|
/** Agent 状态变化回调 */
|
|
243
243
|
onAgentStateChange?: (state: Record<string, unknown>) => void;
|
|
244
|
+
/** 是否显示调试面板,默认 false。仅在开发环境生效 */
|
|
245
|
+
showDebug?: boolean;
|
|
244
246
|
}
|
|
245
247
|
/** AgentChat 组件对外暴露的方法 */
|
|
246
248
|
interface AgentChatRef {
|
package/dist/index.mjs
CHANGED
|
@@ -226,7 +226,7 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
|
|
|
226
226
|
children: /* @__PURE__ */ jsx(ReasoningContent, { content: message.reasoningContent })
|
|
227
227
|
}),
|
|
228
228
|
message.content && /* @__PURE__ */ jsx("div", {
|
|
229
|
-
style: { marginTop: message.reasoningContent ? "8px" :
|
|
229
|
+
style: { marginTop: message.reasoningContent ? "8px" : "3px" },
|
|
230
230
|
children: /* @__PURE__ */ jsx(Streamdown, {
|
|
231
231
|
components: {
|
|
232
232
|
p: CustomParagraph,
|
|
@@ -377,6 +377,429 @@ const MessageList = ({ messages, isLoading = false, className = "", tools, toolE
|
|
|
377
377
|
});
|
|
378
378
|
};
|
|
379
379
|
//#endregion
|
|
380
|
+
//#region src/components/DebugPanel.tsx
|
|
381
|
+
const isDevelopment = () => {
|
|
382
|
+
if (typeof process !== "undefined" && process.env) return process.env.NODE_ENV === "development";
|
|
383
|
+
const viteEnv = import.meta.env;
|
|
384
|
+
if (typeof import.meta !== "undefined" && viteEnv) return viteEnv.DEV === true || viteEnv.MODE === "development";
|
|
385
|
+
return false;
|
|
386
|
+
};
|
|
387
|
+
function DebugPanel({ messages, streamState, visible = true }) {
|
|
388
|
+
if (!isDevelopment() || !visible) return null;
|
|
389
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
390
|
+
const [activeTab, setActiveTab] = useState("messages");
|
|
391
|
+
const [expandedRows, setExpandedRows] = useState(/* @__PURE__ */ new Set());
|
|
392
|
+
const [buttonPos, setButtonPos] = useState({
|
|
393
|
+
x: 0,
|
|
394
|
+
y: 0
|
|
395
|
+
});
|
|
396
|
+
const [isDraggingButton, setIsDraggingButton] = useState(false);
|
|
397
|
+
const buttonDragRef = useRef(null);
|
|
398
|
+
const [dialogPos, setDialogPos] = useState({
|
|
399
|
+
x: 0,
|
|
400
|
+
y: 0
|
|
401
|
+
});
|
|
402
|
+
const [isDraggingDialog, setIsDraggingDialog] = useState(false);
|
|
403
|
+
const dialogDragRef = useRef(null);
|
|
404
|
+
const handleButtonMouseDown = useCallback((e) => {
|
|
405
|
+
e.preventDefault();
|
|
406
|
+
buttonDragRef.current = {
|
|
407
|
+
startX: e.clientX,
|
|
408
|
+
startY: e.clientY,
|
|
409
|
+
initialX: buttonPos.x,
|
|
410
|
+
initialY: buttonPos.y
|
|
411
|
+
};
|
|
412
|
+
setIsDraggingButton(true);
|
|
413
|
+
}, [buttonPos]);
|
|
414
|
+
const handleDialogMouseDown = useCallback((e) => {
|
|
415
|
+
if (!e.target.closest(".debug-panel-header")) return;
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
dialogDragRef.current = {
|
|
418
|
+
startX: e.clientX,
|
|
419
|
+
startY: e.clientY,
|
|
420
|
+
initialX: dialogPos.x,
|
|
421
|
+
initialY: dialogPos.y
|
|
422
|
+
};
|
|
423
|
+
setIsDraggingDialog(true);
|
|
424
|
+
}, [dialogPos]);
|
|
425
|
+
useEffect(() => {
|
|
426
|
+
const handleMouseMove = (e) => {
|
|
427
|
+
if (isDraggingButton && buttonDragRef.current) {
|
|
428
|
+
const dx = e.clientX - buttonDragRef.current.startX;
|
|
429
|
+
const dy = e.clientY - buttonDragRef.current.startY;
|
|
430
|
+
setButtonPos({
|
|
431
|
+
x: buttonDragRef.current.initialX + dx,
|
|
432
|
+
y: buttonDragRef.current.initialY + dy
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
if (isDraggingDialog && dialogDragRef.current) {
|
|
436
|
+
const dx = e.clientX - dialogDragRef.current.startX;
|
|
437
|
+
const dy = e.clientY - dialogDragRef.current.startY;
|
|
438
|
+
setDialogPos({
|
|
439
|
+
x: dialogDragRef.current.initialX + dx,
|
|
440
|
+
y: dialogDragRef.current.initialY + dy
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
const handleMouseUp = () => {
|
|
445
|
+
setIsDraggingButton(false);
|
|
446
|
+
setIsDraggingDialog(false);
|
|
447
|
+
buttonDragRef.current = null;
|
|
448
|
+
dialogDragRef.current = null;
|
|
449
|
+
};
|
|
450
|
+
if (isDraggingButton || isDraggingDialog) {
|
|
451
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
452
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
453
|
+
}
|
|
454
|
+
return () => {
|
|
455
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
456
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
457
|
+
};
|
|
458
|
+
}, [isDraggingButton, isDraggingDialog]);
|
|
459
|
+
const formatJson = (data) => {
|
|
460
|
+
try {
|
|
461
|
+
return JSON.stringify(data, null, 2);
|
|
462
|
+
} catch {
|
|
463
|
+
return String(data);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
const toggleRow = (index) => {
|
|
467
|
+
setExpandedRows((prev) => {
|
|
468
|
+
const next = new Set(prev);
|
|
469
|
+
if (next.has(index)) next.delete(index);
|
|
470
|
+
else next.add(index);
|
|
471
|
+
return next;
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
const getTypeTagStyle = (type) => {
|
|
475
|
+
const color = {
|
|
476
|
+
human: {
|
|
477
|
+
bg: "#e6f4ff",
|
|
478
|
+
color: "#0958d9"
|
|
479
|
+
},
|
|
480
|
+
ai: {
|
|
481
|
+
bg: "#f6ffed",
|
|
482
|
+
color: "#389e0d"
|
|
483
|
+
},
|
|
484
|
+
tool: {
|
|
485
|
+
bg: "#fff7e6",
|
|
486
|
+
color: "#d46b08"
|
|
487
|
+
},
|
|
488
|
+
system: {
|
|
489
|
+
bg: "#f9f0ff",
|
|
490
|
+
color: "#722ed1"
|
|
491
|
+
},
|
|
492
|
+
function: {
|
|
493
|
+
bg: "#fff2f0",
|
|
494
|
+
color: "#cf1322"
|
|
495
|
+
}
|
|
496
|
+
}[type || ""] || {
|
|
497
|
+
bg: "#f5f5f5",
|
|
498
|
+
color: "#666"
|
|
499
|
+
};
|
|
500
|
+
return {
|
|
501
|
+
display: "inline-block",
|
|
502
|
+
padding: "2px 8px",
|
|
503
|
+
borderRadius: "4px",
|
|
504
|
+
fontSize: "12px",
|
|
505
|
+
fontWeight: 500,
|
|
506
|
+
background: color.bg,
|
|
507
|
+
color: color.color
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
const formatContent = (content) => {
|
|
511
|
+
if (!content) return "-";
|
|
512
|
+
return content;
|
|
513
|
+
};
|
|
514
|
+
const buttonStyle = {
|
|
515
|
+
position: "fixed",
|
|
516
|
+
right: `${20 - buttonPos.x}px`,
|
|
517
|
+
bottom: `${20 - buttonPos.y}px`,
|
|
518
|
+
width: "48px",
|
|
519
|
+
height: "48px",
|
|
520
|
+
borderRadius: "50%",
|
|
521
|
+
background: "#1677ff",
|
|
522
|
+
color: "#fff",
|
|
523
|
+
border: "none",
|
|
524
|
+
cursor: isDraggingButton ? "grabbing" : "grab",
|
|
525
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
526
|
+
display: "flex",
|
|
527
|
+
alignItems: "center",
|
|
528
|
+
justifyContent: "center",
|
|
529
|
+
fontSize: "20px",
|
|
530
|
+
zIndex: 9998,
|
|
531
|
+
transition: isDraggingButton ? "none" : "box-shadow 0.2s",
|
|
532
|
+
userSelect: "none"
|
|
533
|
+
};
|
|
534
|
+
const dialogStyle = {
|
|
535
|
+
position: "fixed",
|
|
536
|
+
left: "50%",
|
|
537
|
+
top: "50%",
|
|
538
|
+
transform: `translate(calc(-50% + ${dialogPos.x}px), calc(-50% + ${dialogPos.y}px))`,
|
|
539
|
+
width: "1000px",
|
|
540
|
+
maxWidth: "90vw",
|
|
541
|
+
height: "650px",
|
|
542
|
+
maxHeight: "85vh",
|
|
543
|
+
background: "#fff",
|
|
544
|
+
borderRadius: "12px",
|
|
545
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.2)",
|
|
546
|
+
zIndex: 9999,
|
|
547
|
+
display: "flex",
|
|
548
|
+
flexDirection: "column",
|
|
549
|
+
overflow: "hidden",
|
|
550
|
+
cursor: isDraggingDialog ? "grabbing" : "default",
|
|
551
|
+
userSelect: "none"
|
|
552
|
+
};
|
|
553
|
+
const headerStyle = {
|
|
554
|
+
padding: "12px 16px",
|
|
555
|
+
background: "#f5f5f5",
|
|
556
|
+
borderBottom: "1px solid #e8e8e8",
|
|
557
|
+
display: "flex",
|
|
558
|
+
alignItems: "center",
|
|
559
|
+
justifyContent: "space-between",
|
|
560
|
+
cursor: isDraggingDialog ? "grabbing" : "grab"
|
|
561
|
+
};
|
|
562
|
+
const tabContainerStyle = {
|
|
563
|
+
display: "flex",
|
|
564
|
+
gap: "8px"
|
|
565
|
+
};
|
|
566
|
+
const getTabStyle = (isActive) => ({
|
|
567
|
+
padding: "6px 16px",
|
|
568
|
+
borderRadius: "6px",
|
|
569
|
+
border: "none",
|
|
570
|
+
background: isActive ? "#1677ff" : "transparent",
|
|
571
|
+
color: isActive ? "#fff" : "#666",
|
|
572
|
+
cursor: "pointer",
|
|
573
|
+
fontSize: "14px",
|
|
574
|
+
transition: "all 0.2s"
|
|
575
|
+
});
|
|
576
|
+
const closeButtonStyle = {
|
|
577
|
+
width: "28px",
|
|
578
|
+
height: "28px",
|
|
579
|
+
borderRadius: "50%",
|
|
580
|
+
border: "none",
|
|
581
|
+
background: "#ff4d4f",
|
|
582
|
+
color: "#fff",
|
|
583
|
+
cursor: "pointer",
|
|
584
|
+
display: "flex",
|
|
585
|
+
alignItems: "center",
|
|
586
|
+
justifyContent: "center",
|
|
587
|
+
fontSize: "16px",
|
|
588
|
+
transition: "background 0.2s"
|
|
589
|
+
};
|
|
590
|
+
const contentStyle = {
|
|
591
|
+
flex: 1,
|
|
592
|
+
overflow: "auto",
|
|
593
|
+
padding: "16px",
|
|
594
|
+
background: "#fafafa"
|
|
595
|
+
};
|
|
596
|
+
const preStyle = {
|
|
597
|
+
margin: 0,
|
|
598
|
+
padding: "12px",
|
|
599
|
+
background: "#f8f9fa",
|
|
600
|
+
color: "#333",
|
|
601
|
+
borderRadius: "8px",
|
|
602
|
+
fontSize: "12px",
|
|
603
|
+
fontFamily: "\"Fira Code\", \"Monaco\", \"Consolas\", monospace",
|
|
604
|
+
lineHeight: 1.5,
|
|
605
|
+
overflow: "auto",
|
|
606
|
+
whiteSpace: "pre-wrap",
|
|
607
|
+
wordBreak: "break-word",
|
|
608
|
+
border: "1px solid #e8e8e8"
|
|
609
|
+
};
|
|
610
|
+
const statsStyle = {
|
|
611
|
+
padding: "8px 12px",
|
|
612
|
+
background: "#e6f4ff",
|
|
613
|
+
borderRadius: "6px",
|
|
614
|
+
marginBottom: "12px",
|
|
615
|
+
fontSize: "13px",
|
|
616
|
+
color: "#0958d9"
|
|
617
|
+
};
|
|
618
|
+
const tableStyle = {
|
|
619
|
+
width: "100%",
|
|
620
|
+
borderCollapse: "collapse",
|
|
621
|
+
fontSize: "13px",
|
|
622
|
+
background: "#fff",
|
|
623
|
+
borderRadius: "8px",
|
|
624
|
+
overflow: "hidden",
|
|
625
|
+
boxShadow: "0 1px 2px rgba(0, 0, 0, 0.05)"
|
|
626
|
+
};
|
|
627
|
+
const tableHeaderStyle = {
|
|
628
|
+
background: "#f5f5f5",
|
|
629
|
+
fontWeight: 600,
|
|
630
|
+
color: "#333",
|
|
631
|
+
textAlign: "left",
|
|
632
|
+
padding: "10px 12px",
|
|
633
|
+
borderBottom: "1px solid #e8e8e8",
|
|
634
|
+
whiteSpace: "nowrap"
|
|
635
|
+
};
|
|
636
|
+
const tableCellStyle = {
|
|
637
|
+
padding: "10px 12px",
|
|
638
|
+
borderBottom: "1px solid #f0f0f0",
|
|
639
|
+
verticalAlign: "top"
|
|
640
|
+
};
|
|
641
|
+
const expandButtonStyle = {
|
|
642
|
+
width: "20px",
|
|
643
|
+
height: "20px",
|
|
644
|
+
border: "none",
|
|
645
|
+
background: "transparent",
|
|
646
|
+
cursor: "pointer",
|
|
647
|
+
display: "flex",
|
|
648
|
+
alignItems: "center",
|
|
649
|
+
justifyContent: "center",
|
|
650
|
+
fontSize: "12px",
|
|
651
|
+
color: "#666",
|
|
652
|
+
borderRadius: "4px",
|
|
653
|
+
transition: "background 0.2s"
|
|
654
|
+
};
|
|
655
|
+
const expandedRowStyle = { background: "#fafafa" };
|
|
656
|
+
const jsonContainerStyle = {
|
|
657
|
+
padding: "12px",
|
|
658
|
+
background: "#fff",
|
|
659
|
+
borderRadius: "6px",
|
|
660
|
+
margin: "8px 0",
|
|
661
|
+
border: "1px solid #e8e8e8"
|
|
662
|
+
};
|
|
663
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
664
|
+
style: buttonStyle,
|
|
665
|
+
onMouseDown: handleButtonMouseDown,
|
|
666
|
+
onClick: () => !isDraggingButton && setIsOpen(true),
|
|
667
|
+
title: "打开调试面板",
|
|
668
|
+
children: "🐛"
|
|
669
|
+
}), isOpen && /* @__PURE__ */ jsxs("div", {
|
|
670
|
+
style: dialogStyle,
|
|
671
|
+
onMouseDown: handleDialogMouseDown,
|
|
672
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
673
|
+
className: "debug-panel-header",
|
|
674
|
+
style: headerStyle,
|
|
675
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
676
|
+
style: tabContainerStyle,
|
|
677
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
678
|
+
style: getTabStyle(activeTab === "messages"),
|
|
679
|
+
onClick: () => setActiveTab("messages"),
|
|
680
|
+
children: [
|
|
681
|
+
"Messages (",
|
|
682
|
+
messages.length,
|
|
683
|
+
")"
|
|
684
|
+
]
|
|
685
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
686
|
+
style: getTabStyle(activeTab === "state"),
|
|
687
|
+
onClick: () => setActiveTab("state"),
|
|
688
|
+
children: "State"
|
|
689
|
+
})]
|
|
690
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
691
|
+
style: closeButtonStyle,
|
|
692
|
+
onClick: () => setIsOpen(false),
|
|
693
|
+
title: "关闭",
|
|
694
|
+
children: "×"
|
|
695
|
+
})]
|
|
696
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
697
|
+
style: contentStyle,
|
|
698
|
+
children: activeTab === "messages" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
699
|
+
style: statsStyle,
|
|
700
|
+
children: [
|
|
701
|
+
"共 ",
|
|
702
|
+
messages.length,
|
|
703
|
+
" 条消息"
|
|
704
|
+
]
|
|
705
|
+
}), /* @__PURE__ */ jsxs("table", {
|
|
706
|
+
style: tableStyle,
|
|
707
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
708
|
+
/* @__PURE__ */ jsx("th", { style: {
|
|
709
|
+
...tableHeaderStyle,
|
|
710
|
+
width: "30px"
|
|
711
|
+
} }),
|
|
712
|
+
/* @__PURE__ */ jsx("th", {
|
|
713
|
+
style: {
|
|
714
|
+
...tableHeaderStyle,
|
|
715
|
+
width: "60px"
|
|
716
|
+
},
|
|
717
|
+
children: "类型"
|
|
718
|
+
}),
|
|
719
|
+
/* @__PURE__ */ jsx("th", {
|
|
720
|
+
style: tableHeaderStyle,
|
|
721
|
+
children: "内容"
|
|
722
|
+
})
|
|
723
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: messages.map((msg, index) => {
|
|
724
|
+
const message = msg;
|
|
725
|
+
const isExpanded = expandedRows.has(index);
|
|
726
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("tr", {
|
|
727
|
+
style: {
|
|
728
|
+
cursor: "pointer",
|
|
729
|
+
transition: "background 0.2s"
|
|
730
|
+
},
|
|
731
|
+
onClick: () => toggleRow(index),
|
|
732
|
+
onMouseEnter: (e) => {
|
|
733
|
+
e.currentTarget.style.background = "#f5f5f5";
|
|
734
|
+
},
|
|
735
|
+
onMouseLeave: (e) => {
|
|
736
|
+
e.currentTarget.style.background = "transparent";
|
|
737
|
+
},
|
|
738
|
+
children: [
|
|
739
|
+
/* @__PURE__ */ jsx("td", {
|
|
740
|
+
style: tableCellStyle,
|
|
741
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
742
|
+
style: expandButtonStyle,
|
|
743
|
+
onClick: (e) => {
|
|
744
|
+
e.stopPropagation();
|
|
745
|
+
toggleRow(index);
|
|
746
|
+
},
|
|
747
|
+
children: isExpanded ? "▼" : "▶"
|
|
748
|
+
})
|
|
749
|
+
}),
|
|
750
|
+
/* @__PURE__ */ jsx("td", {
|
|
751
|
+
style: tableCellStyle,
|
|
752
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
753
|
+
style: getTypeTagStyle(message.type),
|
|
754
|
+
children: message.type || "unknown"
|
|
755
|
+
})
|
|
756
|
+
}),
|
|
757
|
+
/* @__PURE__ */ jsx("td", {
|
|
758
|
+
style: tableCellStyle,
|
|
759
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
760
|
+
style: {
|
|
761
|
+
color: "#333",
|
|
762
|
+
lineHeight: 1.5,
|
|
763
|
+
wordBreak: "break-all"
|
|
764
|
+
},
|
|
765
|
+
children: formatContent(message.content)
|
|
766
|
+
})
|
|
767
|
+
})
|
|
768
|
+
]
|
|
769
|
+
}, index), isExpanded && /* @__PURE__ */ jsx("tr", {
|
|
770
|
+
style: expandedRowStyle,
|
|
771
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
772
|
+
colSpan: 3,
|
|
773
|
+
style: {
|
|
774
|
+
padding: 0,
|
|
775
|
+
borderBottom: "1px solid #e8e8e8"
|
|
776
|
+
},
|
|
777
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
778
|
+
style: jsonContainerStyle,
|
|
779
|
+
children: /* @__PURE__ */ jsx("pre", {
|
|
780
|
+
style: {
|
|
781
|
+
...preStyle,
|
|
782
|
+
margin: 0,
|
|
783
|
+
maxHeight: "300px",
|
|
784
|
+
overflow: "auto"
|
|
785
|
+
},
|
|
786
|
+
children: formatJson(message)
|
|
787
|
+
})
|
|
788
|
+
})
|
|
789
|
+
})
|
|
790
|
+
})] });
|
|
791
|
+
}) })]
|
|
792
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
793
|
+
style: statsStyle,
|
|
794
|
+
children: ["State 键数量: ", Object.keys(streamState).length]
|
|
795
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
796
|
+
style: preStyle,
|
|
797
|
+
children: formatJson(streamState)
|
|
798
|
+
})] })
|
|
799
|
+
})]
|
|
800
|
+
})] });
|
|
801
|
+
}
|
|
802
|
+
//#endregion
|
|
380
803
|
//#region src/hooks/useInterrupt.tsx
|
|
381
804
|
/**
|
|
382
805
|
* InterruptManager - 管理 Interrupt 状态的 Hook
|
|
@@ -786,7 +1209,7 @@ function injectStyles() {
|
|
|
786
1209
|
//#endregion
|
|
787
1210
|
//#region src/components/AgentChat.tsx
|
|
788
1211
|
injectStyles();
|
|
789
|
-
const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: externalThreadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange }, ref) => {
|
|
1212
|
+
const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: externalThreadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
|
|
790
1213
|
const [internalThreadId, setInternalThreadId] = useState(externalThreadId);
|
|
791
1214
|
useEffect(() => {
|
|
792
1215
|
setInternalThreadId(externalThreadId);
|
|
@@ -901,33 +1324,41 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
|
|
|
901
1324
|
});
|
|
902
1325
|
return /* @__PURE__ */ jsxs("div", {
|
|
903
1326
|
className: `agent-chat-container ${className}`,
|
|
904
|
-
children: [
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1327
|
+
children: [
|
|
1328
|
+
/* @__PURE__ */ jsx(MessageList, {
|
|
1329
|
+
messages,
|
|
1330
|
+
isLoading: stream.isLoading,
|
|
1331
|
+
className: "agent-chat-messages",
|
|
1332
|
+
tools,
|
|
1333
|
+
toolExecutions,
|
|
1334
|
+
components: messageConfig?.components,
|
|
1335
|
+
securityConfig: {
|
|
1336
|
+
allowedTags: messageConfig?.allowedTags,
|
|
1337
|
+
literalTagContent: messageConfig?.literalTagContent
|
|
1338
|
+
},
|
|
1339
|
+
loadingColor: messageConfig?.loadingColor,
|
|
1340
|
+
interruptRender,
|
|
1341
|
+
emptyState: messageConfig?.emptyState
|
|
1342
|
+
}),
|
|
1343
|
+
/* @__PURE__ */ jsx(ChatInput, {
|
|
1344
|
+
ref: chatInputRef,
|
|
1345
|
+
onSend: handleSend,
|
|
1346
|
+
onStop: handleStop,
|
|
1347
|
+
isLoading: stream.isLoading,
|
|
1348
|
+
className: "agent-chat-input",
|
|
1349
|
+
footer,
|
|
1350
|
+
skill,
|
|
1351
|
+
slotConfig,
|
|
1352
|
+
header,
|
|
1353
|
+
prefix,
|
|
1354
|
+
placeholder
|
|
1355
|
+
}),
|
|
1356
|
+
/* @__PURE__ */ jsx(DebugPanel, {
|
|
1357
|
+
messages: stream.messages,
|
|
1358
|
+
streamState: stream.values || {},
|
|
1359
|
+
visible: showDebug
|
|
1360
|
+
})
|
|
1361
|
+
]
|
|
931
1362
|
});
|
|
932
1363
|
});
|
|
933
1364
|
AgentChat.displayName = "AgentChat";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vegintech/langchain-react-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "LangChain Agent UI component library for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,13 +15,6 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "vp pack",
|
|
20
|
-
"dev": "vp pack --watch",
|
|
21
|
-
"test": "vp test",
|
|
22
|
-
"check": "vp check",
|
|
23
|
-
"prepublishOnly": "vp run build"
|
|
24
|
-
},
|
|
25
18
|
"dependencies": {
|
|
26
19
|
"@ant-design/x": "^2.4.0",
|
|
27
20
|
"@langchain/core": "^1.1.36",
|
|
@@ -43,5 +36,11 @@
|
|
|
43
36
|
"peerDependencies": {
|
|
44
37
|
"react": ">=18.0.0",
|
|
45
38
|
"react-dom": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "vp pack",
|
|
42
|
+
"dev": "vp pack --watch",
|
|
43
|
+
"test": "vp test",
|
|
44
|
+
"check": "vp check"
|
|
46
45
|
}
|
|
47
|
-
}
|
|
46
|
+
}
|