langgraph-ui-components 0.0.25 → 0.0.27
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 +412 -51
- package/dist/_virtual/index.cjs6.js +1 -1
- package/dist/_virtual/index.cjs8.js +1 -1
- package/dist/_virtual/index.es6.js +2 -2
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/assets/langgraph-ui-components.css +1 -1
- package/dist/components/ChatBody.cjs.js +2 -2
- package/dist/components/ChatBody.cjs.js.map +1 -1
- package/dist/components/ChatBody.d.ts.map +1 -1
- package/dist/components/ChatBody.es.js +137 -98
- package/dist/components/ChatBody.es.js.map +1 -1
- package/dist/components/messages/AgentMessage.cjs.js +3 -1
- package/dist/components/messages/AgentMessage.cjs.js.map +1 -1
- package/dist/components/messages/AgentMessage.d.ts +3 -1
- package/dist/components/messages/AgentMessage.d.ts.map +1 -1
- package/dist/components/messages/AgentMessage.es.js +197 -112
- package/dist/components/messages/AgentMessage.es.js.map +1 -1
- package/dist/entries/components.cjs.js +1 -1
- package/dist/entries/components.d.ts.map +1 -1
- package/dist/entries/components.es.js +4 -5
- package/dist/entries/components.es.js.map +1 -1
- package/dist/entries/hooks.cjs.js +1 -1
- package/dist/entries/hooks.d.ts.map +1 -1
- package/dist/entries/hooks.es.js +5 -6
- package/dist/entries/hooks.es.js.map +1 -1
- package/dist/entries/providers.cjs.js +1 -1
- package/dist/entries/providers.d.ts +1 -1
- package/dist/entries/providers.d.ts.map +1 -1
- package/dist/entries/providers.es.js +18 -19
- package/dist/entries/providers.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +28 -29
- package/dist/index.es.js.map +1 -1
- package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.cjs.js +1 -1
- package/dist/node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.es.js +1 -1
- package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.cjs.js +1 -1
- package/dist/node_modules/.pnpm/p-timeout@3.2.0/node_modules/p-timeout/index.es.js +1 -1
- package/dist/node_modules/.pnpm/react-syntax-highlighter@16.1.0_react@19.2.3/node_modules/react-syntax-highlighter/dist/cjs/styles/prism/index.cjs.js +1 -1
- package/dist/node_modules/.pnpm/react-syntax-highlighter@16.1.0_react@19.2.3/node_modules/react-syntax-highlighter/dist/cjs/styles/prism/index.es.js +1 -1
- package/dist/providers/ChatProvider.cjs.js +1 -1
- package/dist/providers/ChatProvider.cjs.js.map +1 -1
- package/dist/providers/ChatProvider.d.ts +17 -1
- package/dist/providers/ChatProvider.d.ts.map +1 -1
- package/dist/providers/ChatProvider.es.js +18 -17
- package/dist/providers/ChatProvider.es.js.map +1 -1
- package/dist/providers/ChatRuntime.es.js +4 -4
- package/dist/providers/CustomComponentProvider.cjs.js +1 -1
- package/dist/providers/CustomComponentProvider.cjs.js.map +1 -1
- package/dist/providers/CustomComponentProvider.d.ts +11 -0
- package/dist/providers/CustomComponentProvider.d.ts.map +1 -1
- package/dist/providers/CustomComponentProvider.es.js +51 -35
- package/dist/providers/CustomComponentProvider.es.js.map +1 -1
- package/dist/providers/Stream.cjs.js +1 -1
- package/dist/providers/Stream.cjs.js.map +1 -1
- package/dist/providers/Stream.d.ts.map +1 -1
- package/dist/providers/Stream.es.js +113 -94
- package/dist/providers/Stream.es.js.map +1 -1
- package/dist/providers/Thread.cjs.js +1 -1
- package/dist/providers/Thread.cjs.js.map +1 -1
- package/dist/providers/Thread.d.ts +2 -1
- package/dist/providers/Thread.d.ts.map +1 -1
- package/dist/providers/Thread.es.js +19 -19
- package/dist/providers/Thread.es.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ChatBody.tsx +88 -28
- package/src/components/messages/AgentMessage.tsx +281 -81
- package/src/entries/components.ts +0 -2
- package/src/entries/hooks.ts +0 -2
- package/src/entries/providers.ts +1 -3
- package/src/index.css +2 -2
- package/src/index.ts +1 -3
- package/src/providers/ChatProvider.tsx +18 -1
- package/src/providers/CustomComponentProvider.tsx +41 -0
- package/src/providers/Stream.tsx +34 -15
- package/src/providers/Thread.tsx +2 -2
- package/dist/components/ToolCallFunctions.cjs.js +0 -2
- package/dist/components/ToolCallFunctions.cjs.js.map +0 -1
- package/dist/components/ToolCallFunctions.es.js +0 -75
- package/dist/components/ToolCallFunctions.es.js.map +0 -1
package/src/entries/providers.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "../index.css";
|
|
2
|
-
|
|
3
1
|
// ─── Providers ────────────────────────────────────────────────────────────────
|
|
4
2
|
export { ChatProvider } from "../providers/ChatProvider";
|
|
5
3
|
export { ChatRuntimeProvider } from "../providers/ChatRuntime";
|
|
@@ -7,7 +5,7 @@ export { ThreadProvider } from "../providers/Thread";
|
|
|
7
5
|
export { StreamProvider } from "../providers/Stream";
|
|
8
6
|
export { FileProvider } from "../providers/FileProvider";
|
|
9
7
|
export { CustomComponentProvider } from "../providers/CustomComponentProvider";
|
|
10
|
-
export type { CustomComponentContextValue } from "../providers/CustomComponentProvider";
|
|
8
|
+
export type { CustomComponentContextValue, InterruptComponentProps } from "../providers/CustomComponentProvider";
|
|
11
9
|
|
|
12
10
|
// ─── Provider hooks ───────────────────────────────────────────────────────────
|
|
13
11
|
export { useThread } from "../providers/Thread";
|
package/src/index.css
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
|
|
3
1
|
// ─── Components ──────────────────────────────────────────────────────────────
|
|
4
2
|
export { default as Sidebar } from "./pages/Sidebar/sidebar";
|
|
5
3
|
export { Chat } from "./pages/Chat/Chat";
|
|
@@ -11,7 +9,7 @@ export { ThreadProvider } from "./providers/Thread";
|
|
|
11
9
|
export { StreamProvider } from "./providers/Stream";
|
|
12
10
|
export { FileProvider } from "./providers/FileProvider";
|
|
13
11
|
export { CustomComponentProvider } from "./providers/CustomComponentProvider";
|
|
14
|
-
export type { CustomComponentContextValue } from "./providers/CustomComponentProvider";
|
|
12
|
+
export type { CustomComponentContextValue, InterruptComponentProps } from "./providers/CustomComponentProvider";
|
|
15
13
|
|
|
16
14
|
// ─── Hooks ────────────────────────────────────────────────────────────────────
|
|
17
15
|
export { useTools } from "./hooks/useTools";
|
|
@@ -26,6 +26,11 @@ interface ChatProviderProps {
|
|
|
26
26
|
* Defaults to a plain `<div>Loading chat...</div>` if not provided.
|
|
27
27
|
*/
|
|
28
28
|
suspenseFallback?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Initial thread mode. Use `"multi"` to enable thread history and switching.
|
|
31
|
+
* Defaults to `"single"` (one conversation, no history panel).
|
|
32
|
+
*/
|
|
33
|
+
initialMode?: "single" | "multi";
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -35,10 +40,21 @@ interface ChatProviderProps {
|
|
|
35
40
|
*
|
|
36
41
|
* @example
|
|
37
42
|
* ```tsx
|
|
43
|
+
* // Single-thread mode (default)
|
|
44
|
+
* <ChatProvider
|
|
45
|
+
* apiUrl="https://api.example.com"
|
|
46
|
+
* assistantId="my-assistant"
|
|
47
|
+
* identity={{ user_id: "user123", org_id: "org456" }}
|
|
48
|
+
* >
|
|
49
|
+
* <YourChatUI />
|
|
50
|
+
* </ChatProvider>
|
|
51
|
+
*
|
|
52
|
+
* // Multi-thread mode (enables thread history)
|
|
38
53
|
* <ChatProvider
|
|
39
54
|
* apiUrl="https://api.example.com"
|
|
40
55
|
* assistantId="my-assistant"
|
|
41
56
|
* identity={{ user_id: "user123", org_id: "org456" }}
|
|
57
|
+
* initialMode="multi"
|
|
42
58
|
* >
|
|
43
59
|
* <YourChatUI />
|
|
44
60
|
* </ChatProvider>
|
|
@@ -51,6 +67,7 @@ export function ChatProvider({
|
|
|
51
67
|
children,
|
|
52
68
|
customComponents,
|
|
53
69
|
suspenseFallback = <div>Loading chat...</div>,
|
|
70
|
+
initialMode = "single",
|
|
54
71
|
}: ChatProviderProps) {
|
|
55
72
|
return (
|
|
56
73
|
<React.Suspense fallback={suspenseFallback}>
|
|
@@ -59,7 +76,7 @@ export function ChatProvider({
|
|
|
59
76
|
assistantId={assistantId}
|
|
60
77
|
identity={identity}
|
|
61
78
|
>
|
|
62
|
-
<ThreadProvider>
|
|
79
|
+
<ThreadProvider initialMode={initialMode}>
|
|
63
80
|
<StreamProvider>
|
|
64
81
|
<SuggestionProvider>
|
|
65
82
|
<CustomComponentProvider initialComponents={customComponents}>
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React, { createContext, useCallback, useContext, useState } from "react";
|
|
2
2
|
|
|
3
|
+
export interface InterruptComponentProps {
|
|
4
|
+
interrupt: any;
|
|
5
|
+
actions: {
|
|
6
|
+
approve: () => void;
|
|
7
|
+
reject: (reason?: string) => void;
|
|
8
|
+
edit: (editedArgs: Record<string, unknown>) => void;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export interface CustomComponentContextValue {
|
|
4
13
|
components: Record<string, React.FunctionComponent | React.ComponentClass>;
|
|
5
14
|
registerComponent: (
|
|
@@ -10,6 +19,12 @@ export interface CustomComponentContextValue {
|
|
|
10
19
|
components: Record<string, React.FunctionComponent | React.ComponentClass>
|
|
11
20
|
) => void;
|
|
12
21
|
unregisterComponent: (name: string) => void;
|
|
22
|
+
interruptComponents: Record<string, React.ComponentType<InterruptComponentProps>>;
|
|
23
|
+
registerInterruptComponent: (
|
|
24
|
+
toolName: string,
|
|
25
|
+
component: React.ComponentType<InterruptComponentProps>
|
|
26
|
+
) => void;
|
|
27
|
+
unregisterInterruptComponent: (toolName: string) => void;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
const CustomComponentContext = createContext<
|
|
@@ -33,6 +48,9 @@ export function CustomComponentProvider({
|
|
|
33
48
|
initialComponents
|
|
34
49
|
);
|
|
35
50
|
|
|
51
|
+
const [interruptComponents, setInterruptComponents] =
|
|
52
|
+
useState<Record<string, React.ComponentType<InterruptComponentProps>>>({});
|
|
53
|
+
|
|
36
54
|
const registerComponent = useCallback(
|
|
37
55
|
(
|
|
38
56
|
name: string,
|
|
@@ -68,6 +86,26 @@ export function CustomComponentProvider({
|
|
|
68
86
|
});
|
|
69
87
|
}, []);
|
|
70
88
|
|
|
89
|
+
const registerInterruptComponent = useCallback(
|
|
90
|
+
(
|
|
91
|
+
toolName: string,
|
|
92
|
+
component: React.ComponentType<InterruptComponentProps>
|
|
93
|
+
) => {
|
|
94
|
+
setInterruptComponents((prev) => ({
|
|
95
|
+
...prev,
|
|
96
|
+
[toolName]: component,
|
|
97
|
+
}));
|
|
98
|
+
},
|
|
99
|
+
[]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const unregisterInterruptComponent = useCallback((toolName: string) => {
|
|
103
|
+
setInterruptComponents((prev) => {
|
|
104
|
+
const { [toolName]: _, ...rest } = prev;
|
|
105
|
+
return rest;
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
71
109
|
return (
|
|
72
110
|
<CustomComponentContext.Provider
|
|
73
111
|
value={{
|
|
@@ -75,6 +113,9 @@ export function CustomComponentProvider({
|
|
|
75
113
|
registerComponent,
|
|
76
114
|
registerComponents,
|
|
77
115
|
unregisterComponent,
|
|
116
|
+
interruptComponents,
|
|
117
|
+
registerInterruptComponent,
|
|
118
|
+
unregisterInterruptComponent,
|
|
78
119
|
}}
|
|
79
120
|
>
|
|
80
121
|
{children}
|
package/src/providers/Stream.tsx
CHANGED
|
@@ -146,9 +146,9 @@ const StreamSession = ({ children }: { children: ReactNode }) => {
|
|
|
146
146
|
fetchStateHistory: true,
|
|
147
147
|
onUpdateEvent: (data, options) => {
|
|
148
148
|
// Scan update data (potentially nested by node name) for AI messages
|
|
149
|
-
// with reasoning_content
|
|
150
|
-
//
|
|
151
|
-
const
|
|
149
|
+
// with reasoning_content or tool_status in additional_kwargs.
|
|
150
|
+
// Merge these into existing messages so they're available during streaming.
|
|
151
|
+
const enrichedMessages: Message[] = [];
|
|
152
152
|
|
|
153
153
|
const scan = (obj: unknown) => {
|
|
154
154
|
if (!obj || typeof obj !== "object") return;
|
|
@@ -156,13 +156,12 @@ const StreamSession = ({ children }: { children: ReactNode }) => {
|
|
|
156
156
|
if (Array.isArray(o.messages)) {
|
|
157
157
|
for (const m of o.messages as Message[]) {
|
|
158
158
|
const ak = (m as Record<string, unknown>).additional_kwargs as Record<string, unknown> | undefined;
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
reasoningMessages.push(m);
|
|
159
|
+
if (m?.type === "ai" && m.id && ak) {
|
|
160
|
+
const hasReasoning = typeof ak.reasoning_content === "string" && ak.reasoning_content.length > 0;
|
|
161
|
+
const hasToolStatus = Array.isArray(ak.tool_status) && (ak.tool_status as unknown[]).length > 0;
|
|
162
|
+
if (hasReasoning || hasToolStatus) {
|
|
163
|
+
enrichedMessages.push(m);
|
|
164
|
+
}
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
}
|
|
@@ -175,13 +174,33 @@ const StreamSession = ({ children }: { children: ReactNode }) => {
|
|
|
175
174
|
|
|
176
175
|
scan(data);
|
|
177
176
|
|
|
178
|
-
if (
|
|
177
|
+
if (enrichedMessages.length > 0) {
|
|
179
178
|
options.mutate((prev) => {
|
|
180
179
|
const prevMessages = (prev.messages ?? []) as Message[];
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
const enrichedById = new Map<string, Message>();
|
|
181
|
+
for (const m of enrichedMessages) {
|
|
182
|
+
if (m.id) enrichedById.set(m.id, m);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let changed = false;
|
|
186
|
+
const updatedMessages = prevMessages.map((m) => {
|
|
187
|
+
if (!m.id || !enrichedById.has(m.id)) return m;
|
|
188
|
+
const enriched = enrichedById.get(m.id)!;
|
|
189
|
+
enrichedById.delete(m.id);
|
|
190
|
+
changed = true;
|
|
191
|
+
const enrichedKwargs = (enriched as Record<string, unknown>).additional_kwargs as Record<string, unknown> | undefined;
|
|
192
|
+
return {
|
|
193
|
+
...m,
|
|
194
|
+
additional_kwargs: {
|
|
195
|
+
...(m.additional_kwargs ?? {}),
|
|
196
|
+
...(enrichedKwargs ?? {}),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (!changed) return prev;
|
|
202
|
+
|
|
203
|
+
return { ...prev, messages: updatedMessages };
|
|
185
204
|
});
|
|
186
205
|
}
|
|
187
206
|
},
|
package/src/providers/Thread.tsx
CHANGED
|
@@ -71,7 +71,7 @@ function getThreadSearchMetadata(
|
|
|
71
71
|
* </ThreadProvider>
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
export function ThreadProvider({ children }: { children: ReactNode }) {
|
|
74
|
+
export function ThreadProvider({ children, initialMode = "single" }: { children: ReactNode; initialMode?: ThreadMode }) {
|
|
75
75
|
|
|
76
76
|
const { apiUrl, assistantId, identity } = useChatRuntime();
|
|
77
77
|
const [threads, setThreads] = useState<Thread[]>([]);
|
|
@@ -80,7 +80,7 @@ export function ThreadProvider({ children }: { children: ReactNode }) {
|
|
|
80
80
|
const [threadId, setThreadId] = useState<string | null>(null);
|
|
81
81
|
const [configuration, setConfiguration] = useState<ThreadConfiguration | undefined>();
|
|
82
82
|
|
|
83
|
-
const [mode, setMode] = useState<ThreadMode>(
|
|
83
|
+
const [mode, setMode] = useState<ThreadMode>(initialMode);
|
|
84
84
|
|
|
85
85
|
// Extract thread ID from URL query parameter on component mount
|
|
86
86
|
useEffect(() => {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),l=require("../utils/utils.cjs.js"),c=require("react");function h({title:t,toolMessages:s,toolCalls:r}){const[a,d]=c.useState(!1),i=!!s&&s.length>0,o=!!r&&r.length>0;return!i&&!o?null:e.jsxs("div",{id:"accordion-collapse","data-accordion":"collapse",className:"w-full rounded-base overflow-hidden shadow-xs border rounded-xl border-zinc-800 max-w-[90%] min-w-25",children:[e.jsx("h2",{id:"accordion-collapse-heading-1",children:e.jsxs("button",{type:"button",className:"flex items-center justify-between w-full p-2 font-medium gap-3 text-body border-0 outline-none ring-0 appearance-none bg-transparent",onClick:()=>d(n=>!n),"aria-expanded":a,"aria-controls":"accordion-collapse-body-1",children:[e.jsxs("span",{children:["🔷 ",t]}),e.jsx("svg",{"data-accordion-icon":!0,className:`w-5 h-5 shrink-0 transition-transform ${a?"rotate-0":"rotate-180"}`,"aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",children:e.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m5 15 7-7 7 7"})})]})}),e.jsx("div",{id:"accordion-collapse-body-1",className:`${a?"":"hidden"}`,"aria-labelledby":"accordion-collapse-heading-1",children:e.jsxs("div",{className:"md:p-5 text-left space-y-3",children:[i&&s.map(n=>e.jsx("div",{className:"border-zinc-700",children:e.jsx("p",{className:"text-body text-sm",children:n.content?l.getContentString(n.content):""})},n.id)),!i&&o&&r?.map(n=>e.jsxs("div",{className:"border-zinc-700",children:[e.jsx("p",{className:"text-body text-sm font-medium",children:n.name}),e.jsx("pre",{className:"text-xs text-zinc-400 whitespace-pre-wrap mt-1",children:JSON.stringify(n.args??{},null,2)})]},n.id??n.name))]})})]})}const m=c.memo(h,(t,s)=>t.toolMessages?.length===s.toolMessages?.length);module.exports=m;
|
|
2
|
-
//# sourceMappingURL=ToolCallFunctions.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCallFunctions.cjs.js","sources":["../../src/components/ToolCallFunctions.tsx"],"sourcesContent":["import { getContentString } from \"@/utils/utils\";\nimport type { AIMessage, Message } from \"@langchain/langgraph-sdk\";\nimport React, { useState } from \"react\";\n\nfunction ToolCallFunctions({ title, toolMessages, toolCalls }: {\n title?: string;\n toolMessages: Message[];\n toolCalls?: AIMessage[\"tool_calls\"];\n}) {\n const [open, setOpen] = useState(false);\n\n const hasToolMessages = !!toolMessages && toolMessages.length > 0;\n const hasToolCalls = !!toolCalls && toolCalls.length > 0;\n\n // Only render if there are tool messages or tool calls\n if (!hasToolMessages && !hasToolCalls) return null;\n\n return (\n <div\n id=\"accordion-collapse\"\n data-accordion=\"collapse\"\n className=\"w-full rounded-base overflow-hidden shadow-xs border rounded-xl border-zinc-800 max-w-[90%] min-w-25\"\n >\n <h2 id=\"accordion-collapse-heading-1\">\n <button\n type=\"button\"\n className=\"flex items-center justify-between w-full p-2 font-medium gap-3 text-body border-0 outline-none ring-0 appearance-none bg-transparent\"\n onClick={() => setOpen((v) => !v)}\n aria-expanded={open}\n aria-controls=\"accordion-collapse-body-1\"\n >\n <span>🔷 {title}</span>\n <svg\n data-accordion-icon\n className={`w-5 h-5 shrink-0 transition-transform ${open ? \"rotate-0\" : \"rotate-180\"\n }`}\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <path\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"m5 15 7-7 7 7\"\n />\n </svg>\n </button>\n </h2>\n <div\n id=\"accordion-collapse-body-1\"\n className={`${open ? \"\" : \"hidden\"}`}\n aria-labelledby=\"accordion-collapse-heading-1\"\n >\n <div className=\"md:p-5 text-left space-y-3\">\n {hasToolMessages && toolMessages.map((toolMsg) => (\n <div key={toolMsg.id} className=\"border-zinc-700\">\n <p className=\"text-body text-sm\">{toolMsg.content ? getContentString(toolMsg.content) : \"\"}</p>\n </div>\n ))}\n {!hasToolMessages && hasToolCalls && toolCalls?.map((toolCall) => (\n <div key={toolCall.id ?? toolCall.name} className=\"border-zinc-700\">\n <p className=\"text-body text-sm font-medium\">{toolCall.name}</p>\n <pre className=\"text-xs text-zinc-400 whitespace-pre-wrap mt-1\">\n {JSON.stringify(toolCall.args ?? {}, null, 2)}\n </pre>\n </div>\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nexport default React.memo(ToolCallFunctions, (prevProps, nextProps) => {\n return prevProps.toolMessages?.length === nextProps.toolMessages?.length;\n});"],"names":["ToolCallFunctions","title","toolMessages","toolCalls","open","setOpen","useState","hasToolMessages","hasToolCalls","jsxs","jsx","v","toolMsg","getContentString","toolCall","React","prevProps","nextProps"],"mappings":"wGAIA,SAASA,EAAkB,CAAE,MAAAC,EAAO,aAAAC,EAAc,UAAAC,GAI/C,CACD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAEhCC,EAAkB,CAAC,CAACL,GAAgBA,EAAa,OAAS,EAC1DM,EAAe,CAAC,CAACL,GAAaA,EAAU,OAAS,EAGvD,MAAI,CAACI,GAAmB,CAACC,EAAqB,KAG5CC,EAAAA,KAAC,MAAA,CACC,GAAG,qBACH,iBAAe,WACf,UAAU,uGAEV,SAAA,CAAAC,EAAAA,IAAC,KAAA,CAAG,GAAG,+BACL,SAAAD,EAAAA,KAAC,SAAA,CACC,KAAK,SACL,UAAU,uIACV,QAAS,IAAMJ,EAASM,GAAM,CAACA,CAAC,EAChC,gBAAeP,EACf,gBAAc,4BAEd,SAAA,CAAAK,OAAC,OAAA,CAAK,SAAA,CAAA,MAAIR,CAAA,EAAM,EAChBS,EAAAA,IAAC,MAAA,CACC,sBAAmB,GACnB,UAAW,yCAAyCN,EAAO,WAAa,YACtE,GACF,cAAY,OACZ,MAAM,6BACN,MAAM,KACN,OAAO,KACP,KAAK,OACL,QAAQ,YAER,SAAAM,EAAAA,IAAC,OAAA,CACC,OAAO,eACP,cAAc,QACd,eAAe,QACf,YAAY,IACZ,EAAE,eAAA,CAAA,CACJ,CAAA,CACF,CAAA,CAAA,EAEJ,EACAA,EAAAA,IAAC,MAAA,CACC,GAAG,4BACH,UAAW,GAAGN,EAAO,GAAK,QAAQ,GAClC,kBAAgB,+BAEhB,SAAAK,EAAAA,KAAC,MAAA,CAAI,UAAU,6BACZ,SAAA,CAAAF,GAAmBL,EAAa,IAAKU,SACnC,MAAA,CAAqB,UAAU,kBAC9B,SAAAF,EAAAA,IAAC,IAAA,CAAE,UAAU,oBAAqB,SAAAE,EAAQ,QAAUC,EAAAA,iBAAiBD,EAAQ,OAAO,EAAI,EAAA,CAAG,CAAA,EADnFA,EAAQ,EAElB,CACD,EACA,CAACL,GAAmBC,GAAgBL,GAAW,IAAKW,GACnDL,EAAAA,KAAC,MAAA,CAAuC,UAAU,kBAChD,SAAA,CAAAC,EAAAA,IAAC,IAAA,CAAE,UAAU,gCAAiC,SAAAI,EAAS,KAAK,EAC5DJ,EAAAA,IAAC,MAAA,CAAI,UAAU,iDACZ,SAAA,KAAK,UAAUI,EAAS,MAAQ,CAAA,EAAI,KAAM,CAAC,CAAA,CAC9C,CAAA,CAAA,EAJQA,EAAS,IAAMA,EAAS,IAKlC,CACD,CAAA,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAGN,CAEA,MAAAd,EAAee,EAAM,KAAKf,EAAmB,CAACgB,EAAWC,IAChDD,EAAU,cAAc,SAAWC,EAAU,cAAc,MACnE"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { getContentString as l } from "../utils/utils.es.js";
|
|
3
|
-
import m, { useState as h } from "react";
|
|
4
|
-
function p({ title: r, toolMessages: t, toolCalls: o }) {
|
|
5
|
-
const [i, c] = h(!1), d = !!t && t.length > 0, s = !!o && o.length > 0;
|
|
6
|
-
return !d && !s ? null : /* @__PURE__ */ a(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
id: "accordion-collapse",
|
|
10
|
-
"data-accordion": "collapse",
|
|
11
|
-
className: "w-full rounded-base overflow-hidden shadow-xs border rounded-xl border-zinc-800 max-w-[90%] min-w-25",
|
|
12
|
-
children: [
|
|
13
|
-
/* @__PURE__ */ n("h2", { id: "accordion-collapse-heading-1", children: /* @__PURE__ */ a(
|
|
14
|
-
"button",
|
|
15
|
-
{
|
|
16
|
-
type: "button",
|
|
17
|
-
className: "flex items-center justify-between w-full p-2 font-medium gap-3 text-body border-0 outline-none ring-0 appearance-none bg-transparent",
|
|
18
|
-
onClick: () => c((e) => !e),
|
|
19
|
-
"aria-expanded": i,
|
|
20
|
-
"aria-controls": "accordion-collapse-body-1",
|
|
21
|
-
children: [
|
|
22
|
-
/* @__PURE__ */ a("span", { children: [
|
|
23
|
-
"🔷 ",
|
|
24
|
-
r
|
|
25
|
-
] }),
|
|
26
|
-
/* @__PURE__ */ n(
|
|
27
|
-
"svg",
|
|
28
|
-
{
|
|
29
|
-
"data-accordion-icon": !0,
|
|
30
|
-
className: `w-5 h-5 shrink-0 transition-transform ${i ? "rotate-0" : "rotate-180"}`,
|
|
31
|
-
"aria-hidden": "true",
|
|
32
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
-
width: "24",
|
|
34
|
-
height: "24",
|
|
35
|
-
fill: "none",
|
|
36
|
-
viewBox: "0 0 24 24",
|
|
37
|
-
children: /* @__PURE__ */ n(
|
|
38
|
-
"path",
|
|
39
|
-
{
|
|
40
|
-
stroke: "currentColor",
|
|
41
|
-
strokeLinecap: "round",
|
|
42
|
-
strokeLinejoin: "round",
|
|
43
|
-
strokeWidth: "2",
|
|
44
|
-
d: "m5 15 7-7 7 7"
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
) }),
|
|
52
|
-
/* @__PURE__ */ n(
|
|
53
|
-
"div",
|
|
54
|
-
{
|
|
55
|
-
id: "accordion-collapse-body-1",
|
|
56
|
-
className: `${i ? "" : "hidden"}`,
|
|
57
|
-
"aria-labelledby": "accordion-collapse-heading-1",
|
|
58
|
-
children: /* @__PURE__ */ a("div", { className: "md:p-5 text-left space-y-3", children: [
|
|
59
|
-
d && t.map((e) => /* @__PURE__ */ n("div", { className: "border-zinc-700", children: /* @__PURE__ */ n("p", { className: "text-body text-sm", children: e.content ? l(e.content) : "" }) }, e.id)),
|
|
60
|
-
!d && s && o?.map((e) => /* @__PURE__ */ a("div", { className: "border-zinc-700", children: [
|
|
61
|
-
/* @__PURE__ */ n("p", { className: "text-body text-sm font-medium", children: e.name }),
|
|
62
|
-
/* @__PURE__ */ n("pre", { className: "text-xs text-zinc-400 whitespace-pre-wrap mt-1", children: JSON.stringify(e.args ?? {}, null, 2) })
|
|
63
|
-
] }, e.id ?? e.name))
|
|
64
|
-
] })
|
|
65
|
-
}
|
|
66
|
-
)
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
const b = m.memo(p, (r, t) => r.toolMessages?.length === t.toolMessages?.length);
|
|
72
|
-
export {
|
|
73
|
-
b as default
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=ToolCallFunctions.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ToolCallFunctions.es.js","sources":["../../src/components/ToolCallFunctions.tsx"],"sourcesContent":["import { getContentString } from \"@/utils/utils\";\nimport type { AIMessage, Message } from \"@langchain/langgraph-sdk\";\nimport React, { useState } from \"react\";\n\nfunction ToolCallFunctions({ title, toolMessages, toolCalls }: {\n title?: string;\n toolMessages: Message[];\n toolCalls?: AIMessage[\"tool_calls\"];\n}) {\n const [open, setOpen] = useState(false);\n\n const hasToolMessages = !!toolMessages && toolMessages.length > 0;\n const hasToolCalls = !!toolCalls && toolCalls.length > 0;\n\n // Only render if there are tool messages or tool calls\n if (!hasToolMessages && !hasToolCalls) return null;\n\n return (\n <div\n id=\"accordion-collapse\"\n data-accordion=\"collapse\"\n className=\"w-full rounded-base overflow-hidden shadow-xs border rounded-xl border-zinc-800 max-w-[90%] min-w-25\"\n >\n <h2 id=\"accordion-collapse-heading-1\">\n <button\n type=\"button\"\n className=\"flex items-center justify-between w-full p-2 font-medium gap-3 text-body border-0 outline-none ring-0 appearance-none bg-transparent\"\n onClick={() => setOpen((v) => !v)}\n aria-expanded={open}\n aria-controls=\"accordion-collapse-body-1\"\n >\n <span>🔷 {title}</span>\n <svg\n data-accordion-icon\n className={`w-5 h-5 shrink-0 transition-transform ${open ? \"rotate-0\" : \"rotate-180\"\n }`}\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n >\n <path\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"m5 15 7-7 7 7\"\n />\n </svg>\n </button>\n </h2>\n <div\n id=\"accordion-collapse-body-1\"\n className={`${open ? \"\" : \"hidden\"}`}\n aria-labelledby=\"accordion-collapse-heading-1\"\n >\n <div className=\"md:p-5 text-left space-y-3\">\n {hasToolMessages && toolMessages.map((toolMsg) => (\n <div key={toolMsg.id} className=\"border-zinc-700\">\n <p className=\"text-body text-sm\">{toolMsg.content ? getContentString(toolMsg.content) : \"\"}</p>\n </div>\n ))}\n {!hasToolMessages && hasToolCalls && toolCalls?.map((toolCall) => (\n <div key={toolCall.id ?? toolCall.name} className=\"border-zinc-700\">\n <p className=\"text-body text-sm font-medium\">{toolCall.name}</p>\n <pre className=\"text-xs text-zinc-400 whitespace-pre-wrap mt-1\">\n {JSON.stringify(toolCall.args ?? {}, null, 2)}\n </pre>\n </div>\n ))}\n </div>\n </div>\n </div>\n );\n}\n\nexport default React.memo(ToolCallFunctions, (prevProps, nextProps) => {\n return prevProps.toolMessages?.length === nextProps.toolMessages?.length;\n});"],"names":["ToolCallFunctions","title","toolMessages","toolCalls","open","setOpen","useState","hasToolMessages","hasToolCalls","jsxs","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