@vegintech/langchain-react-agent 0.0.14 → 0.0.16
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 +3 -23
- package/dist/index.mjs +4 -27
- package/package.json +2 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react from "react";
|
|
2
2
|
import React$1, { CSSProperties, ReactNode } from "react";
|
|
3
3
|
import { Components } from "streamdown";
|
|
4
|
-
import { BaseMessage } from "@langchain/core/messages";
|
|
5
4
|
import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
|
|
5
|
+
import { Message } from "@langchain/langgraph-sdk";
|
|
6
6
|
|
|
7
7
|
//#region src/types.d.ts
|
|
8
8
|
/** ToolCard 各部件的样式配置 */
|
|
@@ -89,7 +89,7 @@ interface SenderSubmitParams {
|
|
|
89
89
|
/** onPreSend 钩子返回值:只返回消息数组 */
|
|
90
90
|
interface PreSendResult {
|
|
91
91
|
/** 要发送的消息数组 */
|
|
92
|
-
messages:
|
|
92
|
+
messages: Message[];
|
|
93
93
|
}
|
|
94
94
|
/** Sender 组件的可定制参数 */
|
|
95
95
|
interface SenderCustomizationProps {
|
|
@@ -321,24 +321,4 @@ interface MessageContentRendererProps {
|
|
|
321
321
|
/** 消息内容渲染组件 - 支持字符串和多模态内容块 */
|
|
322
322
|
declare const MessageContentRenderer: React$1.FC<MessageContentRendererProps>;
|
|
323
323
|
//#endregion
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* 创建人类消息(HumanMessage)
|
|
327
|
-
* @param content 消息内容,可以是字符串或多模态内容块数组
|
|
328
|
-
* @returns HumanMessage 实例
|
|
329
|
-
* @example
|
|
330
|
-
* // 纯文本消息
|
|
331
|
-
* createHumanMessage("你好")
|
|
332
|
-
*
|
|
333
|
-
* // 多模态消息
|
|
334
|
-
* createHumanMessage([
|
|
335
|
-
* { type: "text", text: "看看这张图片" },
|
|
336
|
-
* { type: "image_url", image_url: { url: "https://example.com/image.png" } }
|
|
337
|
-
* ])
|
|
338
|
-
*/
|
|
339
|
-
declare function createHumanMessage(content: string | {
|
|
340
|
-
type: string;
|
|
341
|
-
[key: string]: unknown;
|
|
342
|
-
}[]): BaseMessage;
|
|
343
|
-
//#endregion
|
|
344
|
-
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 MessageContent, type MessageContentBlock, MessageContentRenderer, type MessageContentRendererProps, 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, createHumanMessage };
|
|
324
|
+
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 MessageContent, type MessageContentBlock, MessageContentRenderer, type MessageContentRendererProps, 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
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { useStream } from "@langchain/react";
|
|
3
2
|
import { Actions, Bubble, Sender, Think } from "@ant-design/x";
|
|
4
3
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { Streamdown } from "streamdown";
|
|
6
|
-
import {
|
|
5
|
+
import { useStream } from "@langchain/langgraph-sdk/react";
|
|
7
6
|
//#region src/components/ChatInput.tsx
|
|
8
7
|
const slotConfig = [];
|
|
9
8
|
const ChatInput = forwardRef(({ onSend, onStop, isLoading = false, disabled = false, placeholder = "输入消息...", className = "", onPasteFile, footer, skill: externalSkill, header, prefix }, ref) => {
|
|
@@ -1110,23 +1109,6 @@ function useToolExecution({ tools, toolCalls, isLoading = false, onExecutionChan
|
|
|
1110
1109
|
//#endregion
|
|
1111
1110
|
//#region src/utils/messageUtils.ts
|
|
1112
1111
|
/**
|
|
1113
|
-
* 创建人类消息(HumanMessage)
|
|
1114
|
-
* @param content 消息内容,可以是字符串或多模态内容块数组
|
|
1115
|
-
* @returns HumanMessage 实例
|
|
1116
|
-
* @example
|
|
1117
|
-
* // 纯文本消息
|
|
1118
|
-
* createHumanMessage("你好")
|
|
1119
|
-
*
|
|
1120
|
-
* // 多模态消息
|
|
1121
|
-
* createHumanMessage([
|
|
1122
|
-
* { type: "text", text: "看看这张图片" },
|
|
1123
|
-
* { type: "image_url", image_url: { url: "https://example.com/image.png" } }
|
|
1124
|
-
* ])
|
|
1125
|
-
*/
|
|
1126
|
-
function createHumanMessage(content) {
|
|
1127
|
-
return new HumanMessage({ content });
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
1112
|
* 从 BaseMessage 中提取 tool_calls
|
|
1131
1113
|
*/
|
|
1132
1114
|
function extractToolCalls(message) {
|
|
@@ -1350,7 +1332,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
|
|
|
1350
1332
|
useEffect(() => {
|
|
1351
1333
|
setInternalThreadId(externalThreadId);
|
|
1352
1334
|
}, [externalThreadId]);
|
|
1353
|
-
const {
|
|
1335
|
+
const { onPreSend, ...chatInputConfig } = inputConfig || {};
|
|
1354
1336
|
const chatInputRef = useRef(null);
|
|
1355
1337
|
useImperativeHandle(ref, () => ({
|
|
1356
1338
|
input: chatInputRef.current,
|
|
@@ -1482,12 +1464,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
|
|
|
1482
1464
|
onStop: handleStop,
|
|
1483
1465
|
isLoading: stream.isLoading,
|
|
1484
1466
|
className: "agent-chat-input",
|
|
1485
|
-
|
|
1486
|
-
skill,
|
|
1487
|
-
slotConfig,
|
|
1488
|
-
header,
|
|
1489
|
-
prefix,
|
|
1490
|
-
placeholder
|
|
1467
|
+
...chatInputConfig
|
|
1491
1468
|
}),
|
|
1492
1469
|
/* @__PURE__ */ jsx(DebugPanel, {
|
|
1493
1470
|
messages: stream.messages,
|
|
@@ -1541,4 +1518,4 @@ const ToolCard = ({ prefix, content, icon, style, styles }) => {
|
|
|
1541
1518
|
});
|
|
1542
1519
|
};
|
|
1543
1520
|
//#endregion
|
|
1544
|
-
export { AgentChat, MessageContentRenderer, ToolCard
|
|
1521
|
+
export { AgentChat, MessageContentRenderer, ToolCard };
|
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.16",
|
|
4
4
|
"description": "LangChain Agent UI component library for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/x": "^2.4.0",
|
|
27
|
-
"@langchain/
|
|
28
|
-
"@langchain/react": "^0.2.3",
|
|
27
|
+
"@langchain/langgraph-sdk": "^1.8.7",
|
|
29
28
|
"streamdown": "^2.5.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|