@vegintech/langchain-react-agent 0.0.6 → 0.0.8
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 +19 -2
- package/dist/index.mjs +15 -33
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import * as react from "react";
|
|
2
|
-
import { ReactNode } from "react";
|
|
2
|
+
import { CSSProperties, ReactNode } from "react";
|
|
3
3
|
import { Components } from "streamdown";
|
|
4
4
|
import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
|
+
/** ToolCard 各部件的样式配置 */
|
|
8
|
+
interface ToolCardStyles {
|
|
9
|
+
/** icon 容器的样式 */
|
|
10
|
+
icon?: CSSProperties;
|
|
11
|
+
/** prefix 文本的样式 */
|
|
12
|
+
prefix?: CSSProperties;
|
|
13
|
+
/** content 文本的样式 */
|
|
14
|
+
content?: CSSProperties;
|
|
15
|
+
}
|
|
7
16
|
/** ToolCard 组件 Props */
|
|
8
17
|
interface ToolCardProps {
|
|
9
18
|
/**
|
|
@@ -18,6 +27,14 @@ interface ToolCardProps {
|
|
|
18
27
|
* 左侧图标
|
|
19
28
|
*/
|
|
20
29
|
icon: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* 根节点样式
|
|
32
|
+
*/
|
|
33
|
+
style?: CSSProperties;
|
|
34
|
+
/**
|
|
35
|
+
* 各部件的样式配置,可分别设置 icon、prefix、content 的样式
|
|
36
|
+
*/
|
|
37
|
+
styles?: ToolCardStyles;
|
|
21
38
|
}
|
|
22
39
|
/** Interrupt 事件数据结构 */
|
|
23
40
|
interface InterruptEvent {
|
|
@@ -247,4 +264,4 @@ declare const AgentChat: react.ForwardRefExoticComponent<AgentChatProps & react.
|
|
|
247
264
|
*/
|
|
248
265
|
declare const ToolCard: React.FC<ToolCardProps>;
|
|
249
266
|
//#endregion
|
|
250
|
-
export { AgentChat, type AgentChatInputRef, type AgentChatProps, type AgentChatRef, type BackendTool, type ChatMessage, type ContextItem, type EmptyStateConfig, type FrontendTool, type InputConfig, type InterruptConfig, type InterruptEvent, type InterruptManagerProps, type InterruptRenderProps, type MessageConfig, type MessageType, type SenderCustomizationProps, type SenderSlotConfig, type SenderSubmitParams, type ToolCallInput, ToolCard, type ToolCardProps, type ToolDefinition, type ToolExecutionRecord, type ToolExecutionStatus, type ToolParameterSchema, type ToolRenderProps };
|
|
267
|
+
export { AgentChat, type AgentChatInputRef, type AgentChatProps, type AgentChatRef, type BackendTool, type ChatMessage, type ContextItem, type EmptyStateConfig, type FrontendTool, type InputConfig, type InterruptConfig, type InterruptEvent, type InterruptManagerProps, type InterruptRenderProps, type MessageConfig, type MessageType, type SenderCustomizationProps, type SenderSlotConfig, type SenderSubmitParams, type ToolCallInput, ToolCard, type ToolCardProps, type ToolCardStyles, type ToolDefinition, type ToolExecutionRecord, type ToolExecutionStatus, type ToolParameterSchema, type ToolRenderProps };
|
package/dist/index.mjs
CHANGED
|
@@ -208,22 +208,6 @@ const CustomParagraph = (props) => {
|
|
|
208
208
|
const { node, ...rest } = props;
|
|
209
209
|
return /* @__PURE__ */ jsx("span", { ...rest });
|
|
210
210
|
};
|
|
211
|
-
const renderMarkdown = (content, customComponents, securityConfig) => {
|
|
212
|
-
return /* @__PURE__ */ jsx(Streamdown, {
|
|
213
|
-
components: {
|
|
214
|
-
p: CustomParagraph,
|
|
215
|
-
...customComponents
|
|
216
|
-
},
|
|
217
|
-
allowedTags: securityConfig?.allowedTags,
|
|
218
|
-
literalTagContent: securityConfig?.literalTagContent,
|
|
219
|
-
controls: { table: {
|
|
220
|
-
copy: false,
|
|
221
|
-
download: false,
|
|
222
|
-
fullscreen: false
|
|
223
|
-
} },
|
|
224
|
-
children: content ?? ""
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
211
|
const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExecutions, components, securityConfig) => {
|
|
228
212
|
const hasToolCalls = message.toolCalls && message.toolCalls.length > 0;
|
|
229
213
|
const shouldBlink = isLastMessage && isLoading && !message.content && message.toolCalls?.length == 0;
|
|
@@ -267,19 +251,10 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
|
|
|
267
251
|
}, message.id);
|
|
268
252
|
};
|
|
269
253
|
const toBubbleItem = (message, isLastMessage, isLoading, tools, toolExecutions, components, securityConfig) => {
|
|
270
|
-
const hasReasoning = !!message.reasoningContent;
|
|
271
|
-
const hasToolCalls = message.toolCalls && message.toolCalls.length > 0;
|
|
272
|
-
if (hasReasoning || hasToolCalls) return {
|
|
273
|
-
key: message.id,
|
|
274
|
-
role: message.type === "human" ? "user" : "ai",
|
|
275
|
-
content: renderMessageContent(message, isLastMessage, isLoading, tools, toolExecutions, components, securityConfig),
|
|
276
|
-
placement: message.type === "human" ? "end" : "start"
|
|
277
|
-
};
|
|
278
254
|
return {
|
|
279
255
|
key: message.id,
|
|
280
256
|
role: message.type === "human" ? "user" : "ai",
|
|
281
|
-
content: message
|
|
282
|
-
contentRender: (content) => renderMarkdown(content, components, securityConfig),
|
|
257
|
+
content: renderMessageContent(message, isLastMessage, isLoading, tools, toolExecutions, components, securityConfig),
|
|
283
258
|
placement: message.type === "human" ? "end" : "start"
|
|
284
259
|
};
|
|
285
260
|
};
|
|
@@ -884,32 +859,39 @@ AgentChat.displayName = "AgentChat";
|
|
|
884
859
|
* ToolCard 组件 - 用于展示工具调用结果
|
|
885
860
|
* 样式:圆角矩形框,左侧 icon,label 分两行显示(prefix 小字体,content 默认字体)
|
|
886
861
|
*/
|
|
887
|
-
const ToolCard = ({ prefix, content, icon }) => {
|
|
862
|
+
const ToolCard = ({ prefix, content, icon, style, styles }) => {
|
|
888
863
|
return /* @__PURE__ */ jsxs("div", {
|
|
889
864
|
style: {
|
|
890
865
|
display: "inline-flex",
|
|
891
866
|
alignItems: "center",
|
|
892
867
|
gap: 8,
|
|
893
868
|
borderRadius: 8,
|
|
894
|
-
fontSize: 13
|
|
869
|
+
fontSize: 13,
|
|
870
|
+
...style
|
|
895
871
|
},
|
|
896
872
|
children: [/* @__PURE__ */ jsx("span", {
|
|
897
873
|
style: {
|
|
898
874
|
display: "flex",
|
|
899
|
-
alignItems: "center"
|
|
875
|
+
alignItems: "center",
|
|
876
|
+
...styles?.icon
|
|
900
877
|
},
|
|
901
878
|
children: icon
|
|
902
879
|
}), /* @__PURE__ */ jsxs("span", {
|
|
903
880
|
style: {
|
|
904
881
|
display: "flex",
|
|
905
882
|
alignItems: "center",
|
|
906
|
-
gap: 4
|
|
907
|
-
color: "rgba(0, 0, 0, 0.45)"
|
|
883
|
+
gap: 4
|
|
908
884
|
},
|
|
909
885
|
children: [/* @__PURE__ */ jsx("span", {
|
|
910
|
-
style: {
|
|
886
|
+
style: {
|
|
887
|
+
fontSize: 12,
|
|
888
|
+
...styles?.prefix
|
|
889
|
+
},
|
|
911
890
|
children: prefix
|
|
912
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
891
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
892
|
+
style: { ...styles?.content },
|
|
893
|
+
children: content
|
|
894
|
+
})]
|
|
913
895
|
})]
|
|
914
896
|
});
|
|
915
897
|
};
|