@vegintech/langchain-react-agent 0.0.3 → 0.0.4

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
@@ -1,8 +1,7 @@
1
1
  import * as react from "react";
2
- import { ReactNode } from "react";
2
+ import React, { ReactNode } from "react";
3
3
  import { Components } from "streamdown";
4
4
  import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
5
- import { BaseMessage } from "@langchain/core/messages";
6
5
 
7
6
  //#region src/types.d.ts
8
7
  /** Context Item,用于传递上下文信息 */
@@ -178,28 +177,25 @@ interface AgentChatRef {
178
177
  //#region src/AgentChat.d.ts
179
178
  declare const AgentChat: react.ForwardRefExoticComponent<AgentChatProps & react.RefAttributes<AgentChatRef>>;
180
179
  //#endregion
181
- //#region src/messageUtils.d.ts
182
- /**
183
- * 从 BaseMessage 中提取 tool_calls
184
- */
185
- declare function extractToolCalls(message: BaseMessage): ToolCallInput[] | undefined;
186
- /**
187
- * 从 BaseMessage 中提取文本内容
188
- */
189
- declare function extractContent(message: BaseMessage): string;
190
- /**
191
- * 将 BaseMessage 转换为 ChatMessage
192
- */
193
- declare function toChatMessage(message: BaseMessage, toolResults: Map<string, unknown>): ChatMessage | null;
180
+ //#region src/ToolCard.d.ts
181
+ interface ToolCardProps {
182
+ /**
183
+ * 前缀文本(中文,使用小字体)
184
+ */
185
+ prefix: string;
186
+ /**
187
+ * 正文内容(英文/文件名,保持默认大小)
188
+ */
189
+ content?: string;
190
+ /**
191
+ * 左侧图标
192
+ */
193
+ icon: React.ReactNode;
194
+ }
194
195
  /**
195
- * 预处理消息列表:建立 tool_call_id -> result 映射,并过滤 ToolMessage
196
+ * ToolCard 组件 - 用于展示工具调用结果
197
+ * 样式:圆角矩形框,左侧 icon,label 分两行显示(prefix 小字体,content 默认字体)
196
198
  */
197
- declare function processMessages(rawMessages: BaseMessage[]): {
198
- messages: ChatMessage[];
199
- toolResults: Map<string, unknown>;
200
- };
201
- //#endregion
202
- //#region src/injectStyles.d.ts
203
- declare function injectStyles(): void;
199
+ declare const ToolCard: React.FC<ToolCardProps>;
204
200
  //#endregion
205
- export { AgentChat, type AgentChatInputRef, type AgentChatProps, type AgentChatRef, type BackendTool, type ChatMessage, type ContextItem, type FrontendTool, type InputConfig, type MessageConfig, type MessageType, type SenderCustomizationProps, type SenderSlotConfig, type SenderSubmitParams, type ToolCallInput, type ToolDefinition, type ToolExecutionRecord, type ToolExecutionStatus, type ToolParameterSchema, type ToolRenderProps, extractContent, extractToolCalls, injectStyles, processMessages, toChatMessage };
201
+ export { AgentChat, type AgentChatInputRef, type AgentChatProps, type AgentChatRef, type BackendTool, type ChatMessage, type ContextItem, type FrontendTool, type InputConfig, type MessageConfig, type MessageType, type SenderCustomizationProps, type SenderSlotConfig, type SenderSubmitParams, type ToolCallInput, ToolCard, type ToolCardProps, type ToolDefinition, type ToolExecutionRecord, type ToolExecutionStatus, type ToolParameterSchema, type ToolRenderProps };
package/dist/index.mjs CHANGED
@@ -821,4 +821,39 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
821
821
  });
822
822
  AgentChat.displayName = "AgentChat";
823
823
  //#endregion
824
- export { AgentChat, extractContent, extractToolCalls, injectStyles, processMessages, toChatMessage };
824
+ //#region src/ToolCard.tsx
825
+ /**
826
+ * ToolCard 组件 - 用于展示工具调用结果
827
+ * 样式:圆角矩形框,左侧 icon,label 分两行显示(prefix 小字体,content 默认字体)
828
+ */
829
+ const ToolCard = ({ prefix, content, icon }) => {
830
+ return /* @__PURE__ */ jsxs("div", {
831
+ style: {
832
+ display: "inline-flex",
833
+ alignItems: "center",
834
+ gap: 8,
835
+ borderRadius: 8,
836
+ fontSize: 13
837
+ },
838
+ children: [/* @__PURE__ */ jsx("span", {
839
+ style: {
840
+ display: "flex",
841
+ alignItems: "center"
842
+ },
843
+ children: icon
844
+ }), /* @__PURE__ */ jsxs("span", {
845
+ style: {
846
+ display: "flex",
847
+ alignItems: "center",
848
+ gap: 4,
849
+ color: "rgba(0, 0, 0, 0.45)"
850
+ },
851
+ children: [/* @__PURE__ */ jsx("span", {
852
+ style: { fontSize: 12 },
853
+ children: prefix
854
+ }), /* @__PURE__ */ jsx("span", { children: content })]
855
+ })]
856
+ });
857
+ };
858
+ //#endregion
859
+ export { AgentChat, ToolCard };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [