@assistant-ui/mcp-docs-server 0.1.5 → 0.1.7
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-ai-sdk-v5.md +54 -19
- package/.docs/organized/code-examples/with-cloud.md +17 -24
- package/.docs/organized/code-examples/with-external-store.md +6 -6
- package/.docs/organized/code-examples/with-ffmpeg.md +18 -21
- package/.docs/organized/code-examples/with-langgraph.md +7 -8
- package/.docs/organized/code-examples/with-parent-id-grouping.md +9 -6
- package/.docs/organized/code-examples/with-react-hook-form.md +16 -21
- package/.docs/raw/docs/api-reference/overview.mdx +1 -4
- package/.docs/raw/docs/getting-started.mdx +33 -33
- package/.docs/raw/docs/guides/Attachments.mdx +1 -102
- package/.docs/raw/docs/guides/Latex.mdx +42 -16
- package/.docs/raw/docs/guides/ToolUI.mdx +3 -3
- package/.docs/raw/docs/guides/Tools.mdx +101 -84
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +134 -55
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +182 -0
- package/.docs/raw/docs/runtimes/custom/local.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +9 -11
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +2 -2
- package/dist/{chunk-JS4PWCVA.js → chunk-L4K23SWI.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +6 -6
- package/.docs/organized/code-examples/local-ollama.md +0 -1135
- package/.docs/organized/code-examples/search-agent-for-e-commerce.md +0 -1721
- package/.docs/organized/code-examples/with-ai-sdk.md +0 -1081
- package/.docs/organized/code-examples/with-openai-assistants.md +0 -1175
- package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +0 -226
- package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +0 -195
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +0 -138
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-v5.mdx +0 -129
|
@@ -199,14 +199,12 @@ export default function RootLayout({
|
|
|
199
199
|
"use client";
|
|
200
200
|
|
|
201
201
|
import { Thread } from "@/components/assistant-ui/thread";
|
|
202
|
-
import { useChat } from "@ai-sdk/react";
|
|
203
202
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
204
|
-
import {
|
|
203
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
205
204
|
|
|
206
205
|
export default function Home() {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const runtime = useAISDKRuntime(chat);
|
|
206
|
+
// Using the new simplified useChatRuntime hook
|
|
207
|
+
const runtime = useChatRuntime();
|
|
210
208
|
|
|
211
209
|
return (
|
|
212
210
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
@@ -243,6 +241,7 @@ export default function Home() {
|
|
|
243
241
|
},
|
|
244
242
|
"iconLibrary": "lucide"
|
|
245
243
|
}
|
|
244
|
+
|
|
246
245
|
```
|
|
247
246
|
|
|
248
247
|
## components/assistant-ui/markdown-text.tsx
|
|
@@ -1035,34 +1034,34 @@ export default nextConfig;
|
|
|
1035
1034
|
"version": "0.0.0",
|
|
1036
1035
|
"type": "module",
|
|
1037
1036
|
"dependencies": {
|
|
1038
|
-
"@ai-sdk/openai": "^2.0.
|
|
1039
|
-
"@ai-sdk/react": "^2.0.
|
|
1037
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1038
|
+
"@ai-sdk/react": "^2.0.15",
|
|
1040
1039
|
"@assistant-ui/react": "workspace:^",
|
|
1041
1040
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1042
1041
|
"@assistant-ui/react-markdown": "workspace:^",
|
|
1043
1042
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1044
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1045
|
-
"@tailwindcss/postcss": "^4.1.
|
|
1046
|
-
"ai": "^5.0.
|
|
1043
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1044
|
+
"@tailwindcss/postcss": "^4.1.12",
|
|
1045
|
+
"ai": "^5.0.15",
|
|
1047
1046
|
"class-variance-authority": "^0.7.1",
|
|
1048
1047
|
"clsx": "^2.1.1",
|
|
1049
|
-
"lucide-react": "^0.
|
|
1050
|
-
"next": "15.4.
|
|
1048
|
+
"lucide-react": "^0.539.0",
|
|
1049
|
+
"next": "15.4.6",
|
|
1051
1050
|
"postcss": "^8.5.6",
|
|
1052
1051
|
"react": "19.1.1",
|
|
1053
1052
|
"react-dom": "19.1.1",
|
|
1054
1053
|
"remark-gfm": "^4.0.1",
|
|
1055
1054
|
"tailwind-merge": "^3.3.1",
|
|
1056
|
-
"tailwindcss": "^4.1.
|
|
1057
|
-
"zod": "^4.0.
|
|
1055
|
+
"tailwindcss": "^4.1.12",
|
|
1056
|
+
"zod": "^4.0.17"
|
|
1058
1057
|
},
|
|
1059
1058
|
"devDependencies": {
|
|
1060
1059
|
"@assistant-ui/x-buildutils": "workspace:*",
|
|
1061
|
-
"@types/node": "^24.
|
|
1062
|
-
"@types/react": "^19.1.
|
|
1060
|
+
"@types/node": "^24.3.0",
|
|
1061
|
+
"@types/react": "^19.1.10",
|
|
1063
1062
|
"@types/react-dom": "^19.1.7",
|
|
1064
1063
|
"eslint": "^9",
|
|
1065
|
-
"eslint-config-next": "15.4.
|
|
1064
|
+
"eslint-config-next": "15.4.6",
|
|
1066
1065
|
"tw-animate-css": "^1.3.6",
|
|
1067
1066
|
"typescript": "^5.9.2"
|
|
1068
1067
|
},
|
|
@@ -1086,21 +1085,25 @@ This example demonstrates how to use `@assistant-ui/react-ai-sdk-v5` with the Ve
|
|
|
1086
1085
|
## Getting Started
|
|
1087
1086
|
|
|
1088
1087
|
1. Install dependencies:
|
|
1088
|
+
|
|
1089
1089
|
```bash
|
|
1090
1090
|
npm install
|
|
1091
1091
|
```
|
|
1092
1092
|
|
|
1093
1093
|
2. Set up your environment variables:
|
|
1094
|
+
|
|
1094
1095
|
```bash
|
|
1095
1096
|
cp .env.example .env.local
|
|
1096
1097
|
```
|
|
1097
1098
|
|
|
1098
1099
|
Add your Anthropic API key to `.env.local`:
|
|
1100
|
+
|
|
1099
1101
|
```
|
|
1100
1102
|
ANTHROPIC_API_KEY=your-api-key-here
|
|
1101
1103
|
```
|
|
1102
1104
|
|
|
1103
1105
|
3. Run the development server:
|
|
1106
|
+
|
|
1104
1107
|
```bash
|
|
1105
1108
|
npm run dev
|
|
1106
1109
|
```
|
|
@@ -1110,13 +1113,45 @@ Open [http://localhost:3000](http://localhost:3000) to see the result.
|
|
|
1110
1113
|
## Key Features
|
|
1111
1114
|
|
|
1112
1115
|
- Uses the new AI SDK v5 with `@ai-sdk/react` and `@ai-sdk/anthropic`
|
|
1113
|
-
- Integrates with `@assistant-ui/react` using the
|
|
1116
|
+
- Integrates with `@assistant-ui/react` using the new `useChatRuntime` hook
|
|
1114
1117
|
- No RSC support (client-side only)
|
|
1115
|
-
-
|
|
1118
|
+
- Simplified integration with the `useChatRuntime` hook that wraps AI SDK v5's `useChat`
|
|
1119
|
+
- Automatically uses `AssistantChatTransport` to pass system messages and frontend tools to the backend
|
|
1120
|
+
|
|
1121
|
+
## Custom Transport Configuration
|
|
1122
|
+
|
|
1123
|
+
By default, `useChatRuntime` uses `AssistantChatTransport` which automatically forwards system messages and frontend tools to the backend.
|
|
1124
|
+
|
|
1125
|
+
### Custom API URL with Forwarding
|
|
1126
|
+
|
|
1127
|
+
When customizing the API URL, you must explicitly use `AssistantChatTransport` to keep system/tools forwarding:
|
|
1128
|
+
|
|
1129
|
+
```typescript
|
|
1130
|
+
import { AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
1131
|
+
|
|
1132
|
+
const runtime = useChatRuntime({
|
|
1133
|
+
transport: new AssistantChatTransport({
|
|
1134
|
+
api: "/my-custom-api/chat", // Custom URL with system/tools forwarding
|
|
1135
|
+
}),
|
|
1136
|
+
});
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
### Disable System/Tools Forwarding
|
|
1140
|
+
|
|
1141
|
+
To use the standard AI SDK transport without forwarding:
|
|
1142
|
+
|
|
1143
|
+
```typescript
|
|
1144
|
+
import { DefaultChatTransport } from "ai";
|
|
1145
|
+
|
|
1146
|
+
const runtime = useChatRuntime({
|
|
1147
|
+
transport: new DefaultChatTransport(), // No system/tools forwarding
|
|
1148
|
+
});
|
|
1149
|
+
```
|
|
1116
1150
|
|
|
1117
1151
|
## API Route
|
|
1118
1152
|
|
|
1119
1153
|
The API route at `/api/chat` uses the new `streamText` function from AI SDK v5 to handle chat completions.
|
|
1154
|
+
|
|
1120
1155
|
```
|
|
1121
1156
|
|
|
1122
1157
|
## tsconfig.json
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
|
-
import {
|
|
7
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
8
|
+
import { convertToModelMessages, streamText } from "ai";
|
|
8
9
|
|
|
9
|
-
export const runtime = "edge";
|
|
10
10
|
export const maxDuration = 30;
|
|
11
11
|
|
|
12
12
|
export async function POST(req: Request) {
|
|
@@ -14,22 +14,15 @@ export async function POST(req: Request) {
|
|
|
14
14
|
|
|
15
15
|
const result = streamText({
|
|
16
16
|
model: openai("gpt-4o"),
|
|
17
|
-
messages,
|
|
17
|
+
messages: convertToModelMessages(messages),
|
|
18
18
|
// forward system prompt and tools from the frontend
|
|
19
19
|
system,
|
|
20
|
-
tools:
|
|
21
|
-
tools
|
|
22
|
-
|
|
23
|
-
Object.entries<{ parameters: unknown }>(tools).map(([name, tool]) => [
|
|
24
|
-
name,
|
|
25
|
-
{
|
|
26
|
-
parameters: jsonSchema(tool.parameters!),
|
|
27
|
-
},
|
|
28
|
-
]),
|
|
29
|
-
),
|
|
20
|
+
tools: {
|
|
21
|
+
...frontendTools(tools),
|
|
22
|
+
},
|
|
30
23
|
});
|
|
31
24
|
|
|
32
|
-
return result.
|
|
25
|
+
return result.toUIMessageStreamResponse();
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
```
|
|
@@ -210,7 +203,7 @@ export default function RootLayout({
|
|
|
210
203
|
"use client";
|
|
211
204
|
|
|
212
205
|
import { AssistantCloud, AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
213
|
-
import { useChatRuntime } from "@assistant-ui/react-ai-sdk
|
|
206
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
214
207
|
|
|
215
208
|
const cloud = new AssistantCloud({
|
|
216
209
|
baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
|
|
@@ -224,7 +217,6 @@ export function MyRuntimeProvider({
|
|
|
224
217
|
}>) {
|
|
225
218
|
const runtime = useChatRuntime({
|
|
226
219
|
cloud,
|
|
227
|
-
api: "/api/chat",
|
|
228
220
|
});
|
|
229
221
|
|
|
230
222
|
return (
|
|
@@ -279,6 +271,7 @@ export default function Home() {
|
|
|
279
271
|
},
|
|
280
272
|
"iconLibrary": "lucide"
|
|
281
273
|
}
|
|
274
|
+
|
|
282
275
|
```
|
|
283
276
|
|
|
284
277
|
## components/assistant-ui/markdown-text.tsx
|
|
@@ -1096,19 +1089,19 @@ export default nextConfig;
|
|
|
1096
1089
|
"lint": "next lint"
|
|
1097
1090
|
},
|
|
1098
1091
|
"dependencies": {
|
|
1099
|
-
"@ai-sdk/openai": "^
|
|
1092
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1100
1093
|
"@assistant-ui/react": "workspace:*",
|
|
1101
|
-
"@assistant-ui/react-ai-sdk
|
|
1094
|
+
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1102
1095
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1103
1096
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1104
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1105
|
-
"ai": "^
|
|
1097
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1098
|
+
"ai": "^5.0.15",
|
|
1106
1099
|
"class-variance-authority": "^0.7.1",
|
|
1107
1100
|
"clsx": "^2.1.1",
|
|
1108
1101
|
"jsonwebtoken": "^9.0.2",
|
|
1109
|
-
"lucide-react": "^0.
|
|
1102
|
+
"lucide-react": "^0.539.0",
|
|
1110
1103
|
"nanoid": "5.1.5",
|
|
1111
|
-
"next": "15.4.
|
|
1104
|
+
"next": "15.4.6",
|
|
1112
1105
|
"react": "19.1.1",
|
|
1113
1106
|
"react-dom": "19.1.1",
|
|
1114
1107
|
"remark-gfm": "^4.0.1",
|
|
@@ -1122,9 +1115,9 @@ export default nextConfig;
|
|
|
1122
1115
|
"@types/react": "^19",
|
|
1123
1116
|
"@types/react-dom": "^19",
|
|
1124
1117
|
"eslint": "^9",
|
|
1125
|
-
"eslint-config-next": "15.4.
|
|
1118
|
+
"eslint-config-next": "15.4.6",
|
|
1126
1119
|
"postcss": "^8",
|
|
1127
|
-
"tailwindcss": "^4.1.
|
|
1120
|
+
"tailwindcss": "^4.1.12",
|
|
1128
1121
|
"typescript": "^5"
|
|
1129
1122
|
}
|
|
1130
1123
|
}
|
|
@@ -1001,15 +1001,15 @@ export default nextConfig;
|
|
|
1001
1001
|
"lint": "next lint"
|
|
1002
1002
|
},
|
|
1003
1003
|
"dependencies": {
|
|
1004
|
-
"@ai-sdk/openai": "^
|
|
1004
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1005
1005
|
"@assistant-ui/react": "workspace:*",
|
|
1006
1006
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1007
1007
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1008
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1008
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1009
1009
|
"class-variance-authority": "^0.7.1",
|
|
1010
1010
|
"clsx": "^2.1.1",
|
|
1011
|
-
"lucide-react": "^0.
|
|
1012
|
-
"next": "15.4.
|
|
1011
|
+
"lucide-react": "^0.539.0",
|
|
1012
|
+
"next": "15.4.6",
|
|
1013
1013
|
"react": "19.1.1",
|
|
1014
1014
|
"react-dom": "19.1.1",
|
|
1015
1015
|
"remark-gfm": "^4.0.1",
|
|
@@ -1022,9 +1022,9 @@ export default nextConfig;
|
|
|
1022
1022
|
"@types/react": "^19",
|
|
1023
1023
|
"@types/react-dom": "^19",
|
|
1024
1024
|
"eslint": "^9",
|
|
1025
|
-
"eslint-config-next": "15.4.
|
|
1025
|
+
"eslint-config-next": "15.4.6",
|
|
1026
1026
|
"postcss": "^8",
|
|
1027
|
-
"tailwindcss": "^4.1.
|
|
1027
|
+
"tailwindcss": "^4.1.12",
|
|
1028
1028
|
"typescript": "^5"
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
|
-
import { frontendTools } from "@assistant-ui/react-ai-sdk
|
|
8
|
-
import { streamText } from "ai";
|
|
7
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
8
|
+
import { convertToModelMessages, streamText } from "ai";
|
|
9
9
|
|
|
10
|
-
export const runtime = "edge";
|
|
11
10
|
export const maxDuration = 30;
|
|
12
11
|
|
|
13
12
|
export async function POST(req: Request) {
|
|
@@ -15,8 +14,7 @@ export async function POST(req: Request) {
|
|
|
15
14
|
|
|
16
15
|
const result = streamText({
|
|
17
16
|
model: openai("gpt-4o"),
|
|
18
|
-
messages,
|
|
19
|
-
toolCallStreaming: true,
|
|
17
|
+
messages: convertToModelMessages(messages),
|
|
20
18
|
system,
|
|
21
19
|
tools: {
|
|
22
20
|
...frontendTools(tools),
|
|
@@ -24,7 +22,7 @@ export async function POST(req: Request) {
|
|
|
24
22
|
},
|
|
25
23
|
});
|
|
26
24
|
|
|
27
|
-
return result.
|
|
25
|
+
return result.toUIMessageStreamResponse();
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
```
|
|
@@ -192,8 +190,9 @@ export default function RootLayout({
|
|
|
192
190
|
|
|
193
191
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
194
192
|
import { AttachmentAdapter } from "@assistant-ui/react";
|
|
195
|
-
import { useChatRuntime } from "@assistant-ui/react-ai-sdk
|
|
193
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
196
194
|
import { INTERNAL } from "@assistant-ui/react";
|
|
195
|
+
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
|
|
197
196
|
|
|
198
197
|
const { generateId } = INTERNAL;
|
|
199
198
|
|
|
@@ -232,8 +231,7 @@ export function MyRuntimeProvider({
|
|
|
232
231
|
children: React.ReactNode;
|
|
233
232
|
}>) {
|
|
234
233
|
const runtime = useChatRuntime({
|
|
235
|
-
|
|
236
|
-
maxSteps: 4,
|
|
234
|
+
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
237
235
|
adapters: {
|
|
238
236
|
attachments: attachmentAdapter,
|
|
239
237
|
},
|
|
@@ -1225,9 +1223,9 @@ export default nextConfig;
|
|
|
1225
1223
|
"lint": "next lint"
|
|
1226
1224
|
},
|
|
1227
1225
|
"dependencies": {
|
|
1228
|
-
"@ai-sdk/openai": "^
|
|
1226
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1229
1227
|
"@assistant-ui/react": "workspace:*",
|
|
1230
|
-
"@assistant-ui/react-ai-sdk
|
|
1228
|
+
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1231
1229
|
"@assistant-ui/react-hook-form": "workspace:*",
|
|
1232
1230
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1233
1231
|
"@ffmpeg/ffmpeg": "^0.12.15",
|
|
@@ -1237,24 +1235,23 @@ export default nextConfig;
|
|
|
1237
1235
|
"@radix-ui/react-icons": "^1.3.2",
|
|
1238
1236
|
"@radix-ui/react-label": "^2.1.7",
|
|
1239
1237
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1240
|
-
"@radix-ui/react-tabs": "^1.1.
|
|
1241
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1238
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
1239
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1242
1240
|
"@react-hook/media-query": "^1.1.1",
|
|
1243
|
-
"ai": "^
|
|
1241
|
+
"ai": "^5.0.15",
|
|
1244
1242
|
"class-variance-authority": "^0.7.1",
|
|
1245
1243
|
"clsx": "^2.1.1",
|
|
1246
1244
|
"json-schema-to-zod": "^2.6.1",
|
|
1247
|
-
"lucide-react": "^0.
|
|
1248
|
-
"next": "15.4.
|
|
1245
|
+
"lucide-react": "^0.539.0",
|
|
1246
|
+
"next": "15.4.6",
|
|
1249
1247
|
"react": "19.1.1",
|
|
1250
1248
|
"react-dom": "19.1.1",
|
|
1251
|
-
"react-hook-form": "^7.
|
|
1249
|
+
"react-hook-form": "^7.62.0",
|
|
1252
1250
|
"react-resizable-panels": "^3.0.4",
|
|
1253
1251
|
"remark-gfm": "^4.0.1",
|
|
1254
1252
|
"tailwind-merge": "^3.3.1",
|
|
1255
1253
|
"tw-animate-css": "^1.3.6",
|
|
1256
|
-
"zod": "^4.0.
|
|
1257
|
-
"zod-to-json-schema": "^3.24.6",
|
|
1254
|
+
"zod": "^4.0.17",
|
|
1258
1255
|
"zustand": "^5.0.7"
|
|
1259
1256
|
},
|
|
1260
1257
|
"devDependencies": {
|
|
@@ -1263,9 +1260,9 @@ export default nextConfig;
|
|
|
1263
1260
|
"@types/react": "^19",
|
|
1264
1261
|
"@types/react-dom": "^19",
|
|
1265
1262
|
"eslint": "^9",
|
|
1266
|
-
"eslint-config-next": "15.4.
|
|
1263
|
+
"eslint-config-next": "15.4.6",
|
|
1267
1264
|
"postcss": "^8",
|
|
1268
|
-
"tailwindcss": "^4.1.
|
|
1265
|
+
"tailwindcss": "^4.1.12",
|
|
1269
1266
|
"typescript": "^5.9.2"
|
|
1270
1267
|
}
|
|
1271
1268
|
}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { NextRequest, NextResponse } from "next/server";
|
|
7
7
|
|
|
8
|
-
export const runtime = "edge";
|
|
9
|
-
|
|
10
8
|
function getCorsHeaders() {
|
|
11
9
|
return {
|
|
12
10
|
"Access-Control-Allow-Origin": "*",
|
|
@@ -1727,16 +1725,16 @@ export default nextConfig;
|
|
|
1727
1725
|
"@assistant-ui/react": "workspace:*",
|
|
1728
1726
|
"@assistant-ui/react-langgraph": "workspace:*",
|
|
1729
1727
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1730
|
-
"@langchain/langgraph-sdk": "^0.0.
|
|
1728
|
+
"@langchain/langgraph-sdk": "^0.0.107",
|
|
1731
1729
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1732
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1730
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1733
1731
|
"class-variance-authority": "^0.7.1",
|
|
1734
1732
|
"clsx": "^2.1.1",
|
|
1735
1733
|
"js-cookie": "^3.0.5",
|
|
1736
1734
|
"jsonwebtoken": "^9.0.2",
|
|
1737
|
-
"lucide-react": "^0.
|
|
1735
|
+
"lucide-react": "^0.539.0",
|
|
1738
1736
|
"nanoid": "5.1.5",
|
|
1739
|
-
"next": "15.4.
|
|
1737
|
+
"next": "15.4.6",
|
|
1740
1738
|
"react": "19.1.1",
|
|
1741
1739
|
"react-dom": "19.1.1",
|
|
1742
1740
|
"remark-gfm": "^4.0.1",
|
|
@@ -1751,9 +1749,9 @@ export default nextConfig;
|
|
|
1751
1749
|
"@types/react": "^19",
|
|
1752
1750
|
"@types/react-dom": "^19",
|
|
1753
1751
|
"eslint": "^9",
|
|
1754
|
-
"eslint-config-next": "15.4.
|
|
1752
|
+
"eslint-config-next": "15.4.6",
|
|
1755
1753
|
"postcss": "^8",
|
|
1756
|
-
"tailwindcss": "^4.1.
|
|
1754
|
+
"tailwindcss": "^4.1.12",
|
|
1757
1755
|
"typescript": "^5.9.2"
|
|
1758
1756
|
}
|
|
1759
1757
|
}
|
|
@@ -1784,6 +1782,7 @@ To run the example, run the following commands:
|
|
|
1784
1782
|
npm install
|
|
1785
1783
|
npm run dev
|
|
1786
1784
|
```
|
|
1785
|
+
|
|
1787
1786
|
```
|
|
1788
1787
|
|
|
1789
1788
|
## tsconfig.json
|
|
@@ -1247,15 +1247,15 @@ export default nextConfig;
|
|
|
1247
1247
|
"lint": "next lint"
|
|
1248
1248
|
},
|
|
1249
1249
|
"dependencies": {
|
|
1250
|
-
"@ai-sdk/openai": "^
|
|
1250
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1251
1251
|
"@assistant-ui/react": "workspace:*",
|
|
1252
1252
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1253
1253
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1254
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1254
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1255
1255
|
"class-variance-authority": "^0.7.1",
|
|
1256
1256
|
"clsx": "^2.1.1",
|
|
1257
|
-
"lucide-react": "^0.
|
|
1258
|
-
"next": "15.4.
|
|
1257
|
+
"lucide-react": "^0.539.0",
|
|
1258
|
+
"next": "15.4.6",
|
|
1259
1259
|
"react": "19.1.1",
|
|
1260
1260
|
"react-dom": "19.1.1",
|
|
1261
1261
|
"remark-gfm": "^4.0.1",
|
|
@@ -1268,9 +1268,9 @@ export default nextConfig;
|
|
|
1268
1268
|
"@types/react": "^19",
|
|
1269
1269
|
"@types/react-dom": "^19",
|
|
1270
1270
|
"eslint": "^9",
|
|
1271
|
-
"eslint-config-next": "15.4.
|
|
1271
|
+
"eslint-config-next": "15.4.6",
|
|
1272
1272
|
"postcss": "^8",
|
|
1273
|
-
"tailwindcss": "^4.1.
|
|
1273
|
+
"tailwindcss": "^4.1.12",
|
|
1274
1274
|
"typescript": "^5"
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
@@ -1297,6 +1297,7 @@ This example demonstrates how to use the parent ID feature in assistant-ui to gr
|
|
|
1297
1297
|
## How it works
|
|
1298
1298
|
|
|
1299
1299
|
1. **Message Structure**: The example uses the external store runtime with predefined messages that include parts with `parentId` fields:
|
|
1300
|
+
|
|
1300
1301
|
```typescript
|
|
1301
1302
|
{
|
|
1302
1303
|
type: "text",
|
|
@@ -1335,10 +1336,12 @@ Open [http://localhost:3000](http://localhost:3000) to see the example.
|
|
|
1335
1336
|
## Use Cases
|
|
1336
1337
|
|
|
1337
1338
|
This pattern is useful for:
|
|
1339
|
+
|
|
1338
1340
|
- Grouping research sources with their related findings
|
|
1339
1341
|
- Organizing multi-step tool executions
|
|
1340
1342
|
- Creating hierarchical content structures
|
|
1341
1343
|
- Showing related content in collapsible sections
|
|
1344
|
+
|
|
1342
1345
|
```
|
|
1343
1346
|
|
|
1344
1347
|
## tsconfig.json
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
|
-
import { frontendTools } from "@assistant-ui/react-ai-sdk
|
|
8
|
-
import { streamText } from "ai";
|
|
7
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
8
|
+
import { convertToModelMessages, streamText } from "ai";
|
|
9
9
|
|
|
10
|
-
export const runtime = "edge";
|
|
11
10
|
export const maxDuration = 30;
|
|
12
11
|
|
|
13
12
|
export async function POST(req: Request) {
|
|
@@ -15,15 +14,14 @@ export async function POST(req: Request) {
|
|
|
15
14
|
|
|
16
15
|
const result = streamText({
|
|
17
16
|
model: openai("gpt-4o"),
|
|
18
|
-
messages,
|
|
19
|
-
toolCallStreaming: true,
|
|
17
|
+
messages: convertToModelMessages(messages),
|
|
20
18
|
system,
|
|
21
19
|
tools: {
|
|
22
20
|
...frontendTools(tools),
|
|
23
21
|
},
|
|
24
22
|
});
|
|
25
23
|
|
|
26
|
-
return result.
|
|
24
|
+
return result.toUIMessageStreamResponse();
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
```
|
|
@@ -189,16 +187,14 @@ export default function RootLayout({
|
|
|
189
187
|
"use client";
|
|
190
188
|
|
|
191
189
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
192
|
-
import { useChatRuntime } from "@assistant-ui/react-ai-sdk
|
|
190
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
193
191
|
|
|
194
192
|
export function MyRuntimeProvider({
|
|
195
193
|
children,
|
|
196
194
|
}: Readonly<{
|
|
197
195
|
children: React.ReactNode;
|
|
198
196
|
}>) {
|
|
199
|
-
const runtime = useChatRuntime(
|
|
200
|
-
api: "/api/chat",
|
|
201
|
-
});
|
|
197
|
+
const runtime = useChatRuntime();
|
|
202
198
|
|
|
203
199
|
return (
|
|
204
200
|
<AssistantRuntimeProvider runtime={runtime}>
|
|
@@ -1649,7 +1645,7 @@ export default nextConfig;
|
|
|
1649
1645
|
"lint": "next lint"
|
|
1650
1646
|
},
|
|
1651
1647
|
"dependencies": {
|
|
1652
|
-
"@ai-sdk/openai": "^
|
|
1648
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1653
1649
|
"@assistant-ui/react": "workspace:*",
|
|
1654
1650
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1655
1651
|
"@assistant-ui/react-hook-form": "workspace:*",
|
|
@@ -1659,24 +1655,23 @@ export default nextConfig;
|
|
|
1659
1655
|
"@radix-ui/react-icons": "^1.3.2",
|
|
1660
1656
|
"@radix-ui/react-label": "^2.1.7",
|
|
1661
1657
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1662
|
-
"@radix-ui/react-tabs": "^1.1.
|
|
1663
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1658
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
1659
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1664
1660
|
"@react-hook/media-query": "^1.1.1",
|
|
1665
|
-
"ai": "^
|
|
1661
|
+
"ai": "^5.0.15",
|
|
1666
1662
|
"class-variance-authority": "^0.7.1",
|
|
1667
1663
|
"clsx": "^2.1.1",
|
|
1668
1664
|
"json-schema-to-zod": "^2.6.1",
|
|
1669
|
-
"lucide-react": "^0.
|
|
1670
|
-
"next": "15.4.
|
|
1665
|
+
"lucide-react": "^0.539.0",
|
|
1666
|
+
"next": "15.4.6",
|
|
1671
1667
|
"react": "19.1.1",
|
|
1672
1668
|
"react-dom": "19.1.1",
|
|
1673
|
-
"react-hook-form": "^7.
|
|
1669
|
+
"react-hook-form": "^7.62.0",
|
|
1674
1670
|
"react-resizable-panels": "^3.0.4",
|
|
1675
1671
|
"remark-gfm": "^4.0.1",
|
|
1676
1672
|
"tailwind-merge": "^3.3.1",
|
|
1677
1673
|
"tw-animate-css": "^1.3.6",
|
|
1678
|
-
"zod": "^4.0.
|
|
1679
|
-
"zod-to-json-schema": "^3.24.6",
|
|
1674
|
+
"zod": "^4.0.17",
|
|
1680
1675
|
"zustand": "^5.0.7"
|
|
1681
1676
|
},
|
|
1682
1677
|
"devDependencies": {
|
|
@@ -1685,9 +1680,9 @@ export default nextConfig;
|
|
|
1685
1680
|
"@types/react": "^19",
|
|
1686
1681
|
"@types/react-dom": "^19",
|
|
1687
1682
|
"eslint": "^9",
|
|
1688
|
-
"eslint-config-next": "15.4.
|
|
1683
|
+
"eslint-config-next": "15.4.6",
|
|
1689
1684
|
"postcss": "^8",
|
|
1690
|
-
"tailwindcss": "^4.1.
|
|
1685
|
+
"tailwindcss": "^4.1.12",
|
|
1691
1686
|
"typescript": "^5.9.2"
|
|
1692
1687
|
}
|
|
1693
1688
|
}
|
|
@@ -29,10 +29,7 @@ export const contextColors = {
|
|
|
29
29
|
### AI SDK
|
|
30
30
|
|
|
31
31
|
- [`useChatRuntime`](#use-chat-runtime)
|
|
32
|
-
- [`
|
|
33
|
-
- [`useVercelUseAssistantRuntime`](#use-vercel-use-assistant-runtime)
|
|
34
|
-
- [`useVercelRSCRuntime`](#use-vercel-rsc-runtime)
|
|
35
|
-
- [`useDangerousInBrowserRuntime`](#use-dangerous-in-browser-runtime)
|
|
32
|
+
- [`useAISDKRuntime`](#use-aisdk-runtime)
|
|
36
33
|
|
|
37
34
|
### LangGraph
|
|
38
35
|
|