@assistant-ui/mcp-docs-server 0.1.29 → 0.1.31
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/waterfall.md +15 -7
- package/.docs/organized/code-examples/with-a2a.md +9 -21
- package/.docs/organized/code-examples/with-ag-ui.md +11 -8
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +10 -10
- package/.docs/organized/code-examples/with-artifacts.md +12 -10
- package/.docs/organized/code-examples/with-assistant-transport.md +11 -12
- package/.docs/organized/code-examples/with-chain-of-thought.md +83 -54
- package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
- package/.docs/organized/code-examples/with-cloud.md +9 -10
- package/.docs/organized/code-examples/with-custom-thread-list.md +61 -16
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +17 -12
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +13 -13
- package/.docs/organized/code-examples/with-expo.md +25 -21
- package/.docs/organized/code-examples/with-external-store.md +8 -8
- package/.docs/organized/code-examples/with-ffmpeg.md +17 -12
- package/.docs/organized/code-examples/with-generative-ui.md +9 -9
- package/.docs/organized/code-examples/with-google-adk.md +8 -8
- package/.docs/organized/code-examples/with-heat-graph.md +5 -5
- package/.docs/organized/code-examples/with-interactables.md +10 -25
- package/.docs/organized/code-examples/with-langchain.md +437 -0
- package/.docs/organized/code-examples/with-langgraph.md +16 -16
- package/.docs/organized/code-examples/with-livekit.md +18 -13
- package/.docs/organized/code-examples/with-opencode.md +105 -62
- package/.docs/organized/code-examples/with-parent-id-grouping.md +10 -10
- package/.docs/organized/code-examples/with-react-hook-form.md +220 -148
- package/.docs/organized/code-examples/with-react-ink.md +2 -2
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-store.md +8 -5
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/organized/code-examples/with-tap-runtime.md +10 -6
- package/.docs/raw/docs/(docs)/cli.mdx +2 -1
- package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
- package/.docs/raw/docs/(docs)/index.mdx +1 -0
- package/.docs/raw/docs/(docs)/installation.mdx +1 -0
- package/.docs/raw/docs/(docs)/rtl.mdx +80 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +9 -0
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +231 -3
- package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
- package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
- package/.docs/raw/docs/guides/branching.mdx +76 -0
- package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
- package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
- package/.docs/raw/docs/guides/editing.mdx +102 -0
- package/.docs/raw/docs/guides/index.mdx +103 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
- package/.docs/raw/docs/guides/mentions.mdx +520 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
- package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
- package/.docs/raw/docs/guides/slash-commands.mdx +361 -0
- package/.docs/raw/docs/guides/speech.mdx +156 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
- package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
- package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
- package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
- package/.docs/raw/docs/ink/index.mdx +1 -3
- package/.docs/raw/docs/ink/migration.mdx +1 -3
- package/.docs/raw/docs/ink/primitives.mdx +37 -1
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
- package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
- package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
- package/.docs/raw/docs/integrations/index.mdx +173 -0
- package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
- package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/primitives/attachment.mdx +1 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
- package/.docs/raw/docs/primitives/composer.mdx +96 -63
- package/.docs/raw/docs/primitives/error.mdx +1 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -1
- package/.docs/raw/docs/primitives/message.mdx +68 -5
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
- package/.docs/raw/docs/primitives/thread.mdx +16 -13
- package/.docs/raw/docs/react-native/index.mdx +1 -3
- package/.docs/raw/docs/react-native/migration.mdx +1 -3
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
- package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
- package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +365 -101
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
- package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
- package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
- package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
- package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
- package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +74 -198
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +200 -0
- package/.docs/raw/docs/ui/context-display.mdx +1 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
- package/.docs/raw/docs/ui/directive-text.mdx +114 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/mermaid.mdx +1 -0
- package/.docs/raw/docs/ui/message-timing.mdx +3 -2
- package/.docs/raw/docs/ui/model-selector.mdx +1 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
- package/.docs/raw/docs/ui/quote.mdx +1 -0
- package/.docs/raw/docs/ui/reasoning.mdx +69 -32
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +1 -0
- package/.docs/raw/docs/ui/streamdown.mdx +1 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
- package/.docs/raw/docs/ui/tabs.mdx +1 -0
- package/.docs/raw/docs/ui/thread-list.mdx +17 -0
- package/.docs/raw/docs/ui/thread.mdx +56 -1
- package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
- package/.docs/raw/docs/ui/tool-group.mdx +39 -11
- package/.docs/raw/docs/ui/voice.mdx +1 -0
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
- package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/package.json +4 -4
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/mentions.mdx +0 -406
- package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +0 -275
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -268
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -607
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
- package/.docs/raw/docs/ui/mention.mdx +0 -168
|
@@ -1,66 +1,51 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: AI SDK v4 (
|
|
3
|
-
description:
|
|
2
|
+
title: AI SDK v4 (legacy)
|
|
3
|
+
description: Reference for projects still on AI SDK v4. New projects should use v6.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
If you're using AI SDK v4 (legacy), you can integrate with assistant-ui using the `@assistant-ui/react-data-stream` package and its `useDataStreamRuntime` hook. This provides a compatible runtime that works with AI SDK v4's streaming responses.
|
|
10
|
-
|
|
11
|
-
<Callout type="warning">
|
|
12
|
-
AI SDK v4 is now considered legacy. We recommend upgrading to [AI SDK
|
|
13
|
-
v6](/docs/runtimes/ai-sdk/v6) for improved features and better
|
|
14
|
-
TypeScript support. This documentation is provided for projects that haven't
|
|
15
|
-
migrated yet.
|
|
8
|
+
<Callout type="warn">
|
|
9
|
+
AI SDK v4 is a legacy version. New projects should use [AI SDK v6](/docs/runtimes/ai-sdk/v6). v4 integrations use the older `@assistant-ui/react-data-stream` package, not `@assistant-ui/react-ai-sdk`.
|
|
16
10
|
</Callout>
|
|
17
11
|
|
|
18
|
-
##
|
|
12
|
+
## Why legacy
|
|
19
13
|
|
|
14
|
+
Vercel ships AI SDK majors roughly yearly; v4 is two majors behind v6. The current `@assistant-ui/react-ai-sdk` package targets v6+ exclusively, so v4 users plug into [`@assistant-ui/react-data-stream`](/docs/runtimes/custom/data-stream) instead — the same data stream protocol that v4's `toDataStreamResponse()` emits.
|
|
20
15
|
|
|
21
|
-
|
|
16
|
+
This page is reference for existing v4 projects. Plan to migrate to v6 when feasible.
|
|
17
|
+
|
|
18
|
+
## Setup
|
|
22
19
|
|
|
23
20
|
<Steps>
|
|
24
|
-
|
|
25
|
-
### Install the required packages
|
|
21
|
+
<Step>
|
|
26
22
|
|
|
27
|
-
Install
|
|
23
|
+
### Install
|
|
28
24
|
|
|
29
25
|
<InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-data-stream", "ai@^4"]} />
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Setup your backend route
|
|
27
|
+
</Step>
|
|
28
|
+
<Step>
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
### Backend route
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```tsx
|
|
32
|
+
```ts title="@/app/api/chat/route.ts"
|
|
41
33
|
import { streamText } from "ai";
|
|
42
34
|
import { openai } from "@ai-sdk/openai";
|
|
43
35
|
|
|
44
36
|
export async function POST(req: Request) {
|
|
45
37
|
const { messages } = await req.json();
|
|
46
|
-
|
|
47
|
-
const result = streamText({
|
|
48
|
-
model: openai("gpt-4"),
|
|
49
|
-
messages,
|
|
50
|
-
});
|
|
51
|
-
|
|
38
|
+
const result = streamText({ model: openai("gpt-4"), messages });
|
|
52
39
|
return result.toDataStreamResponse();
|
|
53
40
|
}
|
|
54
41
|
```
|
|
55
42
|
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
</Step>
|
|
44
|
+
<Step>
|
|
58
45
|
|
|
59
|
-
###
|
|
46
|
+
### Frontend
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```tsx
|
|
48
|
+
```tsx title="@/app/page.tsx"
|
|
64
49
|
"use client";
|
|
65
50
|
|
|
66
51
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
@@ -68,10 +53,7 @@ import { useDataStreamRuntime } from "@assistant-ui/react-data-stream";
|
|
|
68
53
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
69
54
|
|
|
70
55
|
export default function Home() {
|
|
71
|
-
const runtime = useDataStreamRuntime({
|
|
72
|
-
api: "/api/chat",
|
|
73
|
-
});
|
|
74
|
-
|
|
56
|
+
const runtime = useDataStreamRuntime({ api: "/api/chat" });
|
|
75
57
|
return (
|
|
76
58
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
77
59
|
<div className="h-full">
|
|
@@ -82,96 +64,54 @@ export default function Home() {
|
|
|
82
64
|
}
|
|
83
65
|
```
|
|
84
66
|
|
|
85
|
-
|
|
67
|
+
</Step>
|
|
86
68
|
</Steps>
|
|
87
69
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
api: "/api/chat",
|
|
137
|
-
// Options similar to AI SDK v4's useChat
|
|
138
|
-
initialMessages: [],
|
|
139
|
-
onFinish: (message) => {
|
|
140
|
-
console.log("Message completed:", message);
|
|
141
|
-
},
|
|
142
|
-
onError: (error) => {
|
|
143
|
-
console.error("Chat error:", error);
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
#### Options
|
|
149
|
-
|
|
150
|
-
The `useDataStreamRuntime` hook accepts options similar to AI SDK v4's `useChat` hook:
|
|
151
|
-
|
|
152
|
-
- **`api`**: The API endpoint for chat requests (required)
|
|
153
|
-
- **`initialMessages`**: Initial messages to populate the chat
|
|
154
|
-
- **`onFinish`**: Callback when a message completes streaming
|
|
155
|
-
- **`onError`**: Callback for handling errors
|
|
156
|
-
- **`headers`**: Additional headers to send with requests
|
|
157
|
-
- **`body`**: Additional body parameters to send with requests
|
|
158
|
-
|
|
159
|
-
<Callout type="info">
|
|
160
|
-
The `useDataStreamRuntime` API is designed to be familiar to developers
|
|
161
|
-
already using AI SDK v4's `useChat` hook, making migration straightforward.
|
|
162
|
-
</Callout>
|
|
163
|
-
|
|
164
|
-
## Migration to AI SDK v6
|
|
165
|
-
|
|
166
|
-
When you're ready to upgrade to AI SDK v6:
|
|
167
|
-
|
|
168
|
-
1. Replace `@assistant-ui/react-data-stream` with `@assistant-ui/react-ai-sdk`
|
|
169
|
-
2. Update your backend to use AI SDK v6's `streamText` API
|
|
170
|
-
3. Switch from `useDataStreamRuntime` to `useChatRuntime`
|
|
171
|
-
4. Take advantage of improved TypeScript support and automatic system/tool forwarding
|
|
172
|
-
|
|
173
|
-
See our [AI SDK v6 documentation](/docs/runtimes/ai-sdk/v6) for the complete migration guide.
|
|
174
|
-
|
|
175
|
-
## Example
|
|
176
|
-
|
|
177
|
-
For a working example with AI SDK v4, you can adapt the patterns from our [AI SDK examples](https://github.com/assistant-ui/assistant-ui/tree/main/examples) using the `@assistant-ui/react-data-stream` package instead of the v6 integration.
|
|
70
|
+
`useDataStreamRuntime` accepts `api`, `initialMessages`, `onFinish`, `onError`, `headers`, `body`, and the standard `LocalRuntimeOptions`. For the full reference, see [Data Stream Protocol](/docs/runtimes/custom/data-stream).
|
|
71
|
+
|
|
72
|
+
## Differences from v6
|
|
73
|
+
|
|
74
|
+
| Feature | v4 | v6 |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `ai` package | `ai@^4` | `ai@^6` |
|
|
77
|
+
| Runtime package | `@assistant-ui/react-data-stream` | `@assistant-ui/react-ai-sdk` |
|
|
78
|
+
| Runtime hook | `useDataStreamRuntime` | `useChatRuntime` |
|
|
79
|
+
| Response | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
|
|
80
|
+
| Tool schema | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
81
|
+
| Message type | (untyped) | `UIMessage` |
|
|
82
|
+
|
|
83
|
+
## Migration to v6
|
|
84
|
+
|
|
85
|
+
When you are ready to upgrade:
|
|
86
|
+
|
|
87
|
+
1. Swap `@assistant-ui/react-data-stream` for `@assistant-ui/react-ai-sdk`.
|
|
88
|
+
2. Update your backend to AI SDK v6's `streamText` (see [v6 docs](/docs/runtimes/ai-sdk/v6)).
|
|
89
|
+
3. Switch the runtime hook from `useDataStreamRuntime` to `useChatRuntime`.
|
|
90
|
+
|
|
91
|
+
AI SDK provides codemods at [ai-sdk.dev/docs/migration-guides](https://ai-sdk.dev/docs/migration-guides) that handle the package-side rewrites.
|
|
92
|
+
|
|
93
|
+
## Alternative: react-ai-sdk@0.1.10
|
|
94
|
+
|
|
95
|
+
An older release line of `@assistant-ui/react-ai-sdk` (0.1.10) supported AI SDK v4 directly. It is no longer maintained and has no upgrade path; if you are starting a new v4 project, use `@assistant-ui/react-data-stream` instead.
|
|
96
|
+
|
|
97
|
+
## Related
|
|
98
|
+
|
|
99
|
+
<Cards>
|
|
100
|
+
<Card
|
|
101
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
102
|
+
title="AI SDK v6"
|
|
103
|
+
description="Current integration; what new projects should target."
|
|
104
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
105
|
+
/>
|
|
106
|
+
<Card
|
|
107
|
+
title="Data Stream Protocol"
|
|
108
|
+
description="The runtime v4 integrations are built on."
|
|
109
|
+
href="/docs/runtimes/custom/data-stream"
|
|
110
|
+
/>
|
|
111
|
+
<Card
|
|
112
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
113
|
+
title="AI SDK v5 (legacy)"
|
|
114
|
+
description="The intermediate legacy version."
|
|
115
|
+
href="/docs/runtimes/ai-sdk/v5-legacy"
|
|
116
|
+
/>
|
|
117
|
+
</Cards>
|
|
@@ -1,45 +1,35 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: AI SDK v5 (
|
|
3
|
-
description:
|
|
2
|
+
title: AI SDK v5 (legacy)
|
|
3
|
+
description: Reference for projects still on AI SDK v5. New projects should use v6.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
|
|
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>
|
|
6
|
+
import { VercelIcon } from "@/components/icons/vercel";
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
<Callout type="warn">
|
|
9
|
+
AI SDK v5 is a legacy version. New projects should use [AI SDK v6](/docs/runtimes/ai-sdk/v6). v5 users stay on `@assistant-ui/react-ai-sdk@0.x`; the latest line targets v6+.
|
|
10
|
+
</Callout>
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## Why legacy
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
AI SDK v6 introduced major API changes: async `convertToModelMessages`, a new tool schema, and `toUIMessageStreamResponse()`. v5 still works but no longer receives new features in `@assistant-ui/react-ai-sdk`. Pinning to `@0.x` keeps you on the v5-compatible surface.
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
<Step>
|
|
19
|
-
### Create a Next.js project
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npx create-next-app@latest my-app
|
|
23
|
-
cd my-app
|
|
24
|
-
```
|
|
16
|
+
This page is reference for existing v5 projects. Plan to migrate to v6 when feasible.
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
<Step>
|
|
18
|
+
## Setup
|
|
28
19
|
|
|
29
|
-
|
|
20
|
+
<Steps>
|
|
21
|
+
<Step>
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
npm install @assistant-ui/react @assistant-ui/react-ai-sdk@0.x ai@^5 @ai-sdk/openai@^1 zod
|
|
33
|
-
```
|
|
23
|
+
### Install v5-compatible versions
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
<Step>
|
|
25
|
+
<InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-ai-sdk@0.x", "ai@^5", "@ai-sdk/openai@^1", "zod"]} />
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
</Step>
|
|
28
|
+
<Step>
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
### Backend route
|
|
41
31
|
|
|
42
|
-
```
|
|
32
|
+
```ts title="@/app/api/chat/route.ts"
|
|
43
33
|
import { openai } from "@ai-sdk/openai";
|
|
44
34
|
import { streamText, tool } from "ai";
|
|
45
35
|
import type { Message } from "ai";
|
|
@@ -49,35 +39,27 @@ export const maxDuration = 30;
|
|
|
49
39
|
|
|
50
40
|
export async function POST(req: Request) {
|
|
51
41
|
const { messages }: { messages: Message[] } = await req.json();
|
|
52
|
-
|
|
53
42
|
const result = streamText({
|
|
54
43
|
model: openai("gpt-4o"),
|
|
55
44
|
messages,
|
|
56
45
|
tools: {
|
|
57
46
|
get_current_weather: tool({
|
|
58
47
|
description: "Get the current weather",
|
|
59
|
-
parameters: z.object({
|
|
60
|
-
|
|
61
|
-
}),
|
|
62
|
-
execute: async ({ city }) => {
|
|
63
|
-
return `The weather in ${city} is sunny`;
|
|
64
|
-
},
|
|
48
|
+
parameters: z.object({ city: z.string() }),
|
|
49
|
+
execute: async ({ city }) => `The weather in ${city} is sunny`,
|
|
65
50
|
}),
|
|
66
51
|
},
|
|
67
52
|
});
|
|
68
|
-
|
|
69
53
|
return result.toDataStreamResponse();
|
|
70
54
|
}
|
|
71
55
|
```
|
|
72
56
|
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
</Step>
|
|
58
|
+
<Step>
|
|
75
59
|
|
|
76
|
-
###
|
|
60
|
+
### Frontend
|
|
77
61
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
62
|
+
```tsx title="@/app/page.tsx"
|
|
81
63
|
"use client";
|
|
82
64
|
|
|
83
65
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
@@ -86,7 +68,6 @@ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
|
86
68
|
|
|
87
69
|
export default function Home() {
|
|
88
70
|
const runtime = useChatRuntime();
|
|
89
|
-
|
|
90
71
|
return (
|
|
91
72
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
92
73
|
<div className="h-full">
|
|
@@ -97,33 +78,58 @@ export default function Home() {
|
|
|
97
78
|
}
|
|
98
79
|
```
|
|
99
80
|
|
|
81
|
+
</Step>
|
|
82
|
+
</Steps>
|
|
83
|
+
|
|
100
84
|
<Callout type="info">
|
|
101
|
-
|
|
85
|
+
On `@assistant-ui/react-ai-sdk` versions older than 0.11.3, use `useVercelUseChatRuntime` with `useChat` from `ai/react` instead:
|
|
102
86
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
```tsx
|
|
88
|
+
import { useChat } from "ai/react";
|
|
89
|
+
import { useVercelUseChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
106
90
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
const chat = useChat({ api: "/api/chat" });
|
|
92
|
+
const runtime = useVercelUseChatRuntime(chat);
|
|
93
|
+
```
|
|
110
94
|
</Callout>
|
|
111
95
|
|
|
112
|
-
|
|
113
|
-
</Steps>
|
|
114
|
-
|
|
115
|
-
## Key Differences from v6
|
|
96
|
+
## Differences from v6
|
|
116
97
|
|
|
117
98
|
| Feature | v5 | v6 |
|
|
118
|
-
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
|
125
|
-
|
|
|
99
|
+
| --- | --- | --- |
|
|
100
|
+
| `ai` package | `ai@^5` | `ai@^6` |
|
|
101
|
+
| `@assistant-ui/react-ai-sdk` | `@0.x` | `@latest` |
|
|
102
|
+
| `@ai-sdk/openai` | `^1` | `^3` |
|
|
103
|
+
| Message type | `Message` | `UIMessage` |
|
|
104
|
+
| `convertToModelMessages` | Sync | Async (`await`) |
|
|
105
|
+
| Tool schema | `parameters: z.object({...})` | `inputSchema: zodSchema(z.object({...}))` |
|
|
106
|
+
| Response | `toDataStreamResponse()` | `toUIMessageStreamResponse()` |
|
|
126
107
|
|
|
127
108
|
## Migration to v6
|
|
128
109
|
|
|
129
|
-
|
|
110
|
+
When you are ready to upgrade:
|
|
111
|
+
|
|
112
|
+
1. Update `ai` from `@^5` to `@^6`, and `@assistant-ui/react-ai-sdk` to the latest line.
|
|
113
|
+
2. Add `await` to `convertToModelMessages(...)` calls.
|
|
114
|
+
3. Convert tool schemas: `parameters: z.object({...})` → `inputSchema: zodSchema(z.object({...}))`.
|
|
115
|
+
4. Replace `toDataStreamResponse()` with `toUIMessageStreamResponse()`.
|
|
116
|
+
5. Switch the `Message` type to `UIMessage`.
|
|
117
|
+
|
|
118
|
+
AI SDK provides codemods at [ai-sdk.dev/docs/migration-guides/migration-guide-6-0](https://ai-sdk.dev/docs/migration-guides/migration-guide-6-0) that handle most of the package-side rewrites.
|
|
119
|
+
|
|
120
|
+
## Related
|
|
121
|
+
|
|
122
|
+
<Cards>
|
|
123
|
+
<Card
|
|
124
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
125
|
+
title="AI SDK v6"
|
|
126
|
+
description="Current integration; what new projects should target."
|
|
127
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
128
|
+
/>
|
|
129
|
+
<Card
|
|
130
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
131
|
+
title="AI SDK v4 (legacy)"
|
|
132
|
+
description="The earlier legacy version using react-data-stream."
|
|
133
|
+
href="/docs/runtimes/ai-sdk/v4-legacy"
|
|
134
|
+
/>
|
|
135
|
+
</Cards>
|