@assistant-ui/mcp-docs-server 0.1.3 → 0.1.5
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/.docs/organized/code-examples/local-ollama.md +13 -13
- package/.docs/organized/code-examples/search-agent-for-e-commerce.md +18 -18
- package/.docs/organized/code-examples/{with-vercel-ai-rsc.md → with-ai-sdk-v5.md} +225 -230
- package/.docs/organized/code-examples/with-ai-sdk.md +13 -13
- package/.docs/organized/code-examples/with-cloud.md +12 -12
- package/.docs/organized/code-examples/with-external-store.md +9 -9
- package/.docs/organized/code-examples/with-ffmpeg.md +19 -19
- package/.docs/organized/code-examples/with-langgraph.md +14 -14
- package/.docs/organized/code-examples/with-openai-assistants.md +12 -12
- package/.docs/organized/code-examples/with-parent-id-grouping.md +1374 -0
- package/.docs/organized/code-examples/with-react-hook-form.md +18 -18
- package/.docs/raw/docs/about-assistantui.mdx +9 -0
- package/.docs/raw/docs/api-reference/context-providers/{TextContentPartProvider.mdx → TextMessagePartProvider.mdx} +3 -3
- package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +2 -2
- package/.docs/raw/docs/api-reference/overview.mdx +23 -23
- package/.docs/raw/docs/api-reference/primitives/Error.mdx +5 -3
- package/.docs/raw/docs/api-reference/primitives/Message.mdx +32 -0
- package/.docs/raw/docs/api-reference/primitives/{ContentPart.mdx → MessagePart.mdx} +41 -41
- package/.docs/raw/docs/api-reference/runtimes/MessagePartRuntime.mdx +22 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +1 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +1 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +89 -32
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +187 -32
- package/.docs/raw/docs/concepts/runtime-layer.mdx +7 -7
- package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +22 -13
- package/.docs/raw/docs/copilots/make-assistant-tool.mdx +20 -14
- package/.docs/raw/docs/getting-started.mdx +11 -10
- package/.docs/raw/docs/guides/Attachments.mdx +24 -21
- package/.docs/raw/docs/guides/Latex.mdx +81 -0
- package/.docs/raw/docs/guides/ToolUI.mdx +13 -8
- package/.docs/raw/docs/migrations/v0-11.mdx +169 -0
- package/.docs/raw/docs/migrations/v0-7.mdx +8 -8
- package/.docs/raw/docs/migrations/v0-8.mdx +14 -14
- package/.docs/raw/docs/migrations/v0-9.mdx +3 -3
- package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-v5.mdx +129 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +3 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +5 -5
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +2 -2
- package/.docs/raw/docs/ui/Attachment.mdx +5 -2
- package/.docs/raw/docs/ui/Markdown.mdx +2 -3
- package/.docs/raw/docs/ui/PartGrouping.mdx +540 -0
- package/.docs/raw/docs/ui/ToolFallback.mdx +2 -2
- package/.docs/raw/docs/ui/ToolGroup.mdx +96 -0
- package/package.json +8 -8
- package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +0 -22
|
@@ -2,37 +2,74 @@
|
|
|
2
2
|
title: Chat History for LangGraph Cloud
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { Steps, Step } from 'fumadocs-ui/components/steps';
|
|
6
|
+
import { Callout } from 'fumadocs-ui/components/callout';
|
|
7
|
+
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
8
|
+
|
|
5
9
|
## Overview
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
assistant-cloud provides thread management and persistent chat history for applications built with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/). This guide shows you how to integrate cloud persistence into your LangGraph application.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
<Callout type="info">
|
|
16
|
+
You need an assistant-cloud account to follow this guide. [Sign up here](https://cloud.assistant-ui.com/) to get started.
|
|
17
|
+
</Callout>
|
|
18
|
+
|
|
19
|
+
## Setup Guide
|
|
20
|
+
|
|
21
|
+
<Steps>
|
|
22
|
+
|
|
23
|
+
<Step>
|
|
24
|
+
|
|
25
|
+
### Create a Cloud Project
|
|
26
|
+
|
|
27
|
+
Create a new project in the [assistant-cloud dashboard](https://cloud.assistant-ui.com/) and from the settings page, copy:
|
|
28
|
+
|
|
29
|
+
- **Frontend API URL**: `https://proj-[ID].assistant-api.com`
|
|
30
|
+
- **API Key**: For server-side operations
|
|
31
|
+
|
|
32
|
+
</Step>
|
|
33
|
+
|
|
34
|
+
<Step>
|
|
35
|
+
|
|
36
|
+
### Configure Environment Variables
|
|
9
37
|
|
|
10
|
-
|
|
38
|
+
Add the following environment variables to your project:
|
|
11
39
|
|
|
12
|
-
|
|
13
|
-
|
|
40
|
+
```bash title=".env.local"
|
|
41
|
+
# Frontend API URL from your cloud project settings
|
|
42
|
+
NEXT_PUBLIC_ASSISTANT_BASE_URL=https://proj-[YOUR-ID].assistant-api.com
|
|
14
43
|
|
|
15
|
-
|
|
44
|
+
# API key for server-side operations
|
|
45
|
+
ASSISTANT_API_KEY=your-api-key-here
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</Step>
|
|
16
49
|
|
|
17
|
-
|
|
50
|
+
<Step>
|
|
18
51
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
### Install Dependencies
|
|
53
|
+
|
|
54
|
+
Install the required packages:
|
|
22
55
|
|
|
23
56
|
```bash
|
|
24
|
-
|
|
57
|
+
npm install @assistant-ui/react @assistant-ui/react-langgraph
|
|
25
58
|
```
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
</Step>
|
|
61
|
+
|
|
62
|
+
<Step>
|
|
28
63
|
|
|
29
|
-
|
|
64
|
+
### Create the Runtime Provider
|
|
30
65
|
|
|
31
|
-
|
|
66
|
+
Create a runtime provider that integrates LangGraph with assistant-cloud. Choose between anonymous mode for demos/prototypes or authenticated mode for production:
|
|
32
67
|
|
|
33
|
-
|
|
34
|
-
// @errors: 2307
|
|
68
|
+
<Tabs items={["Anonymous", "Authenticated (Clerk)"]}>
|
|
35
69
|
|
|
70
|
+
<Tab value="Anonymous">
|
|
71
|
+
|
|
72
|
+
```tsx title="app/chat/runtime-provider.tsx"
|
|
36
73
|
"use client";
|
|
37
74
|
|
|
38
75
|
import {
|
|
@@ -44,19 +81,22 @@ import {
|
|
|
44
81
|
import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
45
82
|
import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
46
83
|
import { LangChainMessage } from "@assistant-ui/react-langgraph";
|
|
47
|
-
import { useAuth } from "@clerk/nextjs";
|
|
48
84
|
import { useMemo } from "react";
|
|
49
85
|
|
|
50
|
-
// ---cut---
|
|
51
86
|
const useMyLangGraphRuntime = () => {
|
|
52
87
|
const threadListItemRuntime = useThreadListItemRuntime();
|
|
88
|
+
|
|
53
89
|
const runtime = useLangGraphRuntime({
|
|
54
90
|
stream: async function* (messages) {
|
|
55
91
|
const { externalId } = await threadListItemRuntime.initialize();
|
|
56
92
|
if (!externalId) throw new Error("Thread not found");
|
|
57
93
|
|
|
58
|
-
return sendMessage({
|
|
94
|
+
return sendMessage({
|
|
95
|
+
threadId: externalId,
|
|
96
|
+
messages,
|
|
97
|
+
});
|
|
59
98
|
},
|
|
99
|
+
|
|
60
100
|
onSwitchToThread: async (externalId) => {
|
|
61
101
|
const state = await getThreadState(externalId);
|
|
62
102
|
return {
|
|
@@ -69,6 +109,82 @@ const useMyLangGraphRuntime = () => {
|
|
|
69
109
|
return runtime;
|
|
70
110
|
};
|
|
71
111
|
|
|
112
|
+
export function MyRuntimeProvider({
|
|
113
|
+
children,
|
|
114
|
+
}: Readonly<{
|
|
115
|
+
children: React.ReactNode;
|
|
116
|
+
}>) {
|
|
117
|
+
const cloud = useMemo(
|
|
118
|
+
() =>
|
|
119
|
+
new AssistantCloud({
|
|
120
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
121
|
+
anonymous: true, // Creates browser session-based user ID
|
|
122
|
+
}),
|
|
123
|
+
[],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const runtime = useCloudThreadListRuntime({
|
|
127
|
+
cloud,
|
|
128
|
+
runtimeHook: useMyLangGraphRuntime,
|
|
129
|
+
create: async () => {
|
|
130
|
+
const { thread_id } = await createThread();
|
|
131
|
+
return { externalId: thread_id };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
137
|
+
{children}
|
|
138
|
+
</AssistantRuntimeProvider>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
</Tab>
|
|
144
|
+
|
|
145
|
+
<Tab value="Authenticated (Clerk)">
|
|
146
|
+
|
|
147
|
+
```tsx title="app/chat/runtime-provider.tsx"
|
|
148
|
+
"use client";
|
|
149
|
+
|
|
150
|
+
import {
|
|
151
|
+
AssistantCloud,
|
|
152
|
+
AssistantRuntimeProvider,
|
|
153
|
+
useCloudThreadListRuntime,
|
|
154
|
+
useThreadListItemRuntime,
|
|
155
|
+
} from "@assistant-ui/react";
|
|
156
|
+
import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
157
|
+
import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
158
|
+
import { LangChainMessage } from "@assistant-ui/react-langgraph";
|
|
159
|
+
import { useAuth } from "@clerk/nextjs";
|
|
160
|
+
import { useMemo } from "react";
|
|
161
|
+
|
|
162
|
+
const useMyLangGraphRuntime = () => {
|
|
163
|
+
const threadListItemRuntime = useThreadListItemRuntime();
|
|
164
|
+
|
|
165
|
+
const runtime = useLangGraphRuntime({
|
|
166
|
+
stream: async function* (messages) {
|
|
167
|
+
const { externalId } = await threadListItemRuntime.initialize();
|
|
168
|
+
if (!externalId) throw new Error("Thread not found");
|
|
169
|
+
|
|
170
|
+
return sendMessage({
|
|
171
|
+
threadId: externalId,
|
|
172
|
+
messages,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
onSwitchToThread: async (externalId) => {
|
|
177
|
+
const state = await getThreadState(externalId);
|
|
178
|
+
return {
|
|
179
|
+
messages:
|
|
180
|
+
(state.values as { messages?: LangChainMessage[] }).messages ?? []
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return runtime;
|
|
186
|
+
};
|
|
187
|
+
|
|
72
188
|
export function MyRuntimeProvider({
|
|
73
189
|
children,
|
|
74
190
|
}: Readonly<{
|
|
@@ -79,7 +195,7 @@ export function MyRuntimeProvider({
|
|
|
79
195
|
const cloud = useMemo(
|
|
80
196
|
() =>
|
|
81
197
|
new AssistantCloud({
|
|
82
|
-
baseUrl: process.env
|
|
198
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
83
199
|
authToken: async () => getToken({ template: "assistant-ui" }),
|
|
84
200
|
}),
|
|
85
201
|
[getToken],
|
|
@@ -102,22 +218,61 @@ export function MyRuntimeProvider({
|
|
|
102
218
|
}
|
|
103
219
|
```
|
|
104
220
|
|
|
105
|
-
<Callout
|
|
106
|
-
|
|
107
|
-
function. This hook will be mounted multiple times, once per active thread.
|
|
221
|
+
<Callout type="info">
|
|
222
|
+
For Clerk authentication, configure the `"assistant-ui"` token template in your Clerk dashboard.
|
|
108
223
|
</Callout>
|
|
109
224
|
|
|
110
|
-
|
|
225
|
+
</Tab>
|
|
111
226
|
|
|
112
|
-
|
|
227
|
+
</Tabs>
|
|
113
228
|
|
|
114
|
-
|
|
115
|
-
|
|
229
|
+
<Callout type="info">
|
|
230
|
+
The `useMyLangGraphRuntime` hook is extracted into a separate function because it will be mounted multiple times, once per active thread.
|
|
231
|
+
</Callout>
|
|
232
|
+
|
|
233
|
+
</Step>
|
|
234
|
+
|
|
235
|
+
<Step>
|
|
236
|
+
|
|
237
|
+
### Add Thread UI Components
|
|
238
|
+
|
|
239
|
+
Install the thread list component:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npx assistant-ui add thread-list
|
|
116
243
|
```
|
|
117
244
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
245
|
+
Then add it to your application layout:
|
|
246
|
+
|
|
247
|
+
```tsx title="app/chat/page.tsx"
|
|
248
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
249
|
+
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
250
|
+
|
|
251
|
+
export default function ChatPage() {
|
|
252
|
+
return (
|
|
253
|
+
<div className="grid h-dvh grid-cols-[250px_1fr] gap-x-2">
|
|
254
|
+
<ThreadList />
|
|
255
|
+
<Thread />
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
123
259
|
```
|
|
260
|
+
|
|
261
|
+
</Step>
|
|
262
|
+
|
|
263
|
+
</Steps>
|
|
264
|
+
|
|
265
|
+
## Authentication
|
|
266
|
+
|
|
267
|
+
The examples above show two authentication modes:
|
|
268
|
+
|
|
269
|
+
- **Anonymous**: Suitable for demos and prototypes. Creates a browser session-based user ID.
|
|
270
|
+
- **Authenticated**: For production use with user accounts. The authenticated example uses [Clerk](https://clerk.com/), but you can integrate any auth provider.
|
|
271
|
+
|
|
272
|
+
For other authentication providers or custom implementations, see the [Cloud Authorization](/docs/cloud/authorization) guide.
|
|
273
|
+
|
|
274
|
+
## Next Steps
|
|
275
|
+
|
|
276
|
+
- Learn about [LangGraph runtime setup](/docs/runtimes/langgraph) for your application
|
|
277
|
+
- Explore [ThreadListRuntime](/docs/api-reference/runtimes/ThreadListRuntime) for advanced thread management
|
|
278
|
+
- Check out the [LangGraph example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-langgraph) on GitHub
|
|
@@ -66,7 +66,7 @@ import { File, Folder, Files } from "fumadocs-ui/components/files";
|
|
|
66
66
|
<Folder name="ThreadRuntime" defaultOpen>
|
|
67
67
|
<Folder name="MessageRuntime" defaultOpen>
|
|
68
68
|
<Folder
|
|
69
|
-
name="
|
|
69
|
+
name="MessagePartRuntime (Text / Reasoning / Image / Audio / Tool-Call / UI)"
|
|
70
70
|
defaultOpen
|
|
71
71
|
></Folder>
|
|
72
72
|
<Folder name="MessageAttachmentRuntime" defaultOpen></Folder>
|
|
@@ -95,8 +95,8 @@ The following components provide the runtime APIs:
|
|
|
95
95
|
// renders every message, provides MessageRuntime, ComposerRuntime (EditComposer)
|
|
96
96
|
<ThreadPrimitive.Messages components={{ Message, ... }} />
|
|
97
97
|
|
|
98
|
-
// renders every
|
|
99
|
-
<MessagePrimitive.
|
|
98
|
+
// renders every message part, provides MessagePartRuntime
|
|
99
|
+
<MessagePrimitive.Parts components={{ Text, Reasoning, Image, Audio, UI, tools }} />
|
|
100
100
|
|
|
101
101
|
// renders every attachment, provides AttachmentRuntime (Thread or EditComposer)
|
|
102
102
|
<ComposerPrimitive.Attachments components={{ Attachment, ... }} />
|
|
@@ -104,8 +104,8 @@ The following components provide the runtime APIs:
|
|
|
104
104
|
// renders every attachment, provides AtatchmentRuntime (Message)
|
|
105
105
|
<MessagePrimitive.Attachments components={{ Attachment, ... }} />
|
|
106
106
|
|
|
107
|
-
// provides a custom
|
|
108
|
-
<
|
|
107
|
+
// provides a custom TextMessagePartRuntime
|
|
108
|
+
<TextMessagePartProvider text="Hello!" />
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
### Accessing runtime APIs
|
|
@@ -116,7 +116,7 @@ You can access the runtime APIs with react hooks:
|
|
|
116
116
|
const runtime = useAssistantRuntime();
|
|
117
117
|
const threadRuntime = useThreadRuntime();
|
|
118
118
|
const messageRuntime = useMessageRuntime();
|
|
119
|
-
const
|
|
119
|
+
const MessagePartRuntime = useMessagePartRuntime();
|
|
120
120
|
|
|
121
121
|
// thread manager has no separate hook (1:1 relationship with assistant runtime)
|
|
122
122
|
const ThreadListRuntime = useAssistantRuntime().threads;
|
|
@@ -145,7 +145,7 @@ Most runtimes also expose a state through two methods `getState` and `subscribe`
|
|
|
145
145
|
useThreadList(); // get thread manager state
|
|
146
146
|
useThread(); // get thread state
|
|
147
147
|
useMessage(); // get message state
|
|
148
|
-
|
|
148
|
+
useMessagePart(); // get message part state
|
|
149
149
|
useComposer(); // get composer state
|
|
150
150
|
useThreadComposer(); // get thread composer state
|
|
151
151
|
useEditComposer(); // get edit composer state
|
|
@@ -29,21 +29,23 @@ const MyToolUI = makeAssistantToolUI({
|
|
|
29
29
|
{
|
|
30
30
|
name: "toolName",
|
|
31
31
|
type: "string",
|
|
32
|
-
description:
|
|
32
|
+
description:
|
|
33
|
+
"The name of the tool. This must match the name of the tool defined in the assistant.",
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
36
|
name: "render",
|
|
36
|
-
type: "ComponentType<
|
|
37
|
-
description:
|
|
37
|
+
type: "ComponentType<ToolCallMessagePartProps<TArgs, TResult>>",
|
|
38
|
+
description:
|
|
39
|
+
"A React component that renders the tool UI. Receives the following props:",
|
|
38
40
|
required: true,
|
|
39
41
|
children: [
|
|
40
42
|
{
|
|
41
|
-
type: "
|
|
43
|
+
type: "ToolCallMessagePartProps<TArgs, TResult>",
|
|
42
44
|
parameters: [
|
|
43
45
|
{
|
|
44
46
|
name: "type",
|
|
45
|
-
type: "
|
|
46
|
-
description: "The
|
|
47
|
+
type: '"tool-call"',
|
|
48
|
+
description: "The message part type",
|
|
47
49
|
},
|
|
48
50
|
{
|
|
49
51
|
name: "toolCallId",
|
|
@@ -77,18 +79,21 @@ const MyToolUI = makeAssistantToolUI({
|
|
|
77
79
|
},
|
|
78
80
|
{
|
|
79
81
|
name: "status",
|
|
80
|
-
type: "
|
|
81
|
-
description:
|
|
82
|
+
type: "ToolCallMessagePartStatus",
|
|
83
|
+
description:
|
|
84
|
+
'The execution status object with a type property: "running", "complete", "incomplete", or "requires_action"',
|
|
82
85
|
},
|
|
83
86
|
{
|
|
84
87
|
name: "addResult",
|
|
85
88
|
type: "(result: TResult | ToolResponse<TResult>) => void",
|
|
86
|
-
description:
|
|
89
|
+
description:
|
|
90
|
+
"Function to add a result (useful for human-in-the-loop tools)",
|
|
87
91
|
},
|
|
88
92
|
{
|
|
89
93
|
name: "artifact",
|
|
90
94
|
type: "unknown",
|
|
91
|
-
description:
|
|
95
|
+
description:
|
|
96
|
+
"Optional artifact data associated with the tool call",
|
|
92
97
|
},
|
|
93
98
|
],
|
|
94
99
|
},
|
|
@@ -110,10 +115,13 @@ import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
|
110
115
|
const GetWeatherUI = makeAssistantToolUI({
|
|
111
116
|
toolName: "get_weather",
|
|
112
117
|
render: ({ args, result, status }) => {
|
|
113
|
-
if (status.type === "requires_action")
|
|
118
|
+
if (status.type === "requires_action")
|
|
119
|
+
return <p>Getting weather for {args.location}...</p>;
|
|
114
120
|
if (status.type === "running") return <p>Loading...</p>;
|
|
115
|
-
if (status.type === "incomplete" && status.reason === "error")
|
|
116
|
-
|
|
121
|
+
if (status.type === "incomplete" && status.reason === "error")
|
|
122
|
+
return <p>Error getting weather.</p>;
|
|
123
|
+
if (status.type === "complete")
|
|
124
|
+
return <p>The weather is {result.weather}.</p>;
|
|
117
125
|
return null;
|
|
118
126
|
},
|
|
119
127
|
});
|
|
@@ -127,4 +135,5 @@ function App() {
|
|
|
127
135
|
);
|
|
128
136
|
}
|
|
129
137
|
```
|
|
138
|
+
|
|
130
139
|
This example shows how to create a simple UI for a `get_weather` tool. The UI will display different messages depending on the status of the tool execution.
|
|
@@ -27,7 +27,7 @@ const submitForm = tool({
|
|
|
27
27
|
// Create a tool component
|
|
28
28
|
const SubmitFormTool = makeAssistantTool({
|
|
29
29
|
...submitForm,
|
|
30
|
-
toolName: "submitForm"
|
|
30
|
+
toolName: "submitForm",
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Use in your component
|
|
@@ -57,13 +57,15 @@ function Form() {
|
|
|
57
57
|
{
|
|
58
58
|
name: "parameters",
|
|
59
59
|
type: "StandardSchemaV1<TArgs> | JSONSchema7",
|
|
60
|
-
description:
|
|
60
|
+
description:
|
|
61
|
+
"Schema defining the tool's parameters (typically a Zod schema)",
|
|
61
62
|
required: true,
|
|
62
63
|
},
|
|
63
64
|
{
|
|
64
65
|
name: "execute",
|
|
65
66
|
type: "(args: TArgs, context: ToolExecutionContext) => TResult | Promise<TResult>",
|
|
66
|
-
description:
|
|
67
|
+
description:
|
|
68
|
+
"Function that implements the tool's behavior (required for frontend tools)",
|
|
67
69
|
required: true,
|
|
68
70
|
},
|
|
69
71
|
{
|
|
@@ -73,16 +75,17 @@ function Form() {
|
|
|
73
75
|
},
|
|
74
76
|
{
|
|
75
77
|
name: "render",
|
|
76
|
-
type: "ComponentType<
|
|
77
|
-
description:
|
|
78
|
+
type: "ComponentType<ToolCallMessagePartProps<TArgs, TResult>>",
|
|
79
|
+
description:
|
|
80
|
+
"Optional custom UI component for rendering the tool execution. Receives the following props:",
|
|
78
81
|
children: [
|
|
79
82
|
{
|
|
80
|
-
type: "
|
|
83
|
+
type: "ToolCallMessagePartProps<TArgs, TResult>",
|
|
81
84
|
parameters: [
|
|
82
85
|
{
|
|
83
86
|
name: "type",
|
|
84
|
-
type: "
|
|
85
|
-
description: "The
|
|
87
|
+
type: '"tool-call"',
|
|
88
|
+
description: "The message part type",
|
|
86
89
|
},
|
|
87
90
|
{
|
|
88
91
|
name: "toolCallId",
|
|
@@ -116,18 +119,21 @@ function Form() {
|
|
|
116
119
|
},
|
|
117
120
|
{
|
|
118
121
|
name: "status",
|
|
119
|
-
type: "
|
|
120
|
-
description:
|
|
122
|
+
type: "ToolCallMessagePartStatus",
|
|
123
|
+
description:
|
|
124
|
+
'The execution status object with a type property: "running", "complete", "incomplete", or "requires_action"',
|
|
121
125
|
},
|
|
122
126
|
{
|
|
123
127
|
name: "addResult",
|
|
124
128
|
type: "(result: TResult | ToolResponse<TResult>) => void",
|
|
125
|
-
description:
|
|
129
|
+
description:
|
|
130
|
+
"Function to add a result (useful for human-in-the-loop tools)",
|
|
126
131
|
},
|
|
127
132
|
{
|
|
128
133
|
name: "artifact",
|
|
129
134
|
type: "unknown",
|
|
130
|
-
description:
|
|
135
|
+
description:
|
|
136
|
+
"Optional artifact data associated with the tool call",
|
|
131
137
|
},
|
|
132
138
|
],
|
|
133
139
|
},
|
|
@@ -176,11 +182,11 @@ const sendEmail = tool({
|
|
|
176
182
|
// Create tool components
|
|
177
183
|
const EmailValidator = makeAssistantTool({
|
|
178
184
|
...validateEmail,
|
|
179
|
-
toolName: "validateEmail"
|
|
185
|
+
toolName: "validateEmail",
|
|
180
186
|
});
|
|
181
187
|
const EmailSender = makeAssistantTool({
|
|
182
188
|
...sendEmail,
|
|
183
|
-
toolName: "sendEmail"
|
|
189
|
+
toolName: "sendEmail",
|
|
184
190
|
});
|
|
185
191
|
|
|
186
192
|
// Use together
|
|
@@ -15,6 +15,7 @@ import { Card, Cards } from "fumadocs-ui/components/card";
|
|
|
15
15
|
<Step>
|
|
16
16
|
|
|
17
17
|
### Initialize assistant-ui
|
|
18
|
+
|
|
18
19
|
**Create a new project:**
|
|
19
20
|
|
|
20
21
|
```sh
|
|
@@ -349,7 +350,7 @@ const UserMessage: FC = () => {
|
|
|
349
350
|
<UserActionBar />
|
|
350
351
|
|
|
351
352
|
<div className="aui-user-message-content">
|
|
352
|
-
<MessagePrimitive.
|
|
353
|
+
<MessagePrimitive.Parts />
|
|
353
354
|
</div>
|
|
354
355
|
|
|
355
356
|
<BranchPicker className="aui-user-branch-picker" />
|
|
@@ -394,7 +395,7 @@ const AssistantMessage: FC = () => {
|
|
|
394
395
|
return (
|
|
395
396
|
<MessagePrimitive.Root className="aui-assistant-message-root">
|
|
396
397
|
<div className="aui-assistant-message-content">
|
|
397
|
-
<MessagePrimitive.
|
|
398
|
+
<MessagePrimitive.Parts components={{ Text: MarkdownText }} />
|
|
398
399
|
</div>
|
|
399
400
|
|
|
400
401
|
<AssistantActionBar />
|
|
@@ -1110,23 +1111,23 @@ const MyApp = () => {
|
|
|
1110
1111
|
## What's Next?
|
|
1111
1112
|
|
|
1112
1113
|
<Cards>
|
|
1113
|
-
<Card
|
|
1114
|
-
title="Pick a Runtime"
|
|
1114
|
+
<Card
|
|
1115
|
+
title="Pick a Runtime"
|
|
1115
1116
|
description="Choose the right runtime for your needs"
|
|
1116
1117
|
href="/docs/runtimes/pick-a-runtime"
|
|
1117
1118
|
/>
|
|
1118
|
-
<Card
|
|
1119
|
-
title="Generative UI"
|
|
1119
|
+
<Card
|
|
1120
|
+
title="Generative UI"
|
|
1120
1121
|
description="Create rich UI components for tool executions"
|
|
1121
1122
|
href="/docs/guides/ToolUI"
|
|
1122
1123
|
/>
|
|
1123
|
-
<Card
|
|
1124
|
-
title="Add Persistence"
|
|
1124
|
+
<Card
|
|
1125
|
+
title="Add Persistence"
|
|
1125
1126
|
description="Save and restore chat conversations"
|
|
1126
1127
|
href="/docs/cloud/overview"
|
|
1127
1128
|
/>
|
|
1128
|
-
<Card
|
|
1129
|
-
title="Examples"
|
|
1129
|
+
<Card
|
|
1130
|
+
title="Examples"
|
|
1130
1131
|
description="Explore full implementations and demos"
|
|
1131
1132
|
href="https://github.com/assistant-ui/assistant-ui/tree/main/examples"
|
|
1132
1133
|
/>
|