@assistant-ui/mcp-docs-server 0.1.24 → 0.1.25
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 +4 -2
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +5 -6
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +27 -15
- package/.docs/organized/code-examples/with-artifacts.md +4 -4
- package/.docs/organized/code-examples/with-assistant-transport.md +2 -2
- package/.docs/organized/code-examples/with-chain-of-thought.md +33 -25
- package/.docs/organized/code-examples/with-cloud-standalone.md +9 -6
- package/.docs/organized/code-examples/with-cloud.md +4 -4
- package/.docs/organized/code-examples/with-custom-thread-list.md +6 -6
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
- package/.docs/organized/code-examples/with-expo.md +565 -514
- package/.docs/organized/code-examples/with-external-store.md +2 -2
- package/.docs/organized/code-examples/with-ffmpeg.md +4 -4
- package/.docs/organized/code-examples/with-google-adk.md +353 -0
- package/.docs/organized/code-examples/with-heat-graph.md +304 -0
- package/.docs/organized/code-examples/with-langgraph.md +24 -22
- package/.docs/organized/code-examples/with-parent-id-grouping.md +3 -3
- package/.docs/organized/code-examples/with-react-hook-form.md +4 -4
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +5 -5
- package/.docs/organized/code-examples/with-store.md +28 -17
- package/.docs/organized/code-examples/with-tanstack.md +7 -7
- package/.docs/organized/code-examples/with-tap-runtime.md +5 -3
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +227 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +14 -9
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
- package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +9 -11
- package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
- package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +2 -1
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +173 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
- package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
- package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
- package/.docs/raw/docs/(docs)/index.mdx +3 -3
- package/.docs/raw/docs/(docs)/installation.mdx +69 -46
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +99 -45
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
- package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
- package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
- package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +84 -6
- package/.docs/raw/docs/cloud/ai-sdk.mdx +14 -4
- package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
- package/.docs/raw/docs/ink/adapters.mdx +41 -0
- package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
- package/.docs/raw/docs/ink/hooks.mdx +448 -0
- package/.docs/raw/docs/ink/index.mdx +239 -0
- package/.docs/raw/docs/ink/migration.mdx +140 -0
- package/.docs/raw/docs/ink/primitives.mdx +699 -0
- package/.docs/raw/docs/react-native/adapters.mdx +63 -87
- package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
- package/.docs/raw/docs/react-native/hooks.mdx +214 -232
- package/.docs/raw/docs/react-native/index.mdx +118 -159
- package/.docs/raw/docs/react-native/migration.mdx +144 -0
- package/.docs/raw/docs/react-native/primitives.mdx +431 -302
- package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
- package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
- package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
- package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
- package/.docs/raw/docs/ui/file.mdx +5 -4
- package/.docs/raw/docs/ui/image.mdx +5 -4
- package/.docs/raw/docs/ui/markdown.mdx +3 -1
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
- package/.docs/raw/docs/ui/quote.mdx +210 -0
- package/.docs/raw/docs/ui/reasoning.mdx +12 -11
- package/.docs/raw/docs/ui/sources.mdx +88 -17
- package/.docs/raw/docs/ui/streamdown.mdx +16 -7
- package/.docs/raw/docs/ui/thread-list.mdx +11 -13
- package/.docs/raw/docs/ui/thread.mdx +28 -33
- package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
- package/.docs/raw/docs/ui/tool-group.mdx +9 -8
- package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
- package/package.json +4 -4
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
- package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
- /package/.docs/raw/docs/cloud/{overview.mdx → index.mdx} +0 -0
|
@@ -57,7 +57,7 @@ NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID=your_graph_id
|
|
|
57
57
|
subset of endpoints that you need and perform authorization checks.
|
|
58
58
|
</Callout>
|
|
59
59
|
|
|
60
|
-
```tsx twoslash title="@/
|
|
60
|
+
```tsx twoslash title="@/app/api/[...path]/route.ts"
|
|
61
61
|
import { NextRequest, NextResponse } from "next/server";
|
|
62
62
|
|
|
63
63
|
function getCorsHeaders() {
|
|
@@ -95,16 +95,29 @@ async function handleRequest(req: NextRequest, method: string) {
|
|
|
95
95
|
options,
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
+
const headers = new Headers(res.headers);
|
|
99
|
+
headers.delete("content-encoding");
|
|
100
|
+
headers.delete("content-length");
|
|
101
|
+
headers.delete("transfer-encoding");
|
|
102
|
+
const corsHeaders = getCorsHeaders();
|
|
103
|
+
for (const [key, value] of Object.entries(corsHeaders)) {
|
|
104
|
+
headers.set(key, value);
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
return new NextResponse(res.body, {
|
|
99
108
|
status: res.status,
|
|
100
109
|
statusText: res.statusText,
|
|
101
|
-
headers
|
|
102
|
-
...res.headers,
|
|
103
|
-
...getCorsHeaders(),
|
|
104
|
-
},
|
|
110
|
+
headers,
|
|
105
111
|
});
|
|
106
|
-
} catch (e:
|
|
107
|
-
|
|
112
|
+
} catch (e: unknown) {
|
|
113
|
+
if (e instanceof Error) {
|
|
114
|
+
const typedError = e as Error & { status?: number };
|
|
115
|
+
return NextResponse.json(
|
|
116
|
+
{ error: typedError.message },
|
|
117
|
+
{ status: typedError.status ?? 500 },
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return NextResponse.json({ error: "Unknown error" }, { status: 500 });
|
|
108
121
|
}
|
|
109
122
|
}
|
|
110
123
|
|
|
@@ -113,16 +126,11 @@ export const POST = (req: NextRequest) => handleRequest(req, "POST");
|
|
|
113
126
|
export const PUT = (req: NextRequest) => handleRequest(req, "PUT");
|
|
114
127
|
export const PATCH = (req: NextRequest) => handleRequest(req, "PATCH");
|
|
115
128
|
export const DELETE = (req: NextRequest) => handleRequest(req, "DELETE");
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
export const OPTIONS = () => {
|
|
119
|
-
return new NextResponse(null, {
|
|
129
|
+
export const OPTIONS = () =>
|
|
130
|
+
new NextResponse(null, {
|
|
120
131
|
status: 204,
|
|
121
|
-
headers:
|
|
122
|
-
...getCorsHeaders(),
|
|
123
|
-
},
|
|
132
|
+
headers: getCorsHeaders(),
|
|
124
133
|
});
|
|
125
|
-
};
|
|
126
134
|
```
|
|
127
135
|
|
|
128
136
|
</Step>
|
|
@@ -134,8 +142,8 @@ export const OPTIONS = () => {
|
|
|
134
142
|
// @filename: /lib/chatApi.ts
|
|
135
143
|
|
|
136
144
|
// ---cut---
|
|
137
|
-
import { Client } from "@langchain/langgraph-sdk";
|
|
138
|
-
import { LangChainMessage,
|
|
145
|
+
import { Client, type ThreadState } from "@langchain/langgraph-sdk";
|
|
146
|
+
import { LangChainMessage, LangGraphCommand } from "@assistant-ui/react-langgraph";
|
|
139
147
|
|
|
140
148
|
const createClient = () => {
|
|
141
149
|
const apiUrl = process.env["NEXT_PUBLIC_LANGGRAPH_API_URL"] || "/api";
|
|
@@ -158,21 +166,19 @@ export const getThreadState = async (
|
|
|
158
166
|
|
|
159
167
|
export const sendMessage = async (params: {
|
|
160
168
|
threadId: string;
|
|
161
|
-
messages
|
|
162
|
-
|
|
169
|
+
messages?: LangChainMessage[];
|
|
170
|
+
command?: LangGraphCommand;
|
|
163
171
|
}) => {
|
|
164
172
|
const client = createClient();
|
|
165
|
-
const { checkpointId, ...restConfig } = params.config ?? {};
|
|
166
173
|
return client.runs.stream(
|
|
167
174
|
params.threadId,
|
|
168
175
|
process.env["NEXT_PUBLIC_LANGGRAPH_ASSISTANT_ID"]!,
|
|
169
176
|
{
|
|
170
|
-
input: params.messages
|
|
177
|
+
input: params.messages?.length
|
|
171
178
|
? { messages: params.messages }
|
|
172
179
|
: null,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
...restConfig,
|
|
180
|
+
command: params.command,
|
|
181
|
+
streamMode: ["messages", "updates"],
|
|
176
182
|
},
|
|
177
183
|
);
|
|
178
184
|
};
|
|
@@ -198,14 +204,17 @@ import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
|
198
204
|
|
|
199
205
|
export function MyAssistant() {
|
|
200
206
|
const runtime = useLangGraphRuntime({
|
|
201
|
-
stream: async (messages, { initialize,
|
|
207
|
+
stream: async function* (messages, { initialize, command }) {
|
|
202
208
|
const { externalId } = await initialize();
|
|
203
209
|
if (!externalId) throw new Error("Thread not found");
|
|
204
|
-
|
|
210
|
+
|
|
211
|
+
const generator = await sendMessage({
|
|
205
212
|
threadId: externalId,
|
|
206
213
|
messages,
|
|
207
|
-
|
|
214
|
+
command,
|
|
208
215
|
});
|
|
216
|
+
|
|
217
|
+
yield* generator;
|
|
209
218
|
},
|
|
210
219
|
create: async () => {
|
|
211
220
|
const { thread_id } = await createThread();
|
|
@@ -321,6 +330,7 @@ const runtime = useLangGraphRuntime({
|
|
|
321
330
|
// Fired when an "updates" event is received
|
|
322
331
|
},
|
|
323
332
|
onMetadata: (metadata) => { /* thread metadata */ },
|
|
333
|
+
onInfo: (info) => { /* informational messages */ },
|
|
324
334
|
onError: (error) => { /* stream errors */ },
|
|
325
335
|
onCustomEvent: (type, data) => { /* custom events */ },
|
|
326
336
|
},
|
|
@@ -378,6 +388,7 @@ For persistent thread history across sessions, integrate with assistant-cloud:
|
|
|
378
388
|
const runtime = useLangGraphRuntime({
|
|
379
389
|
cloud: new AssistantCloud({
|
|
380
390
|
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL,
|
|
391
|
+
anonymous: true,
|
|
381
392
|
}),
|
|
382
393
|
// ... stream, create, load functions
|
|
383
394
|
});
|
|
@@ -20,22 +20,32 @@ import { File, Folder, Files } from "fumadocs-ui/components/files";
|
|
|
20
20
|
<Folder name="my-app" defaultOpen>
|
|
21
21
|
<Folder name="app" defaultOpen>
|
|
22
22
|
<Folder name="api" defaultOpen>
|
|
23
|
-
<Folder name="[...
|
|
23
|
+
<Folder name="[..._path]" defaultOpen>
|
|
24
24
|
<File name="route.ts" />
|
|
25
25
|
</Folder>
|
|
26
26
|
</Folder>
|
|
27
|
+
<File name="assistant.tsx" />
|
|
27
28
|
<File name="globals.css" />
|
|
28
29
|
<File name="layout.tsx" />
|
|
29
|
-
<File name="MyRuntimeProvider.tsx" />
|
|
30
30
|
<File name="page.tsx" />
|
|
31
31
|
</Folder>
|
|
32
|
+
<Folder name="components" defaultOpen>
|
|
33
|
+
<Folder name="assistant-ui">
|
|
34
|
+
<File name="thread.tsx" />
|
|
35
|
+
</Folder>
|
|
36
|
+
<Folder name="ui">
|
|
37
|
+
<File name="button.tsx" />
|
|
38
|
+
<File name="tooltip.tsx" />
|
|
39
|
+
</Folder>
|
|
40
|
+
</Folder>
|
|
32
41
|
<Folder name="lib">
|
|
33
42
|
<File name="chatApi.ts" />
|
|
43
|
+
<File name="utils.ts" />
|
|
34
44
|
</Folder>
|
|
45
|
+
<File name="components.json" />
|
|
35
46
|
<File name="next.config.ts" />
|
|
36
47
|
<File name="package.json" />
|
|
37
48
|
<File name="postcss.config.mjs" />
|
|
38
|
-
<File name="tailwind.config.ts" />
|
|
39
49
|
<File name="tsconfig.json" />
|
|
40
50
|
</Folder>
|
|
41
51
|
</Files>
|
|
@@ -95,26 +105,11 @@ import starter from "./images/conversation-starters.png";
|
|
|
95
105
|
className="mx-auto rounded-lg border shadow"
|
|
96
106
|
/>
|
|
97
107
|
|
|
98
|
-
```tsx title="@/app/page.tsx"
|
|
108
|
+
```tsx title="@/app/page.tsx"
|
|
99
109
|
export default function Home() {
|
|
100
110
|
return (
|
|
101
111
|
<div className="flex h-full flex-col">
|
|
102
|
-
<Thread
|
|
103
|
-
welcome={{
|
|
104
|
-
suggestions: [
|
|
105
|
-
{
|
|
106
|
-
prompt: "How much revenue did Apple make last year?",
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
prompt: "Is McDonald's profitable?",
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
prompt: "What's the current stock price of Tesla?",
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
}}
|
|
116
|
-
assistantMessage={{ components: { Text: MarkdownText } }}
|
|
117
|
-
/>
|
|
112
|
+
<Thread />
|
|
118
113
|
</div>
|
|
119
114
|
);
|
|
120
115
|
}
|
|
@@ -98,10 +98,8 @@ import { PriceSnapshotTool } from "@/components/tools/price-snapshot/PriceSnapsh
|
|
|
98
98
|
export default function Home() {
|
|
99
99
|
return (
|
|
100
100
|
<div className="flex h-full flex-col">
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
tools={[PriceSnapshotTool]}
|
|
104
|
-
/>
|
|
101
|
+
<PriceSnapshotTool />
|
|
102
|
+
<Thread />
|
|
105
103
|
</div>
|
|
106
104
|
);
|
|
107
105
|
}
|
|
@@ -321,17 +319,15 @@ export const ToolFallback: ToolCallMessagePartComponent = ({
|
|
|
321
319
|
|
|
322
320
|
### Bind fallback UI
|
|
323
321
|
|
|
324
|
-
```tsx title="@/app/page.tsx"
|
|
325
|
-
import { ToolFallback } from "@/components/tools/ToolFallback";
|
|
326
|
-
|
|
322
|
+
```tsx title="@/app/page.tsx"
|
|
327
323
|
export default function Home() {
|
|
328
324
|
return (
|
|
329
325
|
<div className="flex h-full flex-col">
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
assistantMessage={{ components: { Text: MarkdownText, ToolFallback } }}
|
|
333
|
-
/>
|
|
326
|
+
<PriceSnapshotTool />
|
|
327
|
+
<Thread />
|
|
334
328
|
</div>
|
|
335
329
|
);
|
|
336
330
|
}
|
|
337
331
|
```
|
|
332
|
+
|
|
333
|
+
The `Thread` component from `@assistant-ui/ui` already includes a built-in `ToolFallback` and `MarkdownText`, so no additional configuration is needed.
|
|
@@ -89,18 +89,17 @@ Then we use `makeAssistantToolUI` to define the tool UI:
|
|
|
89
89
|
import { TransactionConfirmationPending } from "./transaction-confirmation-pending";
|
|
90
90
|
import { TransactionConfirmationFinal } from "./transaction-confirmation-final";
|
|
91
91
|
import { makeAssistantToolUI } from "@assistant-ui/react";
|
|
92
|
-
import { updateState } from "@/lib/chatApi";
|
|
93
92
|
|
|
94
93
|
export const PurchaseStockTool = makeAssistantToolUI<PurchaseStockArgs, string>(
|
|
95
94
|
{
|
|
96
95
|
toolName: "purchase_stock",
|
|
97
96
|
render: function PurchaseStockUI({ args, result, status, addResult }) {
|
|
98
97
|
const handleReject = async () => {
|
|
99
|
-
addResult({ approve: false });
|
|
98
|
+
addResult(JSON.stringify({ approve: false }));
|
|
100
99
|
};
|
|
101
100
|
|
|
102
101
|
const handleConfirm = async () => {
|
|
103
|
-
addResult({ approve: true });
|
|
102
|
+
addResult(JSON.stringify({ approve: true }));
|
|
104
103
|
};
|
|
105
104
|
|
|
106
105
|
return (
|
|
@@ -215,10 +214,9 @@ import { PurchaseStockTool } from "@/components/tools/purchase-stock/PurchaseSto
|
|
|
215
214
|
export default function Home() {
|
|
216
215
|
return (
|
|
217
216
|
<div className="flex h-full flex-col">
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
/>
|
|
217
|
+
<PriceSnapshotTool />
|
|
218
|
+
<PurchaseStockTool />
|
|
219
|
+
<Thread />
|
|
222
220
|
</div>
|
|
223
221
|
);
|
|
224
222
|
}
|
|
@@ -308,7 +306,6 @@ We will import the new `<TransactionConfirmationFinal />` component and use it i
|
|
|
308
306
|
import { TransactionConfirmationPending } from "./transaction-confirmation-pending";
|
|
309
307
|
import { TransactionConfirmationFinal } from "./transaction-confirmation-final";
|
|
310
308
|
import { makeAssistantToolUI } from "@assistant-ui/react";
|
|
311
|
-
import { updateState } from "@/lib/chatApi";
|
|
312
309
|
|
|
313
310
|
type PurchaseStockArgs = {
|
|
314
311
|
ticker: string;
|
|
@@ -335,11 +332,11 @@ export const PurchaseStockTool = makeAssistantToolUI<PurchaseStockArgs, string>(
|
|
|
335
332
|
}
|
|
336
333
|
|
|
337
334
|
const handleReject = () => {
|
|
338
|
-
addResult({
|
|
335
|
+
addResult(JSON.stringify({ approve: false }));
|
|
339
336
|
};
|
|
340
337
|
|
|
341
338
|
const handleConfirm = async () => {
|
|
342
|
-
addResult({ approve: true });
|
|
339
|
+
addResult(JSON.stringify({ approve: true }));
|
|
343
340
|
};
|
|
344
341
|
|
|
345
342
|
return (
|
|
@@ -372,7 +369,7 @@ export const PurchaseStockTool = makeAssistantToolUI<PurchaseStockArgs, string>(
|
|
|
372
369
|
|
|
373
370
|
### Try it out!
|
|
374
371
|
|
|
375
|
-
Confirm the purchase of shares. You should see the approval
|
|
372
|
+
Confirm the purchase of shares. You should see the approval confirmation UI appear.
|
|
376
373
|
|
|
377
374
|
import purchase2 from "./images/acme-confirmed.png";
|
|
378
375
|
|
|
@@ -4,7 +4,7 @@ description: Connect to LangServe endpoints via Vercel AI SDK integration.
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<Callout type="warning">
|
|
7
|
-
This integration has not been tested with AI SDK
|
|
7
|
+
This integration has not been tested with AI SDK v6.
|
|
8
8
|
</Callout>
|
|
9
9
|
|
|
10
10
|
## Overview
|
|
@@ -67,7 +67,6 @@ export async function POST(req: Request) {
|
|
|
67
67
|
// ---cut---
|
|
68
68
|
"use client";
|
|
69
69
|
|
|
70
|
-
import { useChat } from "@ai-sdk/react";
|
|
71
70
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
72
71
|
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
73
72
|
|
|
@@ -104,11 +103,11 @@ export default function RootLayout({
|
|
|
104
103
|
children: ReactNode;
|
|
105
104
|
}>) {
|
|
106
105
|
return (
|
|
107
|
-
<
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
</
|
|
111
|
-
</
|
|
106
|
+
<html lang="en">
|
|
107
|
+
<body>
|
|
108
|
+
<MyRuntimeProvider>{children}</MyRuntimeProvider>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
112
111
|
);
|
|
113
112
|
}
|
|
114
113
|
```
|
|
@@ -14,6 +14,8 @@ graph TD
|
|
|
14
14
|
B -->|LangGraph| D[Use LangGraph Runtime]
|
|
15
15
|
B -->|LangServe| E[Use LangServe Runtime]
|
|
16
16
|
B -->|Mastra| F[Use Mastra Runtime]
|
|
17
|
+
B -->|AG-UI Protocol| J[Use AG-UI Runtime]
|
|
18
|
+
B -->|A2A Protocol| K[Use A2A Runtime]
|
|
17
19
|
B -->|Custom Backend| G{State Management?}
|
|
18
20
|
G -->|Let assistant-ui handle it| H[Use LocalRuntime]
|
|
19
21
|
G -->|I'll manage it myself| I[Use ExternalStoreRuntime]
|
|
@@ -43,8 +45,8 @@ For popular frameworks, we provide ready-to-use integrations built on top of our
|
|
|
43
45
|
<Cards>
|
|
44
46
|
<Card
|
|
45
47
|
title="Vercel AI SDK"
|
|
46
|
-
description="For useChat
|
|
47
|
-
href="/docs/runtimes/ai-sdk/
|
|
48
|
+
description="For useChat hook - streaming with all major providers"
|
|
49
|
+
href="/docs/runtimes/ai-sdk/v6"
|
|
48
50
|
/>
|
|
49
51
|
<Card
|
|
50
52
|
title="Data Stream Protocol"
|
|
@@ -66,6 +68,16 @@ For popular frameworks, we provide ready-to-use integrations built on top of our
|
|
|
66
68
|
description="For workflow orchestration with Mastra's ecosystem"
|
|
67
69
|
href="/docs/runtimes/mastra/overview"
|
|
68
70
|
/>
|
|
71
|
+
<Card
|
|
72
|
+
title="AG-UI Protocol"
|
|
73
|
+
description="For backends implementing the AG-UI (Agent-User Interaction) protocol"
|
|
74
|
+
href="https://www.npmjs.com/package/@assistant-ui/react-ag-ui"
|
|
75
|
+
/>
|
|
76
|
+
<Card
|
|
77
|
+
title="A2A Protocol"
|
|
78
|
+
description="For Agent-to-Agent protocol communication between AI agents"
|
|
79
|
+
href="/docs/runtimes/a2a"
|
|
80
|
+
/>
|
|
69
81
|
</Cards>
|
|
70
82
|
|
|
71
83
|
## Understanding Runtime Architecture
|
|
@@ -78,6 +90,8 @@ The pre-built integrations (AI SDK, LangGraph, etc.) are **not separate runtime
|
|
|
78
90
|
- **LangGraph Runtime** → Built on `LocalRuntime` with graph execution adapter
|
|
79
91
|
- **LangServe Runtime** → Built on `LocalRuntime` with LangServe client adapter
|
|
80
92
|
- **Mastra Runtime** → Built on `LocalRuntime` with workflow adapter
|
|
93
|
+
- **AG-UI Runtime** → Built on `LocalRuntime` with AG-UI protocol adapter
|
|
94
|
+
- **A2A Runtime** → Built on `LocalRuntime` with Agent-to-Agent protocol adapter
|
|
81
95
|
|
|
82
96
|
This means you get all the benefits of `LocalRuntime` (automatic state management, built-in features) with zero configuration for your specific framework.
|
|
83
97
|
|
|
@@ -127,6 +141,7 @@ Pre-built integrations can always be replaced with a custom `LocalRuntime` or `E
|
|
|
127
141
|
### Vercel AI SDK with Streaming
|
|
128
142
|
|
|
129
143
|
```tsx
|
|
144
|
+
import { AssistantRuntimeProvider, Thread } from "@assistant-ui/react";
|
|
130
145
|
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
131
146
|
|
|
132
147
|
export function MyAssistant() {
|
|
@@ -209,7 +224,7 @@ Explore our implementation examples:
|
|
|
209
224
|
|
|
210
225
|
1. **Choose your runtime** based on the decision tree above
|
|
211
226
|
2. **Follow the specific guide**:
|
|
212
|
-
- [AI SDK Integration](/docs/runtimes/ai-sdk/
|
|
227
|
+
- [AI SDK Integration](/docs/runtimes/ai-sdk/v6)
|
|
213
228
|
- [`LocalRuntime` Guide](/docs/runtimes/custom/local)
|
|
214
229
|
- [`ExternalStoreRuntime` Guide](/docs/runtimes/custom/external-store)
|
|
215
230
|
- [LangGraph Integration](/docs/runtimes/langgraph)
|
|
@@ -29,11 +29,12 @@ import { File } from "@/components/assistant-ui/file";
|
|
|
29
29
|
const AssistantMessage: FC = () => {
|
|
30
30
|
return (
|
|
31
31
|
<MessagePrimitive.Root className="...">
|
|
32
|
-
<MessagePrimitive.Parts
|
|
33
|
-
|
|
34
|
-
File
|
|
32
|
+
<MessagePrimitive.Parts>
|
|
33
|
+
{({ part }) => {
|
|
34
|
+
if (part.type === "file") return <File {...part} />;
|
|
35
|
+
return null;
|
|
35
36
|
}}
|
|
36
|
-
|
|
37
|
+
</MessagePrimitive.Parts>
|
|
37
38
|
</MessagePrimitive.Root>
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -29,11 +29,12 @@ import { Image } from "@/components/assistant-ui/image";
|
|
|
29
29
|
const AssistantMessage: FC = () => {
|
|
30
30
|
return (
|
|
31
31
|
<MessagePrimitive.Root className="...">
|
|
32
|
-
<MessagePrimitive.Parts
|
|
33
|
-
|
|
34
|
-
Image
|
|
32
|
+
<MessagePrimitive.Parts>
|
|
33
|
+
{({ part }) => {
|
|
34
|
+
if (part.type === "image") return <Image {...part} />;
|
|
35
|
+
return null;
|
|
35
36
|
}}
|
|
36
|
-
|
|
37
|
+
</MessagePrimitive.Parts>
|
|
37
38
|
</MessagePrimitive.Root>
|
|
38
39
|
);
|
|
39
40
|
};
|
|
@@ -50,7 +50,9 @@ const AssistantMessage: FC = () => {
|
|
|
50
50
|
return (
|
|
51
51
|
<MessagePrimitive.Root className="...">
|
|
52
52
|
<div className="...">
|
|
53
|
-
<MessagePrimitive.Parts
|
|
53
|
+
<MessagePrimitive.Parts>
|
|
54
|
+
{({ part }) => part.type === "text" ? <MarkdownText /> : null}
|
|
55
|
+
</MessagePrimitive.Parts>
|
|
54
56
|
</div>
|
|
55
57
|
<AssistantActionBar />
|
|
56
58
|
|
|
@@ -33,11 +33,11 @@ const ComposerAction: FC = () => {
|
|
|
33
33
|
<div className="flex items-center gap-1">
|
|
34
34
|
<ModelSelector
|
|
35
35
|
models={[
|
|
36
|
-
{ id: "gpt-
|
|
37
|
-
{ id: "gpt-
|
|
38
|
-
{ id: "
|
|
36
|
+
{ id: "gpt-4o-mini", name: "GPT-4o Mini", description: "Fast and efficient" },
|
|
37
|
+
{ id: "gpt-4o", name: "GPT-4o", description: "Balanced performance" },
|
|
38
|
+
{ id: "o3", name: "o3", description: "Most capable" },
|
|
39
39
|
]}
|
|
40
|
-
defaultValue="gpt-
|
|
40
|
+
defaultValue="gpt-4o-mini"
|
|
41
41
|
size="sm"
|
|
42
42
|
/>
|
|
43
43
|
</div>
|
|
@@ -58,7 +58,7 @@ export async function POST(req: Request) {
|
|
|
58
58
|
|
|
59
59
|
const result = streamText({
|
|
60
60
|
model: openai(config?.modelName ?? "gpt-4o"),
|
|
61
|
-
messages: convertToModelMessages(messages),
|
|
61
|
+
messages: await convertToModelMessages(messages),
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
return result.toUIMessageStreamResponse();
|
|
@@ -101,8 +101,8 @@ Each model in the `models` array supports:
|
|
|
101
101
|
```tsx
|
|
102
102
|
const models = [
|
|
103
103
|
{
|
|
104
|
-
id: "gpt-
|
|
105
|
-
name: "GPT-
|
|
104
|
+
id: "gpt-4o", // Sent to backend as config.modelName
|
|
105
|
+
name: "GPT-4o", // Display name in trigger and items
|
|
106
106
|
description: "Most capable", // Optional subtitle in items only
|
|
107
107
|
icon: <SparklesIcon />, // Optional icon (any ReactNode)
|
|
108
108
|
},
|
|
@@ -113,7 +113,7 @@ const models = [
|
|
|
113
113
|
|
|
114
114
|
The default `ModelSelector` export automatically registers the selected model with assistant-ui's `ModelContext` system. When a user selects a model:
|
|
115
115
|
|
|
116
|
-
1. The component calls `
|
|
116
|
+
1. The component calls `aui.modelContext().register()` with `config.modelName`
|
|
117
117
|
2. The `AssistantChatTransport` includes `config` in the request body
|
|
118
118
|
3. Your API route reads `config.modelName` to determine which model to use
|
|
119
119
|
|
|
@@ -337,22 +337,19 @@ async def my_run(controller):
|
|
|
337
337
|
# Add parts with custom parentId
|
|
338
338
|
research_controller = controller.with_parent_id("research-123")
|
|
339
339
|
|
|
340
|
-
await research_controller.add_tool_call("search"
|
|
340
|
+
tool = await research_controller.add_tool_call("search")
|
|
341
|
+
tool.append_args_text('{"query": "climate data"}')
|
|
342
|
+
tool.set_response("climate data results")
|
|
341
343
|
research_controller.append_text("Key findings from the research:")
|
|
342
344
|
|
|
343
|
-
# Add
|
|
344
|
-
controller.
|
|
345
|
-
"type": "text",
|
|
346
|
-
"text": "High priority finding",
|
|
347
|
-
"priority": "high",
|
|
348
|
-
"category": "findings"
|
|
349
|
-
})
|
|
345
|
+
# Add text with a different parent_id
|
|
346
|
+
controller.append_text("High priority finding")
|
|
350
347
|
```
|
|
351
348
|
|
|
352
349
|
### TypeScript (assistant-stream)
|
|
353
350
|
|
|
354
351
|
```typescript
|
|
355
|
-
import { createAssistantStream } from "
|
|
352
|
+
import { createAssistantStream } from "assistant-stream";
|
|
356
353
|
|
|
357
354
|
const stream = createAssistantStream(async (controller) => {
|
|
358
355
|
// Add parts with parentId
|
|
@@ -517,7 +514,7 @@ import { useAuiState } from "@assistant-ui/react";
|
|
|
517
514
|
const DynamicGroup: FC<
|
|
518
515
|
PropsWithChildren<{ groupKey: string | undefined; indices: number[] }>
|
|
519
516
|
> = ({ groupKey, indices, children }) => {
|
|
520
|
-
const parts = useAuiState((s) => s.message.
|
|
517
|
+
const parts = useAuiState((s) => s.message.parts);
|
|
521
518
|
const groupParts = indices.map((i) => parts[i]);
|
|
522
519
|
|
|
523
520
|
// Analyze group content
|