@vegintech/langchain-react-agent 0.0.37 → 0.0.40
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 +81 -14
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo
|
|
|
2
2
|
import { Actions, Bubble, Sender, Think, ThoughtChain } from "@ant-design/x";
|
|
3
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Streamdown } from "streamdown";
|
|
5
|
-
import { code } from "@streamdown/code";
|
|
6
5
|
import { useStream } from "@langchain/langgraph-sdk/react";
|
|
7
6
|
//#region src/components/ChatInput.tsx
|
|
8
7
|
const slotConfig = [];
|
|
@@ -181,12 +180,17 @@ const ContentBlock = ({ block, index, components, securityConfig }) => {
|
|
|
181
180
|
},
|
|
182
181
|
allowedTags: securityConfig?.allowedTags,
|
|
183
182
|
literalTagContent: securityConfig?.literalTagContent,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
183
|
+
controls: {
|
|
184
|
+
table: {
|
|
185
|
+
copy: false,
|
|
186
|
+
download: false,
|
|
187
|
+
fullscreen: false
|
|
188
|
+
},
|
|
189
|
+
code: {
|
|
190
|
+
copy: false,
|
|
191
|
+
download: false
|
|
192
|
+
}
|
|
193
|
+
},
|
|
190
194
|
children: String(block.text)
|
|
191
195
|
}, index);
|
|
192
196
|
if (block.type === "image_url" && "image_url" in block) {
|
|
@@ -243,11 +247,17 @@ const MessageContentRenderer = ({ content, components, securityConfig }) => {
|
|
|
243
247
|
},
|
|
244
248
|
allowedTags: securityConfig?.allowedTags,
|
|
245
249
|
literalTagContent: securityConfig?.literalTagContent,
|
|
246
|
-
controls: {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
controls: {
|
|
251
|
+
table: {
|
|
252
|
+
copy: false,
|
|
253
|
+
download: false,
|
|
254
|
+
fullscreen: false
|
|
255
|
+
},
|
|
256
|
+
code: {
|
|
257
|
+
copy: false,
|
|
258
|
+
download: false
|
|
259
|
+
}
|
|
260
|
+
},
|
|
251
261
|
children: content
|
|
252
262
|
});
|
|
253
263
|
return /* @__PURE__ */ jsx(Fragment, { children: content.map((block, index) => /* @__PURE__ */ jsx(ContentBlock, {
|
|
@@ -958,6 +968,59 @@ const styles = `
|
|
|
958
968
|
.tool-call-wrapper {
|
|
959
969
|
width: 100%;
|
|
960
970
|
}
|
|
971
|
+
|
|
972
|
+
/* 代码块卡片 - 自适应任意主题背景 */
|
|
973
|
+
[data-streamdown="code-block"] {
|
|
974
|
+
margin: 12px 0;
|
|
975
|
+
border: 1px solid rgba(128, 128, 128, 0.25);
|
|
976
|
+
border-radius: 8px;
|
|
977
|
+
overflow: hidden;
|
|
978
|
+
background-color: rgba(128, 128, 128, 0.12);
|
|
979
|
+
color: inherit;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
[data-streamdown="code-block-header"] {
|
|
983
|
+
display: flex;
|
|
984
|
+
align-items: center;
|
|
985
|
+
padding: 8px 16px;
|
|
986
|
+
background-color: rgba(128, 128, 128, 0.06);
|
|
987
|
+
border-bottom: 1px solid rgba(128, 128, 128, 0.2);
|
|
988
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
989
|
+
font-size: 12px;
|
|
990
|
+
color: inherit;
|
|
991
|
+
min-height: 36px;
|
|
992
|
+
box-sizing: border-box;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
[data-streamdown="code-block-header"] span {
|
|
996
|
+
font-family: inherit;
|
|
997
|
+
font-size: inherit;
|
|
998
|
+
color: inherit;
|
|
999
|
+
opacity: 0.65;
|
|
1000
|
+
text-transform: lowercase;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
[data-streamdown="code-block-body"] {
|
|
1004
|
+
background-color: transparent;
|
|
1005
|
+
padding: 16px;
|
|
1006
|
+
overflow-x: auto;
|
|
1007
|
+
max-width: 100%;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
[data-streamdown="code-block-body"] pre,
|
|
1011
|
+
[data-streamdown="code-block"] pre {
|
|
1012
|
+
margin: 0;
|
|
1013
|
+
padding: 0;
|
|
1014
|
+
background: transparent;
|
|
1015
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
1016
|
+
font-size: 13px;
|
|
1017
|
+
line-height: 1.6;
|
|
1018
|
+
color: inherit;
|
|
1019
|
+
white-space: pre-wrap;
|
|
1020
|
+
word-wrap: break-word;
|
|
1021
|
+
overflow-wrap: break-word;
|
|
1022
|
+
max-width: 100%;
|
|
1023
|
+
}
|
|
961
1024
|
`;
|
|
962
1025
|
let injected = false;
|
|
963
1026
|
function injectStyles() {
|
|
@@ -1144,7 +1207,8 @@ function DebugPanel({ streamState, visible = true }) {
|
|
|
1144
1207
|
startX: e.clientX,
|
|
1145
1208
|
startY: e.clientY,
|
|
1146
1209
|
initialX: buttonPos.x,
|
|
1147
|
-
initialY: buttonPos.y
|
|
1210
|
+
initialY: buttonPos.y,
|
|
1211
|
+
hasMoved: false
|
|
1148
1212
|
};
|
|
1149
1213
|
setIsDraggingButton(true);
|
|
1150
1214
|
}, [buttonPos]);
|
|
@@ -1164,6 +1228,7 @@ function DebugPanel({ streamState, visible = true }) {
|
|
|
1164
1228
|
if (isDraggingButton && buttonDragRef.current) {
|
|
1165
1229
|
const dx = e.clientX - buttonDragRef.current.startX;
|
|
1166
1230
|
const dy = e.clientY - buttonDragRef.current.startY;
|
|
1231
|
+
if (Math.abs(dx) > 3 || Math.abs(dy) > 3) buttonDragRef.current.hasMoved = true;
|
|
1167
1232
|
setButtonPos({
|
|
1168
1233
|
x: buttonDragRef.current.initialX + dx,
|
|
1169
1234
|
y: buttonDragRef.current.initialY + dy
|
|
@@ -1451,7 +1516,9 @@ function DebugPanel({ streamState, visible = true }) {
|
|
|
1451
1516
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
1452
1517
|
style: buttonStyle,
|
|
1453
1518
|
onMouseDown: handleButtonMouseDown,
|
|
1454
|
-
onClick: () =>
|
|
1519
|
+
onClick: () => {
|
|
1520
|
+
if (!buttonDragRef.current?.hasMoved) setIsOpen(true);
|
|
1521
|
+
},
|
|
1455
1522
|
title: "打开调试面板",
|
|
1456
1523
|
children: "🐛"
|
|
1457
1524
|
}), isOpen && /* @__PURE__ */ jsxs("div", {
|
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.40",
|
|
4
4
|
"description": "LangChain Agent UI component library for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/x": "^2.4.0",
|
|
27
27
|
"@langchain/langgraph-sdk": "^1.8.7",
|
|
28
|
-
"@streamdown/code": "catalog:",
|
|
29
28
|
"streamdown": "^2.5.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|