@vegintech/langchain-react-agent 0.0.23 → 0.0.24
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 -8
- package/dist/index.mjs +13 -20
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -211,8 +211,6 @@ interface MessageConfig {
|
|
|
211
211
|
literalTagContent?: string[];
|
|
212
212
|
/** Loading 动画颜色,支持 CSS 颜色值 */
|
|
213
213
|
loadingColor?: string;
|
|
214
|
-
/** 空状态配置 */
|
|
215
|
-
emptyState?: EmptyStateConfig;
|
|
216
214
|
}
|
|
217
215
|
/** 输入框配置 */
|
|
218
216
|
interface InputConfig extends SenderCustomizationProps {
|
|
@@ -240,6 +238,8 @@ interface AgentChatProps {
|
|
|
240
238
|
onAgentStateChange?: (state: Record<string, unknown>) => void;
|
|
241
239
|
/** 是否显示调试面板,默认 false。仅在开发环境生效 */
|
|
242
240
|
showDebug?: boolean;
|
|
241
|
+
/** 欢迎组件,当消息列表为空且非加载状态时显示 */
|
|
242
|
+
welcome?: ReactNode;
|
|
243
243
|
}
|
|
244
244
|
/** AgentChat 组件对外暴露的方法 */
|
|
245
245
|
interface AgentChatRef {
|
|
@@ -288,12 +288,6 @@ interface MessageListProps {
|
|
|
288
288
|
loadingColor?: string;
|
|
289
289
|
/** Interrupt 渲染函数,用于在消息列表中渲染中断 UI */
|
|
290
290
|
interruptRender?: () => ReactNode;
|
|
291
|
-
/** 空状态配置 */
|
|
292
|
-
emptyState?: {
|
|
293
|
-
/** 空状态标题 */title?: string; /** 空状态描述 */
|
|
294
|
-
description?: string; /** 自定义渲染 */
|
|
295
|
-
render?: () => ReactNode;
|
|
296
|
-
};
|
|
297
291
|
}
|
|
298
292
|
//#endregion
|
|
299
293
|
//#region src/components/AgentChat.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -314,7 +314,7 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
|
|
|
314
314
|
children: /* @__PURE__ */ jsx(ReasoningContent, { content: message.reasoningContent })
|
|
315
315
|
}),
|
|
316
316
|
!isContentEmpty && /* @__PURE__ */ jsx("div", {
|
|
317
|
-
style: { marginTop: message.
|
|
317
|
+
style: { marginTop: message.type == "human" ? "0px" : "8px" },
|
|
318
318
|
children: /* @__PURE__ */ jsx(MessageContentRenderer, {
|
|
319
319
|
content: message.content,
|
|
320
320
|
components,
|
|
@@ -378,7 +378,7 @@ const roleConfig = {
|
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
};
|
|
381
|
-
const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig, loadingColor, interruptRender
|
|
381
|
+
const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig, loadingColor, interruptRender }) => {
|
|
382
382
|
const reasoningCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
383
383
|
const processedMessages = useMemo(() => {
|
|
384
384
|
const cache = reasoningCacheRef.current;
|
|
@@ -444,19 +444,10 @@ const MessageList = ({ messages, isLoading = false, className = "", tools, toolE
|
|
|
444
444
|
placement: "start",
|
|
445
445
|
style: { paddingBlock: 0 }
|
|
446
446
|
}] : items;
|
|
447
|
-
if (allItems.length === 0) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
});
|
|
452
|
-
return /* @__PURE__ */ jsx("div", {
|
|
453
|
-
className: `agent-message-list empty ${className}`,
|
|
454
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
455
|
-
className: "agent-message-empty",
|
|
456
|
-
children: [emptyState?.title && /* @__PURE__ */ jsx("h4", { children: emptyState.title }), emptyState?.description ? /* @__PURE__ */ jsx("p", { children: emptyState.description }) : /* @__PURE__ */ jsx("p", { children: "开始对话吧" })]
|
|
457
|
-
})
|
|
458
|
-
});
|
|
459
|
-
}
|
|
447
|
+
if (allItems.length === 0) return /* @__PURE__ */ jsx("div", {
|
|
448
|
+
className: `agent-message-list empty ${className}`,
|
|
449
|
+
children: /* @__PURE__ */ jsx("div", { className: "agent-message-empty" })
|
|
450
|
+
});
|
|
460
451
|
return /* @__PURE__ */ jsx(Bubble.List, {
|
|
461
452
|
className: `agent-message-list ${className}`,
|
|
462
453
|
items: allItems,
|
|
@@ -1358,7 +1349,7 @@ function injectStyles() {
|
|
|
1358
1349
|
//#endregion
|
|
1359
1350
|
//#region src/components/AgentChat.tsx
|
|
1360
1351
|
injectStyles();
|
|
1361
|
-
const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
|
|
1352
|
+
const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug, welcome }, ref) => {
|
|
1362
1353
|
const { onPreSend, ...chatInputConfig } = inputConfig || {};
|
|
1363
1354
|
const chatInputRef = useRef(null);
|
|
1364
1355
|
const stream = useStream({
|
|
@@ -1475,13 +1466,16 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
|
|
|
1475
1466
|
onToolResultsBatch: handleToolResultsBatch,
|
|
1476
1467
|
completedToolResults: toolResults
|
|
1477
1468
|
});
|
|
1469
|
+
const shouldRenderWelcome = messages.length === 0 && !isLoading && welcome;
|
|
1478
1470
|
return /* @__PURE__ */ jsxs("div", {
|
|
1479
1471
|
className: `agent-chat-container ${className}`,
|
|
1480
1472
|
children: [
|
|
1481
|
-
/* @__PURE__ */ jsx(
|
|
1473
|
+
shouldRenderWelcome ? /* @__PURE__ */ jsx("div", {
|
|
1474
|
+
className: "agent-message-list agent-chat-welcome",
|
|
1475
|
+
children: welcome
|
|
1476
|
+
}) : /* @__PURE__ */ jsx(MessageList, {
|
|
1482
1477
|
messages,
|
|
1483
1478
|
isLoading: stream.isLoading,
|
|
1484
|
-
className: "agent-chat-messages",
|
|
1485
1479
|
tools,
|
|
1486
1480
|
toolExecutions,
|
|
1487
1481
|
components: messageConfig?.components,
|
|
@@ -1490,8 +1484,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
|
|
|
1490
1484
|
literalTagContent: messageConfig?.literalTagContent
|
|
1491
1485
|
},
|
|
1492
1486
|
loadingColor: messageConfig?.loadingColor,
|
|
1493
|
-
interruptRender
|
|
1494
|
-
emptyState: messageConfig?.emptyState
|
|
1487
|
+
interruptRender
|
|
1495
1488
|
}),
|
|
1496
1489
|
/* @__PURE__ */ jsx(ChatInput, {
|
|
1497
1490
|
ref: chatInputRef,
|