@vegintech/langchain-react-agent 0.0.11 → 0.0.12
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.mjs +55 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -508,9 +508,60 @@ function DebugPanel({ messages, streamState, visible = true }) {
|
|
|
508
508
|
};
|
|
509
509
|
};
|
|
510
510
|
const formatContent = (content) => {
|
|
511
|
-
if (!content) return "
|
|
511
|
+
if (!content) return "";
|
|
512
512
|
return content;
|
|
513
513
|
};
|
|
514
|
+
const renderMessageContent = (message) => {
|
|
515
|
+
const hasToolCalls = message.tool_calls && Array.isArray(message.tool_calls) && message.tool_calls.length > 0;
|
|
516
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
517
|
+
style: {
|
|
518
|
+
display: "flex",
|
|
519
|
+
flexDirection: "column",
|
|
520
|
+
gap: "8px"
|
|
521
|
+
},
|
|
522
|
+
children: [message.content && /* @__PURE__ */ jsx("div", {
|
|
523
|
+
style: {
|
|
524
|
+
color: "#333",
|
|
525
|
+
lineHeight: 1.5,
|
|
526
|
+
wordBreak: "break-all"
|
|
527
|
+
},
|
|
528
|
+
children: formatContent(message.content)
|
|
529
|
+
}), hasToolCalls && /* @__PURE__ */ jsxs("div", {
|
|
530
|
+
style: {
|
|
531
|
+
marginTop: "4px",
|
|
532
|
+
padding: "8px",
|
|
533
|
+
background: "#f6ffed",
|
|
534
|
+
border: "1px solid #b7eb8f",
|
|
535
|
+
borderRadius: "6px"
|
|
536
|
+
},
|
|
537
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
538
|
+
style: {
|
|
539
|
+
fontSize: "11px",
|
|
540
|
+
fontWeight: 600,
|
|
541
|
+
color: "#389e0d",
|
|
542
|
+
marginBottom: "6px",
|
|
543
|
+
display: "flex",
|
|
544
|
+
alignItems: "center",
|
|
545
|
+
gap: "4px"
|
|
546
|
+
},
|
|
547
|
+
children: [/* @__PURE__ */ jsx("span", { children: "🔧" }), /* @__PURE__ */ jsxs("span", { children: [
|
|
548
|
+
"Tool Calls (",
|
|
549
|
+
message.tool_calls.length,
|
|
550
|
+
")"
|
|
551
|
+
] })]
|
|
552
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
553
|
+
style: {
|
|
554
|
+
...preStyle,
|
|
555
|
+
background: "#fff",
|
|
556
|
+
border: "1px solid #d9f7be",
|
|
557
|
+
maxHeight: "200px",
|
|
558
|
+
fontSize: "11px"
|
|
559
|
+
},
|
|
560
|
+
children: formatJson(message.tool_calls)
|
|
561
|
+
})]
|
|
562
|
+
})]
|
|
563
|
+
});
|
|
564
|
+
};
|
|
514
565
|
const buttonStyle = {
|
|
515
566
|
position: "fixed",
|
|
516
567
|
right: `${20 - buttonPos.x}px`,
|
|
@@ -547,8 +598,7 @@ function DebugPanel({ messages, streamState, visible = true }) {
|
|
|
547
598
|
display: "flex",
|
|
548
599
|
flexDirection: "column",
|
|
549
600
|
overflow: "hidden",
|
|
550
|
-
cursor: isDraggingDialog ? "grabbing" : "default"
|
|
551
|
-
userSelect: "none"
|
|
601
|
+
cursor: isDraggingDialog ? "grabbing" : "default"
|
|
552
602
|
};
|
|
553
603
|
const headerStyle = {
|
|
554
604
|
padding: "12px 16px",
|
|
@@ -756,14 +806,7 @@ function DebugPanel({ messages, streamState, visible = true }) {
|
|
|
756
806
|
}),
|
|
757
807
|
/* @__PURE__ */ jsx("td", {
|
|
758
808
|
style: tableCellStyle,
|
|
759
|
-
children:
|
|
760
|
-
style: {
|
|
761
|
-
color: "#333",
|
|
762
|
-
lineHeight: 1.5,
|
|
763
|
-
wordBreak: "break-all"
|
|
764
|
-
},
|
|
765
|
-
children: formatContent(message.content)
|
|
766
|
-
})
|
|
809
|
+
children: renderMessageContent(message)
|
|
767
810
|
})
|
|
768
811
|
]
|
|
769
812
|
}, index), isExpanded && /* @__PURE__ */ jsx("tr", {
|
|
@@ -1300,7 +1343,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
|
|
|
1300
1343
|
}, [submitToStream]);
|
|
1301
1344
|
const handleSend = useCallback(async (params) => {
|
|
1302
1345
|
let messages = [];
|
|
1303
|
-
if (onPreSend && params.message.trim()) messages = (await onPreSend(params)).messages.filter((m) => m != null);
|
|
1346
|
+
if (onPreSend && params.message.trim()) messages = (await onPreSend(params)).messages.filter((m) => m != null).map((m) => ({ ...m }));
|
|
1304
1347
|
else {
|
|
1305
1348
|
if (!params.message.trim()) return;
|
|
1306
1349
|
messages = [{
|