@vegintech/langchain-react-agent 0.0.13 → 0.0.15
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 +5 -23
- package/dist/index.mjs +4 -21
- 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 {
|
|
@@ -103,6 +103,8 @@ interface SenderCustomizationProps {
|
|
|
103
103
|
header?: BaseNode | NodeRender;
|
|
104
104
|
/** 前缀区域 */
|
|
105
105
|
prefix?: BaseNode | NodeRender;
|
|
106
|
+
/** 粘贴文件时的回调函数 */
|
|
107
|
+
onPasteFile?: (files: FileList) => void;
|
|
106
108
|
}
|
|
107
109
|
/** ChatInput 组件对外暴露的方法 */
|
|
108
110
|
interface AgentChatInputRef {
|
|
@@ -319,24 +321,4 @@ interface MessageContentRendererProps {
|
|
|
319
321
|
/** 消息内容渲染组件 - 支持字符串和多模态内容块 */
|
|
320
322
|
declare const MessageContentRenderer: React$1.FC<MessageContentRendererProps>;
|
|
321
323
|
//#endregion
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* 创建人类消息(HumanMessage)
|
|
325
|
-
* @param content 消息内容,可以是字符串或多模态内容块数组
|
|
326
|
-
* @returns HumanMessage 实例
|
|
327
|
-
* @example
|
|
328
|
-
* // 纯文本消息
|
|
329
|
-
* createHumanMessage("你好")
|
|
330
|
-
*
|
|
331
|
-
* // 多模态消息
|
|
332
|
-
* createHumanMessage([
|
|
333
|
-
* { type: "text", text: "看看这张图片" },
|
|
334
|
-
* { type: "image_url", image_url: { url: "https://example.com/image.png" } }
|
|
335
|
-
* ])
|
|
336
|
-
*/
|
|
337
|
-
declare function createHumanMessage(content: string | {
|
|
338
|
-
type: string;
|
|
339
|
-
[key: string]: unknown;
|
|
340
|
-
}[]): BaseMessage;
|
|
341
|
-
//#endregion
|
|
342
|
-
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,12 +1,11 @@
|
|
|
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
|
-
const ChatInput = forwardRef(({ onSend, onStop, isLoading = false, disabled = false, placeholder = "输入消息...", className = "", footer, skill: externalSkill, header, prefix }, ref) => {
|
|
8
|
+
const ChatInput = forwardRef(({ onSend, onStop, isLoading = false, disabled = false, placeholder = "输入消息...", className = "", onPasteFile, footer, skill: externalSkill, header, prefix }, ref) => {
|
|
10
9
|
const senderRef = useRef(null);
|
|
11
10
|
const [internalSkill, setInternalSkill] = useState(externalSkill);
|
|
12
11
|
useImperativeHandle(ref, () => ({
|
|
@@ -39,6 +38,7 @@ const ChatInput = forwardRef(({ onSend, onStop, isLoading = false, disabled = fa
|
|
|
39
38
|
disabled,
|
|
40
39
|
onSubmit: handleSubmit,
|
|
41
40
|
onCancel: onStop,
|
|
41
|
+
onPasteFile,
|
|
42
42
|
autoSize: {
|
|
43
43
|
minRows: 1,
|
|
44
44
|
maxRows: 6
|
|
@@ -1109,23 +1109,6 @@ function useToolExecution({ tools, toolCalls, isLoading = false, onExecutionChan
|
|
|
1109
1109
|
//#endregion
|
|
1110
1110
|
//#region src/utils/messageUtils.ts
|
|
1111
1111
|
/**
|
|
1112
|
-
* 创建人类消息(HumanMessage)
|
|
1113
|
-
* @param content 消息内容,可以是字符串或多模态内容块数组
|
|
1114
|
-
* @returns HumanMessage 实例
|
|
1115
|
-
* @example
|
|
1116
|
-
* // 纯文本消息
|
|
1117
|
-
* createHumanMessage("你好")
|
|
1118
|
-
*
|
|
1119
|
-
* // 多模态消息
|
|
1120
|
-
* createHumanMessage([
|
|
1121
|
-
* { type: "text", text: "看看这张图片" },
|
|
1122
|
-
* { type: "image_url", image_url: { url: "https://example.com/image.png" } }
|
|
1123
|
-
* ])
|
|
1124
|
-
*/
|
|
1125
|
-
function createHumanMessage(content) {
|
|
1126
|
-
return new HumanMessage({ content });
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
1112
|
* 从 BaseMessage 中提取 tool_calls
|
|
1130
1113
|
*/
|
|
1131
1114
|
function extractToolCalls(message) {
|
|
@@ -1540,4 +1523,4 @@ const ToolCard = ({ prefix, content, icon, style, styles }) => {
|
|
|
1540
1523
|
});
|
|
1541
1524
|
};
|
|
1542
1525
|
//#endregion
|
|
1543
|
-
export { AgentChat, MessageContentRenderer, ToolCard
|
|
1526
|
+
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.15",
|
|
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": {
|