@assistant-ui/mcp-docs-server 0.1.20 → 0.1.21
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/with-ag-ui.md +112 -16
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +5 -5
- package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
- package/.docs/organized/code-examples/with-cloud.md +5 -5
- package/.docs/organized/code-examples/with-custom-thread-list.md +5 -5
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +8 -8
- package/.docs/organized/code-examples/with-external-store.md +4 -4
- package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
- package/.docs/organized/code-examples/with-langgraph.md +3 -3
- package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
- package/.docs/organized/code-examples/with-react-hook-form.md +6 -6
- package/.docs/organized/code-examples/with-react-router.md +4 -4
- package/.docs/organized/code-examples/with-store.md +3 -3
- package/.docs/organized/code-examples/with-tanstack.md +6 -6
- package/.docs/organized/code-examples/with-tap-runtime.md +812 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -1
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -1
- package/.docs/raw/docs/(docs)/devtools.mdx +0 -1
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +0 -1
- package/.docs/raw/docs/(docs)/installation.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +13 -45
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +12 -35
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +3 -11
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -3
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +5 -16
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +2 -3
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -1
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +118 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +198 -0
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -1
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -11
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -2
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -1
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -2
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -1
- package/.docs/raw/docs/ui/accordion.mdx +0 -2
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -3
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -3
- package/.docs/raw/docs/ui/attachment.mdx +0 -2
- package/.docs/raw/docs/ui/badge.mdx +0 -2
- package/.docs/raw/docs/ui/diff-viewer.mdx +279 -0
- package/.docs/raw/docs/ui/file.mdx +0 -1
- package/.docs/raw/docs/ui/image.mdx +0 -1
- package/.docs/raw/docs/ui/markdown.mdx +0 -1
- package/.docs/raw/docs/ui/mermaid.mdx +0 -1
- package/.docs/raw/docs/ui/model-selector.mdx +0 -2
- package/.docs/raw/docs/ui/part-grouping.mdx +2 -3
- package/.docs/raw/docs/ui/reasoning.mdx +2 -3
- package/.docs/raw/docs/ui/scrollbar.mdx +26 -9
- package/.docs/raw/docs/ui/select.mdx +0 -2
- package/.docs/raw/docs/ui/sources.mdx +0 -1
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +8 -63
- package/.docs/raw/docs/ui/tabs.mdx +0 -2
- package/.docs/raw/docs/ui/thread-list.mdx +98 -16
- package/.docs/raw/docs/ui/thread.mdx +1 -3
- package/.docs/raw/docs/ui/tool-fallback.mdx +0 -1
- package/.docs/raw/docs/ui/tool-group.mdx +1 -3
- package/package.json +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +0 -219
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI SDK v5 (Legacy)
|
|
3
|
+
description: Integrate Vercel AI SDK v5 with useChatRuntime for streaming chat.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<Callout type="error">
|
|
7
|
+
AI SDK v5 is no longer supported. The `@assistant-ui/react-ai-sdk` package now requires AI SDK v6+.
|
|
8
|
+
Please upgrade to [AI SDK v6](/docs/runtimes/ai-sdk/v6).
|
|
9
|
+
</Callout>
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
This documentation is preserved for reference. For new projects, use [AI SDK v6](/docs/runtimes/ai-sdk/v6).
|
|
14
|
+
|
|
15
|
+
## Getting Started
|
|
16
|
+
|
|
17
|
+
<Steps>
|
|
18
|
+
<Step>
|
|
19
|
+
### Create a Next.js project
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx create-next-app@latest my-app
|
|
23
|
+
cd my-app
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
</Step>
|
|
27
|
+
<Step>
|
|
28
|
+
|
|
29
|
+
### Install AI SDK v5 and `@assistant-ui/react`
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm install @assistant-ui/react @assistant-ui/react-ai-sdk@0.x ai@^5 @ai-sdk/openai@^1 zod
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
</Step>
|
|
36
|
+
<Step>
|
|
37
|
+
|
|
38
|
+
### Setup a backend route under `/api/chat`
|
|
39
|
+
|
|
40
|
+
`@/app/api/chat/route.ts`
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { openai } from "@ai-sdk/openai";
|
|
44
|
+
import { streamText, tool } from "ai";
|
|
45
|
+
import type { Message } from "ai";
|
|
46
|
+
import { z } from "zod";
|
|
47
|
+
|
|
48
|
+
export const maxDuration = 30;
|
|
49
|
+
|
|
50
|
+
export async function POST(req: Request) {
|
|
51
|
+
const { messages }: { messages: Message[] } = await req.json();
|
|
52
|
+
|
|
53
|
+
const result = streamText({
|
|
54
|
+
model: openai("gpt-4o"),
|
|
55
|
+
messages,
|
|
56
|
+
tools: {
|
|
57
|
+
get_current_weather: tool({
|
|
58
|
+
description: "Get the current weather",
|
|
59
|
+
parameters: z.object({
|
|
60
|
+
city: z.string(),
|
|
61
|
+
}),
|
|
62
|
+
execute: async ({ city }) => {
|
|
63
|
+
return `The weather in ${city} is sunny`;
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return result.toDataStreamResponse();
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
</Step>
|
|
74
|
+
<Step>
|
|
75
|
+
|
|
76
|
+
### Setup the frontend
|
|
77
|
+
|
|
78
|
+
`@/app/page.tsx`
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
"use client";
|
|
82
|
+
|
|
83
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
84
|
+
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
85
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
86
|
+
|
|
87
|
+
export default function Home() {
|
|
88
|
+
const runtime = useChatRuntime({
|
|
89
|
+
api: "/api/chat",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
94
|
+
<div className="h-full">
|
|
95
|
+
<Thread />
|
|
96
|
+
</div>
|
|
97
|
+
</AssistantRuntimeProvider>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
</Step>
|
|
103
|
+
</Steps>
|
|
104
|
+
|
|
105
|
+
## Key Differences from v6
|
|
106
|
+
|
|
107
|
+
| Feature | v5 | v6 |
|
|
108
|
+
|---------|----|----|
|
|
109
|
+
| **ai package** | `ai@^5` | `ai@^6` |
|
|
110
|
+
| **@ai-sdk/openai** | `@ai-sdk/openai@^1` | `@ai-sdk/openai@^3` |
|
|
111
|
+
| **Message type** | `Message` | `UIMessage` |
|
|
112
|
+
| **convertToModelMessages** | Sync | Async (`await`) |
|
|
113
|
+
| **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
114
|
+
| **Response** | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
|
|
115
|
+
|
|
116
|
+
## Migration to v6
|
|
117
|
+
|
|
118
|
+
See the [AI SDK v6 documentation](/docs/runtimes/ai-sdk/v6) for the latest integration guide.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AI SDK v6
|
|
3
|
+
description: Integrate Vercel AI SDK v6 with assistant-ui for streaming chat.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Integration with the Vercel AI SDK v6 using the `useChatRuntime` hook from `@assistant-ui/react-ai-sdk`.
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
<Steps>
|
|
14
|
+
<Step>
|
|
15
|
+
### Create a Next.js project
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx create-next-app@latest my-app
|
|
19
|
+
cd my-app
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
</Step>
|
|
23
|
+
<Step>
|
|
24
|
+
|
|
25
|
+
### Install dependencies
|
|
26
|
+
|
|
27
|
+
<InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk", "ai@^6", "@ai-sdk/react@^3", "@ai-sdk/openai", "zod"]} />
|
|
28
|
+
|
|
29
|
+
</Step>
|
|
30
|
+
<Step>
|
|
31
|
+
|
|
32
|
+
### Setup a backend route under `/api/chat`
|
|
33
|
+
|
|
34
|
+
`@/app/api/chat/route.ts`
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { openai } from "@ai-sdk/openai";
|
|
38
|
+
import {
|
|
39
|
+
streamText,
|
|
40
|
+
convertToModelMessages,
|
|
41
|
+
tool,
|
|
42
|
+
zodSchema,
|
|
43
|
+
} from "ai";
|
|
44
|
+
import type { UIMessage } from "ai";
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
|
|
47
|
+
export const maxDuration = 30;
|
|
48
|
+
|
|
49
|
+
export async function POST(req: Request) {
|
|
50
|
+
const { messages }: { messages: UIMessage[] } = await req.json();
|
|
51
|
+
|
|
52
|
+
const result = streamText({
|
|
53
|
+
model: openai("gpt-4o"),
|
|
54
|
+
messages: await convertToModelMessages(messages), // Note: async in v6
|
|
55
|
+
tools: {
|
|
56
|
+
get_current_weather: tool({
|
|
57
|
+
description: "Get the current weather",
|
|
58
|
+
inputSchema: zodSchema(
|
|
59
|
+
z.object({
|
|
60
|
+
city: z.string(),
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
execute: async ({ city }) => {
|
|
64
|
+
return `The weather in ${city} is sunny`;
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return result.toUIMessageStreamResponse();
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
</Step>
|
|
75
|
+
<Step>
|
|
76
|
+
|
|
77
|
+
### Setup the frontend
|
|
78
|
+
|
|
79
|
+
`@/app/page.tsx`
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
"use client";
|
|
83
|
+
|
|
84
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
85
|
+
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
86
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
87
|
+
|
|
88
|
+
export default function Home() {
|
|
89
|
+
const runtime = useChatRuntime();
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
93
|
+
<div className="h-full">
|
|
94
|
+
<Thread />
|
|
95
|
+
</div>
|
|
96
|
+
</AssistantRuntimeProvider>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
</Step>
|
|
102
|
+
</Steps>
|
|
103
|
+
|
|
104
|
+
## Key Changes from v5
|
|
105
|
+
|
|
106
|
+
| Feature | v5 | v6 |
|
|
107
|
+
|---------|----|----|
|
|
108
|
+
| **ai package** | `ai@^5` | `ai@^6` |
|
|
109
|
+
| **@ai-sdk/react** | `@ai-sdk/react@^2` | `@ai-sdk/react@^3` |
|
|
110
|
+
| **convertToModelMessages** | Sync | Async (`await`) |
|
|
111
|
+
| **Tool schema** | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
112
|
+
|
|
113
|
+
## API Reference
|
|
114
|
+
|
|
115
|
+
### useChatRuntime
|
|
116
|
+
|
|
117
|
+
Creates a runtime integrated with AI SDK's `useChat` hook.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
121
|
+
|
|
122
|
+
const runtime = useChatRuntime({
|
|
123
|
+
api: "/api/chat", // optional, defaults to "/api/chat"
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Custom API URL
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
const runtime = useChatRuntime({
|
|
131
|
+
api: "/my-custom-api/chat",
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Forwarding System Messages and Frontend Tools
|
|
136
|
+
|
|
137
|
+
Use `AssistantChatTransport` to automatically forward system messages and frontend tools to your backend:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
"use client";
|
|
141
|
+
|
|
142
|
+
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
143
|
+
|
|
144
|
+
const runtime = useChatRuntime({
|
|
145
|
+
transport: new AssistantChatTransport({
|
|
146
|
+
api: "/api/chat",
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Backend route with system/tools forwarding:
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
import { openai } from "@ai-sdk/openai";
|
|
155
|
+
import { streamText, convertToModelMessages, zodSchema } from "ai";
|
|
156
|
+
import type { UIMessage } from "ai";
|
|
157
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
158
|
+
|
|
159
|
+
export async function POST(req: Request) {
|
|
160
|
+
const {
|
|
161
|
+
messages,
|
|
162
|
+
system,
|
|
163
|
+
tools,
|
|
164
|
+
}: {
|
|
165
|
+
messages: UIMessage[];
|
|
166
|
+
system?: string;
|
|
167
|
+
tools?: any;
|
|
168
|
+
} = await req.json();
|
|
169
|
+
|
|
170
|
+
const result = streamText({
|
|
171
|
+
model: openai("gpt-4o"),
|
|
172
|
+
system,
|
|
173
|
+
messages: await convertToModelMessages(messages),
|
|
174
|
+
tools: {
|
|
175
|
+
...frontendTools(tools),
|
|
176
|
+
// your backend tools...
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return result.toUIMessageStreamResponse();
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### useAISDKRuntime (Advanced)
|
|
185
|
+
|
|
186
|
+
For advanced use cases where you need direct access to the `useChat` hook:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { useChat } from "@ai-sdk/react";
|
|
190
|
+
import { useAISDKRuntime } from "@assistant-ui/react-ai-sdk";
|
|
191
|
+
|
|
192
|
+
const chat = useChat();
|
|
193
|
+
const runtime = useAISDKRuntime(chat);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Example
|
|
197
|
+
|
|
198
|
+
For a complete example, check out the [AI SDK v6 example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-ai-sdk-v6) in our repository.
|
|
@@ -3,8 +3,6 @@ title: ExternalStoreRuntime
|
|
|
3
3
|
description: Bring your own Redux, Zustand, or state manager.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
8
6
|
|
|
9
7
|
## Overview
|
|
10
8
|
|
|
@@ -154,7 +152,7 @@ graph TD
|
|
|
154
152
|
<InstallCommand npm={["@assistant-ui/react"]} />
|
|
155
153
|
|
|
156
154
|
</Step>
|
|
157
|
-
|
|
155
|
+
|
|
158
156
|
<Step>
|
|
159
157
|
### Create Runtime Provider
|
|
160
158
|
|
|
@@ -168,45 +166,45 @@ graph TD
|
|
|
168
166
|
useExternalStoreRuntime,
|
|
169
167
|
} from "@assistant-ui/react";
|
|
170
168
|
import { useState } from "react";
|
|
171
|
-
|
|
169
|
+
|
|
172
170
|
const convertMessage = (message: ThreadMessageLike) => {
|
|
173
171
|
return message;
|
|
174
172
|
};
|
|
175
|
-
|
|
173
|
+
|
|
176
174
|
export function MyRuntimeProvider({
|
|
177
175
|
children,
|
|
178
176
|
}: Readonly<{
|
|
179
177
|
children: React.ReactNode;
|
|
180
178
|
}>) {
|
|
181
179
|
const [messages, setMessages] = useState<readonly ThreadMessageLike[]>([]);
|
|
182
|
-
|
|
180
|
+
|
|
183
181
|
const onNew = async (message: AppendMessage) => {
|
|
184
182
|
if (message.content.length !== 1 || message.content[0]?.type !== "text")
|
|
185
183
|
throw new Error("Only text content is supported");
|
|
186
|
-
|
|
184
|
+
|
|
187
185
|
const userMessage: ThreadMessageLike = {
|
|
188
186
|
role: "user",
|
|
189
187
|
content: [{ type: "text", text: message.content[0].text }],
|
|
190
188
|
};
|
|
191
189
|
setMessages((currentMessages) => [...currentMessages, userMessage]);
|
|
192
|
-
|
|
190
|
+
|
|
193
191
|
// normally you would perform an API call here to get the assistant response
|
|
194
192
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
195
|
-
|
|
193
|
+
|
|
196
194
|
const assistantMessage: ThreadMessageLike = {
|
|
197
195
|
role: "assistant",
|
|
198
196
|
content: [{ type: "text", text: "Hello, world!" }],
|
|
199
197
|
};
|
|
200
198
|
setMessages((currentMessages) => [...currentMessages, assistantMessage]);
|
|
201
199
|
};
|
|
202
|
-
|
|
200
|
+
|
|
203
201
|
const runtime = useExternalStoreRuntime<ThreadMessageLike>({
|
|
204
202
|
messages,
|
|
205
203
|
setMessages,
|
|
206
204
|
onNew,
|
|
207
205
|
convertMessage,
|
|
208
206
|
});
|
|
209
|
-
|
|
207
|
+
|
|
210
208
|
return (
|
|
211
209
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
212
210
|
{children}
|
|
@@ -3,8 +3,6 @@ title: LocalRuntime
|
|
|
3
3
|
description: Quickest path to a working chat. Handles state while you handle the API.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
8
6
|
|
|
9
7
|
## Overview
|
|
10
8
|
|
|
@@ -3,7 +3,6 @@ title: Data Stream Protocol
|
|
|
3
3
|
description: Integration with data stream protocol endpoints for streaming AI responses.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
|
|
8
7
|
The `@assistant-ui/react-data-stream` package provides integration with data stream protocol endpoints, enabling streaming AI responses with tool support and state management.
|
|
9
8
|
|
|
@@ -36,7 +36,6 @@ NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID=your_graph_id
|
|
|
36
36
|
</Step>
|
|
37
37
|
</Steps>
|
|
38
38
|
|
|
39
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
40
39
|
|
|
41
40
|
## Installation in existing React project
|
|
42
41
|
|
|
@@ -232,7 +231,7 @@ export function MyAssistant() {
|
|
|
232
231
|
|
|
233
232
|
### Use the `MyAssistant` component
|
|
234
233
|
|
|
235
|
-
```tsx twoslash title="@/app/page.tsx" {
|
|
234
|
+
```tsx twoslash title="@/app/page.tsx" {1,6}
|
|
236
235
|
// @include: MyAssistant
|
|
237
236
|
// @filename: /app/page.tsx
|
|
238
237
|
// ---cut---
|
|
@@ -6,7 +6,6 @@ description: Add human-in-the-loop approval for tool calls.
|
|
|
6
6
|
## Background: LangGraph implementation details
|
|
7
7
|
|
|
8
8
|
import Image from "next/image";
|
|
9
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
10
9
|
import approval from "./images/stockbroker-langgraph.png";
|
|
11
10
|
|
|
12
11
|
<Image
|
|
@@ -3,7 +3,6 @@ title: Full-Stack Integration
|
|
|
3
3
|
description: Integrate Mastra directly into Next.js API routes.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
|
|
8
7
|
Integrate Mastra directly into your Next.js application's API routes. This approach keeps your backend and frontend code within the same project.
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@ title: Separate Server Integration
|
|
|
3
3
|
description: Run Mastra as a standalone server connected to your frontend.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
7
6
|
|
|
8
7
|
Run Mastra as a standalone server and connect your Next.js frontend (using assistant-ui) to its API endpoints. This approach separates your AI backend from your frontend application, allowing for independent development and scaling.
|
|
9
8
|
|
|
@@ -6,8 +6,6 @@ links:
|
|
|
6
6
|
url: https://www.radix-ui.com/primitives/docs/components/accordion
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
10
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
11
9
|
import { PreviewCode } from "@/components/docs/preview-code.server";
|
|
12
10
|
import {
|
|
13
11
|
AccordionSample,
|
|
@@ -3,8 +3,6 @@ title: AssistantModal
|
|
|
3
3
|
description: Floating chat bubble for support widgets and help desks.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
8
6
|
import { AssistantModalSample } from "@/components/docs/samples/assistant-modal";
|
|
9
7
|
|
|
10
8
|
A floating chat modal built on Radix UI Popover. Ideal for support widgets, help desks, and embedded assistants.
|
|
@@ -44,7 +42,7 @@ export default function Home() {
|
|
|
44
42
|
|
|
45
43
|
## Anatomy
|
|
46
44
|
|
|
47
|
-
The AssistantModal component is built with the following primitives:
|
|
45
|
+
The `AssistantModal` component is built with the following primitives:
|
|
48
46
|
|
|
49
47
|
```tsx
|
|
50
48
|
import { AssistantModalPrimitive } from "@assistant-ui/react";
|
|
@@ -3,8 +3,6 @@ title: AssistantSidebar
|
|
|
3
3
|
description: Side panel chat for co-pilot experiences and inline assistance.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
8
6
|
import { AssistantSidebarSample } from "@/components/docs/samples/assistant-sidebar";
|
|
9
7
|
|
|
10
8
|
A resizable side panel layout with your main content on the left and a Thread chat interface on the right. Ideal for co-pilot experiences and inline assistance.
|
|
@@ -13,7 +11,7 @@ A resizable side panel layout with your main content on the left and a Thread ch
|
|
|
13
11
|
|
|
14
12
|
## Getting Started
|
|
15
13
|
|
|
16
|
-
<Steps>
|
|
14
|
+
<Steps>
|
|
17
15
|
<Step>
|
|
18
16
|
|
|
19
17
|
### Add `assistant-sidebar`
|
|
@@ -3,9 +3,7 @@ title: Attachment
|
|
|
3
3
|
description: UI components for attaching and viewing files in messages.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
6
|
import { AttachmentSample } from "@/components/docs/samples/attachment";
|
|
8
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
9
7
|
|
|
10
8
|
<AttachmentSample />
|
|
11
9
|
|
|
@@ -6,8 +6,6 @@ links:
|
|
|
6
6
|
url: https://www.radix-ui.com/primitives/docs/utilities/slot
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
import { InstallCommand } from "@/components/docs/fumadocs/install/install-command";
|
|
10
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
11
9
|
import { PreviewCode } from "@/components/docs/preview-code.server";
|
|
12
10
|
import {
|
|
13
11
|
BadgeSample,
|