@vegintech/langchain-react-agent 0.0.18 → 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
@@ -323,7 +323,7 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
323
323
  }),
324
324
  hasToolCalls && /* @__PURE__ */ jsx("div", {
325
325
  className: "tool-calls-container",
326
- style: { marginTop: "8px" },
326
+ style: { marginTop: !isContentEmpty ? "8px" : "0px" },
327
327
  children: renderToolCalls(message.toolCalls, tools, toolExecutions)
328
328
  })
329
329
  ]
@@ -1307,7 +1307,6 @@ const styles = `
1307
1307
  display: flex;
1308
1308
  flex-direction: column;
1309
1309
  gap: 8px;
1310
- margin-top: 8px;
1311
1310
  }
1312
1311
 
1313
1312
  /* Tool Call Default Style */
@@ -1358,25 +1357,14 @@ function injectStyles() {
1358
1357
  //#endregion
1359
1358
  //#region src/components/AgentChat.tsx
1360
1359
  injectStyles();
1361
- const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: externalThreadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1362
- const [internalThreadId, setInternalThreadId] = useState(externalThreadId);
1363
- useEffect(() => {
1364
- setInternalThreadId(externalThreadId);
1365
- }, [externalThreadId]);
1360
+ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1366
1361
  const { onPreSend, ...chatInputConfig } = inputConfig || {};
1367
1362
  const chatInputRef = useRef(null);
1368
- useImperativeHandle(ref, () => ({
1369
- input: chatInputRef.current,
1370
- setSkill: (skill) => chatInputRef.current?.setSkill?.(skill),
1371
- clearInput: () => chatInputRef.current?.clear?.(),
1372
- focusInput: () => chatInputRef.current?.focus?.()
1373
- }));
1374
1363
  const stream = useStream({
1375
1364
  apiUrl,
1376
1365
  assistantId,
1377
- threadId: internalThreadId,
1366
+ threadId,
1378
1367
  onThreadId: (newThreadId) => {
1379
- setInternalThreadId(newThreadId);
1380
1368
  onThreadIdChange?.(newThreadId);
1381
1369
  },
1382
1370
  defaultHeaders: headers,
@@ -1386,6 +1374,13 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
1386
1374
  onError?.(err);
1387
1375
  }
1388
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
+ }));
1389
1384
  useEffect(() => {
1390
1385
  if (stream.values && onAgentStateChange) onAgentStateChange(stream.values);
1391
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.18",
3
+ "version": "0.0.20",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [