@vegintech/langchain-react-agent 0.0.31 → 0.0.32
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 +7 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -169,6 +169,8 @@ interface ToolRenderProps<TArgs = Record<string, unknown>> {
|
|
|
169
169
|
result?: unknown;
|
|
170
170
|
status: ToolExecutionStatus;
|
|
171
171
|
error?: string;
|
|
172
|
+
/** 是否正在加载 */
|
|
173
|
+
isLoading?: boolean;
|
|
172
174
|
}
|
|
173
175
|
/** 前端工具:需要完整的工具定义(用于前端执行) */
|
|
174
176
|
interface FrontendTool<TArgs = Record<string, unknown>> {
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ ChatInput.displayName = "ChatInput";
|
|
|
61
61
|
* 2. 支持自定义 render 函数
|
|
62
62
|
* 3. 默认渲染:简单的工具卡片样式
|
|
63
63
|
*/
|
|
64
|
-
const ToolCallRenderer = ({ tool, record }) => {
|
|
64
|
+
const ToolCallRenderer = ({ tool, record, isLoading }) => {
|
|
65
65
|
if (tool?.render) return /* @__PURE__ */ jsx("div", {
|
|
66
66
|
className: "tool-call-wrapper",
|
|
67
67
|
children: tool.render({
|
|
@@ -69,7 +69,8 @@ const ToolCallRenderer = ({ tool, record }) => {
|
|
|
69
69
|
args: record.args,
|
|
70
70
|
result: record.result,
|
|
71
71
|
status: record.status,
|
|
72
|
-
error: record.error
|
|
72
|
+
error: record.error,
|
|
73
|
+
isLoading
|
|
73
74
|
})
|
|
74
75
|
});
|
|
75
76
|
return /* @__PURE__ */ jsx(DefaultToolCallRenderer, { record });
|
|
@@ -324,7 +325,7 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
|
|
|
324
325
|
hasToolCalls && /* @__PURE__ */ jsx("div", {
|
|
325
326
|
className: "tool-calls-container",
|
|
326
327
|
style: { marginTop: !isContentEmpty ? "8px" : "0px" },
|
|
327
|
-
children: renderToolCalls(message.toolCalls, tools, toolExecutions)
|
|
328
|
+
children: renderToolCalls(message.toolCalls, tools, toolExecutions, isLoading)
|
|
328
329
|
})
|
|
329
330
|
]
|
|
330
331
|
}, message.id);
|
|
@@ -337,7 +338,7 @@ const toBubbleItem = (message, isLastMessage, isLoading, tools, toolExecutions,
|
|
|
337
338
|
placement: message.type === "human" ? "end" : "start"
|
|
338
339
|
};
|
|
339
340
|
};
|
|
340
|
-
const renderToolCalls = (toolCalls, tools, toolExecutions) => {
|
|
341
|
+
const renderToolCalls = (toolCalls, tools, toolExecutions, isLoading) => {
|
|
341
342
|
return toolCalls.map((call) => {
|
|
342
343
|
const tool = findTool(tools, call.name);
|
|
343
344
|
let record;
|
|
@@ -360,7 +361,8 @@ const renderToolCalls = (toolCalls, tools, toolExecutions) => {
|
|
|
360
361
|
};
|
|
361
362
|
return /* @__PURE__ */ jsx(ToolCallRenderer, {
|
|
362
363
|
tool,
|
|
363
|
-
record
|
|
364
|
+
record,
|
|
365
|
+
isLoading
|
|
364
366
|
}, call.id);
|
|
365
367
|
}).filter(Boolean);
|
|
366
368
|
};
|