@vegintech/langchain-react-agent 0.0.2 → 0.0.3
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/README.md +11 -35
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @vegintech/
|
|
1
|
+
# @vegintech/langchain-react-agent
|
|
2
2
|
|
|
3
3
|
一个用于 React 的 LangChain Agent UI 组件库,基于 Ant Design X 构建,提供开箱即用的智能对话界面。
|
|
4
4
|
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
## 安装
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @vegintech/
|
|
17
|
+
npm install @vegintech/langchain-react-agent
|
|
18
18
|
# 或
|
|
19
|
-
yarn add @vegintech/
|
|
19
|
+
yarn add @vegintech/langchain-react-agent
|
|
20
20
|
# 或
|
|
21
|
-
pnpm add @vegintech/
|
|
21
|
+
pnpm add @vegintech/langchain-react-agent
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
### 对等依赖
|
|
@@ -32,13 +32,12 @@ npm install react react-dom @langchain/react
|
|
|
32
32
|
## 快速开始
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
|
-
import { AgentChat } from "@vegintech/
|
|
36
|
-
import "@vegintech/agentkit/style.css";
|
|
35
|
+
import { AgentChat } from "@vegintech/langchain-react-agent";
|
|
37
36
|
|
|
38
37
|
function App() {
|
|
39
38
|
return (
|
|
40
39
|
<AgentChat
|
|
41
|
-
apiUrl="http://localhost:
|
|
40
|
+
apiUrl="http://localhost:2024"
|
|
42
41
|
assistantId="my-assistant"
|
|
43
42
|
onThreadIdChange={(threadId) => {
|
|
44
43
|
console.log("New thread:", threadId);
|
|
@@ -55,7 +54,7 @@ function App() {
|
|
|
55
54
|
核心聊天组件,封装了消息列表、输入框和工具管理功能。
|
|
56
55
|
|
|
57
56
|
```tsx
|
|
58
|
-
import { AgentChat } from "@vegintech/
|
|
57
|
+
import { AgentChat } from "@vegintech/langchain-react-agent";
|
|
59
58
|
|
|
60
59
|
<AgentChat
|
|
61
60
|
// 连接配置
|
|
@@ -94,7 +93,7 @@ import { AgentChat } from "@vegintech/agentkit";
|
|
|
94
93
|
前端工具在浏览器端执行,适用于需要访问浏览器 API 或不需要后端处理的场景。
|
|
95
94
|
|
|
96
95
|
```tsx
|
|
97
|
-
import type { FrontendTool } from "@vegintech/
|
|
96
|
+
import type { FrontendTool } from "@vegintech/langchain-react-agent";
|
|
98
97
|
|
|
99
98
|
const alertTool: FrontendTool = {
|
|
100
99
|
type: "frontend",
|
|
@@ -122,7 +121,7 @@ const alertTool: FrontendTool = {
|
|
|
122
121
|
后端工具由 LangChain Agent 在后端执行,适用于需要访问数据库、API 等后端资源的场景。
|
|
123
122
|
|
|
124
123
|
```tsx
|
|
125
|
-
import type { BackendTool } from "@vegintech/
|
|
124
|
+
import type { BackendTool } from "@vegintech/langchain-react-agent";
|
|
126
125
|
|
|
127
126
|
const searchTool: BackendTool = {
|
|
128
127
|
type: "backend",
|
|
@@ -176,28 +175,5 @@ import type {
|
|
|
176
175
|
ContextItem,
|
|
177
176
|
MessageConfig,
|
|
178
177
|
InputConfig,
|
|
179
|
-
} from "@vegintech/
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## 开发
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
# 安装依赖
|
|
186
|
-
vp install
|
|
187
|
-
|
|
188
|
-
# 开发模式
|
|
189
|
-
vp dev
|
|
190
|
-
|
|
191
|
-
# 运行测试
|
|
192
|
-
vp test
|
|
193
|
-
|
|
194
|
-
# 构建
|
|
195
|
-
vp pack
|
|
196
|
-
|
|
197
|
-
# 代码检查
|
|
198
|
-
vp check
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## 许可证
|
|
202
|
-
|
|
203
|
-
MIT
|
|
178
|
+
} from "@vegintech/langchain-react-agent";
|
|
179
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -140,6 +140,8 @@ interface MessageConfig {
|
|
|
140
140
|
allowedTags?: Record<string, string[]>;
|
|
141
141
|
/** 作为字面量内容处理的标签(不解析内部 Markdown) */
|
|
142
142
|
literalTagContent?: string[];
|
|
143
|
+
/** Loading 动画颜色,支持 CSS 颜色值 */
|
|
144
|
+
loadingColor?: string;
|
|
143
145
|
}
|
|
144
146
|
/** 输入框配置 */
|
|
145
147
|
interface InputConfig extends SenderCustomizationProps {
|
package/dist/index.mjs
CHANGED
|
@@ -383,7 +383,7 @@ const ReasoningContent = ({ content }) => {
|
|
|
383
383
|
border: "none",
|
|
384
384
|
background: "transparent",
|
|
385
385
|
cursor: "pointer",
|
|
386
|
-
color: "#
|
|
386
|
+
color: "#ffffff"
|
|
387
387
|
},
|
|
388
388
|
children: "查看全部"
|
|
389
389
|
})] });
|
|
@@ -546,7 +546,7 @@ const roleConfig = {
|
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
};
|
|
549
|
-
const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig }) => {
|
|
549
|
+
const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig, loadingColor }) => {
|
|
550
550
|
const reasoningCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
551
551
|
const processedMessages = useMemo(() => {
|
|
552
552
|
const cache = reasoningCacheRef.current;
|
|
@@ -593,7 +593,7 @@ const MessageList = ({ messages, isLoading = false, className = "", tools, toolE
|
|
|
593
593
|
const allItems = processedMessages[processedMessages.length - 1]?.type === "human" && isLoading ? [...items, {
|
|
594
594
|
key: "loading",
|
|
595
595
|
role: "ai",
|
|
596
|
-
content: /* @__PURE__ */ jsx(WaveLoading, {}),
|
|
596
|
+
content: /* @__PURE__ */ jsx(WaveLoading, { color: loadingColor }),
|
|
597
597
|
placement: "start",
|
|
598
598
|
style: { paddingBlock: 0 }
|
|
599
599
|
}] : items;
|
|
@@ -800,7 +800,8 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
|
|
|
800
800
|
securityConfig: {
|
|
801
801
|
allowedTags: messageConfig?.allowedTags,
|
|
802
802
|
literalTagContent: messageConfig?.literalTagContent
|
|
803
|
-
}
|
|
803
|
+
},
|
|
804
|
+
loadingColor: messageConfig?.loadingColor
|
|
804
805
|
}),
|
|
805
806
|
/* @__PURE__ */ jsx(ChatInput, {
|
|
806
807
|
ref: chatInputRef,
|