@vegintech/langchain-react-agent 0.0.19 → 0.0.20

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 CHANGED
@@ -3,7 +3,7 @@ import React$1, { ReactNode } from "react";
3
3
  import { ThoughtChainItemProps } from "@ant-design/x";
4
4
  import { Components } from "streamdown";
5
5
  import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
6
- import { Message } from "@langchain/langgraph-sdk";
6
+ import { Message, Thread } from "@langchain/langgraph-sdk";
7
7
 
8
8
  //#region src/types.d.ts
9
9
  /** ToolCard 组件 Props */
@@ -246,6 +246,7 @@ interface AgentChatRef {
246
246
  clearInput: () => void;
247
247
  /** 聚焦输入框 */
248
248
  focusInput: () => void;
249
+ createThread: () => Promise<Thread>;
249
250
  }
250
251
  /** Streamdown 安全过滤配置 */
251
252
  interface StreamdownSecurityConfig {
package/dist/index.mjs CHANGED
@@ -1357,25 +1357,14 @@ function injectStyles() {
1357
1357
  //#endregion
1358
1358
  //#region src/components/AgentChat.tsx
1359
1359
  injectStyles();
1360
- const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: externalThreadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1361
- const [internalThreadId, setInternalThreadId] = useState(externalThreadId);
1362
- useEffect(() => {
1363
- setInternalThreadId(externalThreadId);
1364
- }, [externalThreadId]);
1360
+ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1365
1361
  const { onPreSend, ...chatInputConfig } = inputConfig || {};
1366
1362
  const chatInputRef = useRef(null);
1367
- useImperativeHandle(ref, () => ({
1368
- input: chatInputRef.current,
1369
- setSkill: (skill) => chatInputRef.current?.setSkill?.(skill),
1370
- clearInput: () => chatInputRef.current?.clear?.(),
1371
- focusInput: () => chatInputRef.current?.focus?.()
1372
- }));
1373
1363
  const stream = useStream({
1374
1364
  apiUrl,
1375
1365
  assistantId,
1376
- threadId: internalThreadId,
1366
+ threadId,
1377
1367
  onThreadId: (newThreadId) => {
1378
- setInternalThreadId(newThreadId);
1379
1368
  onThreadIdChange?.(newThreadId);
1380
1369
  },
1381
1370
  defaultHeaders: headers,
@@ -1385,6 +1374,13 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
1385
1374
  onError?.(err);
1386
1375
  }
1387
1376
  });
1377
+ useImperativeHandle(ref, () => ({
1378
+ input: chatInputRef.current,
1379
+ setSkill: (skill) => chatInputRef.current?.setSkill?.(skill),
1380
+ createThread: () => stream.client.threads.create(),
1381
+ clearInput: () => chatInputRef.current?.clear?.(),
1382
+ focusInput: () => chatInputRef.current?.focus?.()
1383
+ }));
1388
1384
  useEffect(() => {
1389
1385
  if (stream.values && onAgentStateChange) onAgentStateChange(stream.values);
1390
1386
  }, [stream.values, onAgentStateChange]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [