@assistant-ui/mcp-docs-server 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/local-ollama.md +13 -13
- package/.docs/organized/code-examples/search-agent-for-e-commerce.md +18 -18
- package/.docs/organized/code-examples/{with-vercel-ai-rsc.md → with-ai-sdk-v5.md} +225 -230
- package/.docs/organized/code-examples/with-ai-sdk.md +13 -13
- package/.docs/organized/code-examples/with-cloud.md +12 -12
- package/.docs/organized/code-examples/with-external-store.md +9 -9
- package/.docs/organized/code-examples/with-ffmpeg.md +19 -19
- package/.docs/organized/code-examples/with-langgraph.md +14 -14
- package/.docs/organized/code-examples/with-openai-assistants.md +12 -12
- package/.docs/organized/code-examples/with-parent-id-grouping.md +1374 -0
- package/.docs/organized/code-examples/with-react-hook-form.md +18 -18
- package/.docs/raw/docs/about-assistantui.mdx +9 -0
- package/.docs/raw/docs/api-reference/context-providers/{TextContentPartProvider.mdx → TextMessagePartProvider.mdx} +3 -3
- package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +2 -2
- package/.docs/raw/docs/api-reference/overview.mdx +23 -23
- package/.docs/raw/docs/api-reference/primitives/Error.mdx +5 -3
- package/.docs/raw/docs/api-reference/primitives/Message.mdx +32 -0
- package/.docs/raw/docs/api-reference/primitives/{ContentPart.mdx → MessagePart.mdx} +41 -41
- package/.docs/raw/docs/api-reference/runtimes/MessagePartRuntime.mdx +22 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +1 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +1 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +89 -32
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +187 -32
- package/.docs/raw/docs/concepts/runtime-layer.mdx +7 -7
- package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +22 -13
- package/.docs/raw/docs/copilots/make-assistant-tool.mdx +20 -14
- package/.docs/raw/docs/getting-started.mdx +11 -10
- package/.docs/raw/docs/guides/Attachments.mdx +24 -21
- package/.docs/raw/docs/guides/Latex.mdx +81 -0
- package/.docs/raw/docs/guides/ToolUI.mdx +13 -8
- package/.docs/raw/docs/migrations/v0-11.mdx +169 -0
- package/.docs/raw/docs/migrations/v0-7.mdx +8 -8
- package/.docs/raw/docs/migrations/v0-8.mdx +14 -14
- package/.docs/raw/docs/migrations/v0-9.mdx +3 -3
- package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-v5.mdx +129 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +3 -3
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +5 -5
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +2 -2
- package/.docs/raw/docs/ui/Attachment.mdx +5 -2
- package/.docs/raw/docs/ui/Markdown.mdx +2 -3
- package/.docs/raw/docs/ui/PartGrouping.mdx +540 -0
- package/.docs/raw/docs/ui/ToolFallback.mdx +2 -2
- package/.docs/raw/docs/ui/ToolGroup.mdx +96 -0
- package/package.json +8 -8
- package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +0 -22
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
|
-
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
7
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk-v4";
|
|
8
8
|
import { streamText } from "ai";
|
|
9
9
|
|
|
10
10
|
export const runtime = "edge";
|
|
@@ -189,7 +189,7 @@ export default function RootLayout({
|
|
|
189
189
|
"use client";
|
|
190
190
|
|
|
191
191
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
192
|
-
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
192
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk-v4";
|
|
193
193
|
|
|
194
194
|
export function MyRuntimeProvider({
|
|
195
195
|
children,
|
|
@@ -753,7 +753,7 @@ const UserMessage: FC = () => {
|
|
|
753
753
|
<UserActionBar />
|
|
754
754
|
|
|
755
755
|
<div className="bg-muted text-foreground col-start-2 row-start-2 max-w-[calc(var(--thread-max-width)*0.8)] break-words rounded-3xl px-5 py-2.5">
|
|
756
|
-
<MessagePrimitive.
|
|
756
|
+
<MessagePrimitive.Parts />
|
|
757
757
|
</div>
|
|
758
758
|
|
|
759
759
|
<BranchPicker className="col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
|
|
@@ -798,7 +798,7 @@ const AssistantMessage: FC = () => {
|
|
|
798
798
|
return (
|
|
799
799
|
<MessagePrimitive.Root className="relative grid w-full max-w-[var(--thread-max-width)] grid-cols-[auto_auto_1fr] grid-rows-[auto_1fr] py-4">
|
|
800
800
|
<div className="text-foreground col-span-2 col-start-2 row-start-1 my-1.5 max-w-[calc(var(--thread-max-width)*0.8)] break-words leading-7">
|
|
801
|
-
<MessagePrimitive.
|
|
801
|
+
<MessagePrimitive.Parts components={{ Text: MarkdownText }} />
|
|
802
802
|
</div>
|
|
803
803
|
|
|
804
804
|
<AssistantActionBar />
|
|
@@ -1654,7 +1654,7 @@ export default nextConfig;
|
|
|
1654
1654
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1655
1655
|
"@assistant-ui/react-hook-form": "workspace:*",
|
|
1656
1656
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1657
|
-
"@hookform/resolvers": "^5.
|
|
1657
|
+
"@hookform/resolvers": "^5.2.1",
|
|
1658
1658
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
1659
1659
|
"@radix-ui/react-icons": "^1.3.2",
|
|
1660
1660
|
"@radix-ui/react-label": "^2.1.7",
|
|
@@ -1666,18 +1666,18 @@ export default nextConfig;
|
|
|
1666
1666
|
"class-variance-authority": "^0.7.1",
|
|
1667
1667
|
"clsx": "^2.1.1",
|
|
1668
1668
|
"json-schema-to-zod": "^2.6.1",
|
|
1669
|
-
"lucide-react": "^0.
|
|
1670
|
-
"next": "15.
|
|
1671
|
-
"react": "19.1.
|
|
1672
|
-
"react-dom": "19.1.
|
|
1673
|
-
"react-hook-form": "^7.
|
|
1674
|
-
"react-resizable-panels": "^3.0.
|
|
1669
|
+
"lucide-react": "^0.535.0",
|
|
1670
|
+
"next": "15.4.5",
|
|
1671
|
+
"react": "19.1.1",
|
|
1672
|
+
"react-dom": "19.1.1",
|
|
1673
|
+
"react-hook-form": "^7.61.1",
|
|
1674
|
+
"react-resizable-panels": "^3.0.4",
|
|
1675
1675
|
"remark-gfm": "^4.0.1",
|
|
1676
1676
|
"tailwind-merge": "^3.3.1",
|
|
1677
|
-
"tw-animate-css": "^1.3.
|
|
1678
|
-
"zod": "^
|
|
1679
|
-
"zod-to-json-schema": "^3.24.
|
|
1680
|
-
"zustand": "^5.0.
|
|
1677
|
+
"tw-animate-css": "^1.3.6",
|
|
1678
|
+
"zod": "^4.0.14",
|
|
1679
|
+
"zod-to-json-schema": "^3.24.6",
|
|
1680
|
+
"zustand": "^5.0.7"
|
|
1681
1681
|
},
|
|
1682
1682
|
"devDependencies": {
|
|
1683
1683
|
"@assistant-ui/x-buildutils": "workspace:*",
|
|
@@ -1685,10 +1685,10 @@ export default nextConfig;
|
|
|
1685
1685
|
"@types/react": "^19",
|
|
1686
1686
|
"@types/react-dom": "^19",
|
|
1687
1687
|
"eslint": "^9",
|
|
1688
|
-
"eslint-config-next": "15.
|
|
1688
|
+
"eslint-config-next": "15.4.5",
|
|
1689
1689
|
"postcss": "^8",
|
|
1690
|
-
"tailwindcss": "^4.1.
|
|
1691
|
-
"typescript": "^5.
|
|
1690
|
+
"tailwindcss": "^4.1.11",
|
|
1691
|
+
"typescript": "^5.9.2"
|
|
1692
1692
|
}
|
|
1693
1693
|
}
|
|
1694
1694
|
|
|
@@ -41,4 +41,13 @@ assistant-ui helps you create beautiful, enterprise-grade AI chat interfaces in
|
|
|
41
41
|
[Get Started in 30 Seconds](/docs/getting-started).
|
|
42
42
|
</Callout>
|
|
43
43
|
|
|
44
|
+
## AI Accessible Documentation
|
|
45
|
+
|
|
46
|
+
Our docs are easily accessible to AI assistants through several methods:
|
|
47
|
+
|
|
48
|
+
- **[MCP Docs Server](/docs/mcp-docs-server)** - Direct MCP integration for IDEs and agents
|
|
49
|
+
- **`/llms.txt`** - Structured index of all documentation pages
|
|
50
|
+
- **`/llms-full.txt`** - Complete documentation in a single file
|
|
51
|
+
- **`.mdx` suffix** - Add `.mdx` to any page's URL for raw markdown content
|
|
52
|
+
|
|
44
53
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: <
|
|
2
|
+
title: <TextMessagePartProvider />
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
import { ParametersTable } from "@/components/docs";
|
|
6
6
|
import { AssistantRuntimeProvider } from "@/generated/typeDocs";
|
|
7
7
|
|
|
8
|
-
The `
|
|
8
|
+
The `TextMessagePartProvider` provides data and APIs for `TextMessagePart` components.
|
|
9
9
|
|
|
10
10
|
This is useful if you want to reuse the same `Text` component outside of a message text, e.g. with the `@assistant-ui/react-markdown` package.
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
|
14
14
|
|
|
15
15
|
const MyApp = () => {
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
17
|
+
<TextMessagePartProvider text={"Hello!"}>
|
|
18
18
|
<MyMarkdownText />
|
|
19
19
|
</AssistantRuntimeProvider>
|
|
20
20
|
);
|
|
@@ -51,7 +51,7 @@ Drop-in replacement hook for `useForm` that adds support for `@assistant-ui/reac
|
|
|
51
51
|
parameters: [
|
|
52
52
|
{
|
|
53
53
|
name: "render",
|
|
54
|
-
type: "
|
|
54
|
+
type: "ToolCallMessagePartComponent<{ name: string; value: string; }, {}>",
|
|
55
55
|
description:
|
|
56
56
|
"The component to render when set_form_field is called.",
|
|
57
57
|
},
|
|
@@ -68,7 +68,7 @@ Drop-in replacement hook for `useForm` that adds support for `@assistant-ui/reac
|
|
|
68
68
|
parameters: [
|
|
69
69
|
{
|
|
70
70
|
name: "render",
|
|
71
|
-
type: "
|
|
71
|
+
type: "ToolCallMessagePartComponent<{}, {}>",
|
|
72
72
|
description:
|
|
73
73
|
"The component to render when submit_form is called.",
|
|
74
74
|
},
|
|
@@ -11,7 +11,7 @@ export const contextColors = {
|
|
|
11
11
|
"Thread Context": "#45a049",
|
|
12
12
|
"Composer Context": "#ff9933",
|
|
13
13
|
"Message Context": "#bb2244",
|
|
14
|
-
"
|
|
14
|
+
"MessagePart Context": "#268bd2",
|
|
15
15
|
"Attachment Context": "#FFB6C1",
|
|
16
16
|
"ThreadListItem Context": "#c678dd",
|
|
17
17
|
};
|
|
@@ -93,20 +93,20 @@ export const contextColors = {
|
|
|
93
93
|
</Component>
|
|
94
94
|
|
|
95
95
|
<Component
|
|
96
|
-
name="
|
|
96
|
+
name="TextMessagePartProvider"
|
|
97
97
|
isContextProvider={true}
|
|
98
98
|
providedContexts={[
|
|
99
99
|
{
|
|
100
|
-
name: "Text
|
|
101
|
-
color: contextColors["
|
|
102
|
-
link: "#
|
|
100
|
+
name: "Text MessagePart Context",
|
|
101
|
+
color: contextColors["MessagePart Context"],
|
|
102
|
+
link: "#MessagePart-context",
|
|
103
103
|
},
|
|
104
104
|
]}
|
|
105
|
-
docsLink="./context-providers/
|
|
106
|
-
tooltip="Provides context for text
|
|
105
|
+
docsLink="./context-providers/TextMessagePartProvider"
|
|
106
|
+
tooltip="Provides context for text message parts"
|
|
107
107
|
props="text={text}"
|
|
108
108
|
>
|
|
109
|
-
<Component name="
|
|
109
|
+
<Component name="MessagePart" isLink={true} />
|
|
110
110
|
</Component>
|
|
111
111
|
|
|
112
112
|
<ContextLevel color={contextColors["Assistant Context"]}>
|
|
@@ -356,16 +356,16 @@ Manages the state and actions for individual messages
|
|
|
356
356
|
tooltip="Root component for a message"
|
|
357
357
|
>
|
|
358
358
|
<Component
|
|
359
|
-
name="MessagePrimitive.
|
|
359
|
+
name="MessagePrimitive.Parts"
|
|
360
360
|
isContextProvider={true}
|
|
361
361
|
providedContexts={[
|
|
362
362
|
{
|
|
363
|
-
name: "
|
|
364
|
-
color: contextColors["
|
|
363
|
+
name: "MessagePart Context",
|
|
364
|
+
color: contextColors["MessagePart Context"],
|
|
365
365
|
},
|
|
366
366
|
]}
|
|
367
|
-
docsLink="#message-primitive-
|
|
368
|
-
tooltip="Displays the
|
|
367
|
+
docsLink="#message-primitive-parts"
|
|
368
|
+
tooltip="Displays the parts of the message"
|
|
369
369
|
/>
|
|
370
370
|
<Component
|
|
371
371
|
name="MessagePrimitive.Attachments"
|
|
@@ -456,23 +456,23 @@ Manages the state and actions for individual messages
|
|
|
456
456
|
|
|
457
457
|
</ContextLevel>
|
|
458
458
|
|
|
459
|
-
<ContextLevel color={contextColors["
|
|
459
|
+
<ContextLevel color={contextColors["MessagePart Context"]}>
|
|
460
460
|
|
|
461
|
-
##
|
|
461
|
+
## MessagePart Context
|
|
462
462
|
|
|
463
|
-
Manages the state and actions for
|
|
463
|
+
Manages the state and actions for message parts within messages
|
|
464
464
|
|
|
465
|
-
###
|
|
465
|
+
### MessagePartRuntime
|
|
466
466
|
|
|
467
|
-
- [`
|
|
468
|
-
- [`
|
|
469
|
-
- [`
|
|
470
|
-
- [`
|
|
467
|
+
- [`useMessagePart`](#use-content-part)
|
|
468
|
+
- [`useMessagePartText`](#use-content-part-text)
|
|
469
|
+
- [`useMessagePartReasoning`](#use-content-part-reasoning)
|
|
470
|
+
- [`useMessagePartRuntime`](#use-content-part-runtime)
|
|
471
471
|
|
|
472
|
-
###
|
|
472
|
+
### MessagePartPrimitive
|
|
473
473
|
|
|
474
474
|
<Component
|
|
475
|
-
name="
|
|
475
|
+
name="MessagePartPrimitive.Text"
|
|
476
476
|
docsLink="#content-part-text"
|
|
477
477
|
tooltip="Represents a text part of the message content"
|
|
478
478
|
/>
|
|
@@ -30,7 +30,8 @@ Contains all parts of the error display. Renders a `<div>` element with `role="a
|
|
|
30
30
|
{
|
|
31
31
|
name: "asChild",
|
|
32
32
|
type: "boolean",
|
|
33
|
-
description:
|
|
33
|
+
description:
|
|
34
|
+
"Change the component to the HTML tag or custom component of the only child.",
|
|
34
35
|
},
|
|
35
36
|
]}
|
|
36
37
|
/>
|
|
@@ -45,7 +46,8 @@ Displays the error message. By default, it shows the error from the message cont
|
|
|
45
46
|
{
|
|
46
47
|
name: "children",
|
|
47
48
|
type: "ReactNode",
|
|
48
|
-
description:
|
|
49
|
+
description:
|
|
50
|
+
"Optional custom content to display instead of the default error message.",
|
|
49
51
|
},
|
|
50
52
|
]}
|
|
51
53
|
/>
|
|
@@ -59,7 +61,7 @@ import { MessagePrimitive, ErrorPrimitive } from "@assistant-ui/react";
|
|
|
59
61
|
|
|
60
62
|
const MessageWithError = () => (
|
|
61
63
|
<MessagePrimitive.Root>
|
|
62
|
-
<MessagePrimitive.
|
|
64
|
+
<MessagePrimitive.Parts />
|
|
63
65
|
<MessagePrimitive.Error>
|
|
64
66
|
<ErrorPrimitive.Root>
|
|
65
67
|
<ErrorPrimitive.Message />
|
|
@@ -115,6 +115,38 @@ The content of the message. This renders a separate component for each content p
|
|
|
115
115
|
},
|
|
116
116
|
],
|
|
117
117
|
},
|
|
118
|
+
{
|
|
119
|
+
name: "ToolGroup",
|
|
120
|
+
type: "ComponentType<PropsWithChildren<{ startIndex: number; endIndex: number }>>",
|
|
121
|
+
description:
|
|
122
|
+
"Component for rendering grouped consecutive tool calls. When provided, consecutive tool-call content parts will be automatically grouped and wrapped with this component.",
|
|
123
|
+
children: [
|
|
124
|
+
{
|
|
125
|
+
type: "ToolGroupProps",
|
|
126
|
+
parameters: [
|
|
127
|
+
{
|
|
128
|
+
name: "startIndex",
|
|
129
|
+
type: "number",
|
|
130
|
+
description: "Index of the first tool call in the group.",
|
|
131
|
+
required: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "endIndex",
|
|
135
|
+
type: "number",
|
|
136
|
+
description: "Index of the last tool call in the group.",
|
|
137
|
+
required: true,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "children",
|
|
141
|
+
type: "ReactNode",
|
|
142
|
+
description:
|
|
143
|
+
"The rendered tool call components within the group.",
|
|
144
|
+
required: true,
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
118
150
|
],
|
|
119
151
|
},
|
|
120
152
|
],
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description: A part of a message's content.
|
|
2
|
+
title: MessagePartPrimitive
|
|
3
|
+
description: A part of a message's content. Message parts may be text, image, tool call or UI elements.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
import { ParametersTable } from "@/components/docs";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
MessagePartRuntime,
|
|
9
|
+
TextMessagePartState,
|
|
10
|
+
AudioMessagePartState,
|
|
11
|
+
ToolCallMessagePartState,
|
|
12
12
|
} from "@/generated/typeDocs";
|
|
13
13
|
|
|
14
|
-
Each message can have any number of
|
|
15
|
-
|
|
14
|
+
Each message can have any number of message parts.
|
|
15
|
+
Message parts are usually one of text, reasoning, audio or tool-call.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Message part Types
|
|
18
18
|
|
|
19
19
|
### Text
|
|
20
20
|
|
|
@@ -35,10 +35,10 @@ Interactive elements that represent tool operations.
|
|
|
35
35
|
## Anatomy
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
|
-
import {
|
|
38
|
+
import { MessagePartPrimitive } from "@assistant-ui/react";
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
return <
|
|
40
|
+
const TextMessagePart = () => {
|
|
41
|
+
return <MessagePartPrimitive.Text />;
|
|
42
42
|
};
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -47,9 +47,9 @@ const TextContentPart = () => {
|
|
|
47
47
|
### Plain Text
|
|
48
48
|
|
|
49
49
|
```tsx
|
|
50
|
-
import {
|
|
50
|
+
import { MessagePartPrimitive } from "@assistant/react";
|
|
51
51
|
|
|
52
|
-
<
|
|
52
|
+
<MessagePartPrimitive.Text />;
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
### Markdown Text
|
|
@@ -68,14 +68,14 @@ Coming soon.
|
|
|
68
68
|
|
|
69
69
|
### InProgress
|
|
70
70
|
|
|
71
|
-
Renders children only if the
|
|
71
|
+
Renders children only if the message part is in progress.
|
|
72
72
|
|
|
73
73
|
```tsx
|
|
74
|
-
import {
|
|
74
|
+
import { MessagePartPrimitive } from "@assistant/react";
|
|
75
75
|
|
|
76
|
-
<
|
|
76
|
+
<MessagePartPrimitive.InProgress>
|
|
77
77
|
<LoadingIndicator />
|
|
78
|
-
</
|
|
78
|
+
</MessagePartPrimitive.InProgress>;
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
### Tool UI
|
|
@@ -104,14 +104,14 @@ const MyWeatherToolUI = makeAssistantToolUI({
|
|
|
104
104
|
|
|
105
105
|
## Context Provider
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Message part context is provided by `MessagePrimitive.Parts` or `TextMessagePartProvider`
|
|
108
108
|
|
|
109
|
-
### MessagePrimitive.
|
|
109
|
+
### MessagePrimitive.Parts
|
|
110
110
|
|
|
111
111
|
```tsx
|
|
112
112
|
import { MessagePrimitive } from "@assistant/react";
|
|
113
113
|
|
|
114
|
-
<MessagePrimitive.
|
|
114
|
+
<MessagePrimitive.Parts
|
|
115
115
|
components={{
|
|
116
116
|
Text: MyText,
|
|
117
117
|
Reasoning: MyReasoning,
|
|
@@ -126,48 +126,48 @@ import { MessagePrimitive } from "@assistant/react";
|
|
|
126
126
|
/>;
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
###
|
|
129
|
+
### TextMessagePartProvider
|
|
130
130
|
|
|
131
|
-
This is a helper context provider to allow you to reuse the
|
|
131
|
+
This is a helper context provider to allow you to reuse the message part components outside a message message part.
|
|
132
132
|
|
|
133
133
|
```tsx
|
|
134
|
-
import {
|
|
134
|
+
import { TextMessagePartProvider } from "@assistant-ui/react";
|
|
135
135
|
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
</
|
|
136
|
+
<TextMessagePartProvider text="Hello world" isRunning={false}>
|
|
137
|
+
<MessagePart.Text />
|
|
138
|
+
</TextMessagePartProvider>;
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
## Runtime API
|
|
142
142
|
|
|
143
|
-
### `
|
|
143
|
+
### `useMessagePartRuntime`
|
|
144
144
|
|
|
145
145
|
```tsx
|
|
146
|
-
import {
|
|
146
|
+
import { useMessagePartRuntime } from "@assistant-ui/react";
|
|
147
147
|
|
|
148
|
-
const
|
|
148
|
+
const MessagePartRuntime = useMessagePartRuntime();
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
<ParametersTable {...
|
|
151
|
+
<ParametersTable {...MessagePartRuntime} />
|
|
152
152
|
|
|
153
|
-
### `
|
|
153
|
+
### `useMessagePart`
|
|
154
154
|
|
|
155
155
|
```tsx
|
|
156
|
-
import {
|
|
156
|
+
import { useMessagePart } from "@assistant-ui/react";
|
|
157
157
|
|
|
158
|
-
const
|
|
158
|
+
const MessagePart = useMessagePart();
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
<ParametersTable {...
|
|
162
|
-
<ParametersTable {...
|
|
163
|
-
<ParametersTable {...
|
|
161
|
+
<ParametersTable {...TextMessagePartState} />
|
|
162
|
+
<ParametersTable {...AudioMessagePartState} />
|
|
163
|
+
<ParametersTable {...ToolCallMessagePartState} />
|
|
164
164
|
|
|
165
|
-
### `
|
|
165
|
+
### `useMessagePartText`
|
|
166
166
|
|
|
167
167
|
```tsx
|
|
168
|
-
import {
|
|
168
|
+
import { useMessagePartText } from "@assistant-ui/react";
|
|
169
169
|
|
|
170
|
-
const
|
|
170
|
+
const MessagePartText = useMessagePartText();
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
<ParametersTable {...
|
|
173
|
+
<ParametersTable {...TextMessagePartState} />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MessagePartRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import { MessagePartState } from "@/components/docs/parameters/context";
|
|
7
|
+
|
|
8
|
+
### `useMessagePart`
|
|
9
|
+
|
|
10
|
+
Access the message part state:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { useMessagePart } from "@assistant-ui/react";
|
|
14
|
+
|
|
15
|
+
const part = useMessagePart();
|
|
16
|
+
const partState = useMessagePart.getState();
|
|
17
|
+
|
|
18
|
+
const status = useMessagePart((m) => m.status);
|
|
19
|
+
const statusAgain = useMessagePart.getState().status;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<ParametersTable {...MessagePartState} />
|
|
@@ -2,53 +2,110 @@
|
|
|
2
2
|
title: Chat History for AI SDK
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { Steps, Step } from 'fumadocs-ui/components/steps';
|
|
6
|
+
import { Callout } from 'fumadocs-ui/components/callout';
|
|
7
|
+
|
|
5
8
|
## Overview
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
assistant-cloud provides thread management and persistent chat history for applications built with the [AI SDK by Vercel](https://sdk.vercel.ai/). This guide shows you how to integrate cloud persistence into your AI SDK application.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
<Callout type="info">
|
|
15
|
+
You need an assistant-cloud account to follow this guide. [Sign up here](https://cloud.assistant-ui.com/) to get started.
|
|
16
|
+
</Callout>
|
|
17
|
+
|
|
18
|
+
## Setup Guide
|
|
19
|
+
|
|
20
|
+
<Steps>
|
|
21
|
+
|
|
22
|
+
<Step>
|
|
23
|
+
|
|
24
|
+
### Create a Cloud Project
|
|
25
|
+
|
|
26
|
+
Create a new project in the [assistant-cloud dashboard](https://cloud.assistant-ui.com/) and from the settings page, copy:
|
|
27
|
+
|
|
28
|
+
- **Frontend API URL**: `https://proj-[ID].assistant-api.com`
|
|
29
|
+
- **Assistant Cloud API Key**: `sk_aui_proj_*`
|
|
30
|
+
|
|
31
|
+
</Step>
|
|
32
|
+
|
|
33
|
+
<Step>
|
|
34
|
+
|
|
35
|
+
### Configure Environment Variables
|
|
36
|
+
|
|
37
|
+
Add the following environment variables to your project:
|
|
8
38
|
|
|
9
|
-
|
|
39
|
+
```bash title=".env.local"
|
|
40
|
+
# Frontend API URL from your cloud project settings
|
|
41
|
+
NEXT_PUBLIC_ASSISTANT_BASE_URL=https://proj-[YOUR-ID].assistant-api.com
|
|
10
42
|
|
|
11
|
-
|
|
43
|
+
# API key for server-side operations
|
|
44
|
+
ASSISTANT_API_KEY=your-api-key-here
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
</Step>
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
<Step>
|
|
14
50
|
|
|
15
|
-
|
|
16
|
-
|
|
51
|
+
### Install Dependencies
|
|
52
|
+
|
|
53
|
+
Install the required packages:
|
|
17
54
|
|
|
18
55
|
```bash
|
|
19
|
-
|
|
56
|
+
npm install @assistant-ui/react @assistant-ui/react-ai-sdk
|
|
20
57
|
```
|
|
21
|
-
3. Create a client side AssistantCloud instance. Note: this will create an anonymous user id that is tied to the user's browser session. For connecting to an auth provider to persist threads for a user based on a workspace and/or user id, look at [Cloud Authorization Docs](/docs/cloud/authorization).
|
|
22
58
|
|
|
23
|
-
|
|
59
|
+
</Step>
|
|
60
|
+
|
|
61
|
+
<Step>
|
|
62
|
+
|
|
63
|
+
### Set Up the Cloud Runtime
|
|
64
|
+
|
|
65
|
+
Create a client-side AssistantCloud instance and integrate it with your AI SDK runtime:
|
|
66
|
+
|
|
67
|
+
```tsx title="app/chat/page.tsx"
|
|
24
68
|
"use client";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
AssistantRuntimeProvider,
|
|
28
|
-
ThreadList,
|
|
29
|
-
Thread
|
|
30
|
-
} from "@assistant-ui/react";
|
|
69
|
+
|
|
70
|
+
import { AssistantCloud, AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
31
71
|
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
72
|
+
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
73
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
74
|
+
|
|
75
|
+
export default function ChatPage() {
|
|
76
|
+
const cloud = new AssistantCloud({
|
|
77
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
78
|
+
anonymous: true, // Creates browser-session based user ID
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const runtime = useChatRuntime({
|
|
82
|
+
api: "/api/chat", // Your AI SDK endpoint
|
|
83
|
+
cloud,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
88
|
+
<div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
|
|
89
|
+
<ThreadList />
|
|
90
|
+
<Thread />
|
|
91
|
+
</div>
|
|
92
|
+
</AssistantRuntimeProvider>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
</Step>
|
|
32
98
|
|
|
99
|
+
</Steps>
|
|
33
100
|
|
|
34
|
-
|
|
35
|
-
baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
|
|
36
|
-
anonymous: true,
|
|
37
|
-
});
|
|
101
|
+
## Authentication
|
|
38
102
|
|
|
103
|
+
The example above uses `anonymous: true` which creates a browser session-based user ID. This is suitable for public demos or prototypes.
|
|
39
104
|
|
|
40
|
-
|
|
41
|
-
api: "/api/chat",
|
|
42
|
-
cloud,
|
|
43
|
-
});
|
|
105
|
+
For production apps with user accounts, see the [Cloud Authorization](/docs/cloud/authorization) guide to persist threads per user or workspace.
|
|
44
106
|
|
|
45
|
-
|
|
46
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
|
47
|
-
<div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
|
|
48
|
-
<ThreadList />
|
|
49
|
-
<Thread />
|
|
50
|
-
</div>
|
|
51
|
-
</AssistantRuntimeProvider>
|
|
52
|
-
);
|
|
107
|
+
## Next Steps
|
|
53
108
|
|
|
54
|
-
|
|
109
|
+
- Learn about [user authentication](/docs/cloud/authorization) for multi-user applications
|
|
110
|
+
- Explore [runtime hooks](/docs/api-reference/integrations/vercel-ai-sdk) and integration options
|
|
111
|
+
- Check out the [complete example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-cloud) on GitHub
|