@assistant-ui/mcp-docs-server 0.1.6 → 0.1.8
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 +15 -13
- package/.docs/organized/code-examples/with-cloud.md +19 -25
- package/.docs/organized/code-examples/with-external-store.md +9 -7
- package/.docs/organized/code-examples/with-ffmpeg.md +21 -21
- package/.docs/organized/code-examples/with-langgraph.md +72 -46
- package/.docs/organized/code-examples/with-parent-id-grouping.md +9 -7
- package/.docs/organized/code-examples/with-react-hook-form.md +19 -21
- package/.docs/raw/docs/api-reference/integrations/react-data-stream.mdx +194 -0
- package/.docs/raw/docs/api-reference/overview.mdx +7 -4
- package/.docs/raw/docs/api-reference/primitives/Composer.mdx +31 -0
- package/.docs/raw/docs/api-reference/primitives/Message.mdx +108 -3
- package/.docs/raw/docs/api-reference/primitives/Thread.mdx +59 -0
- package/.docs/raw/docs/api-reference/primitives/ThreadList.mdx +128 -0
- package/.docs/raw/docs/api-reference/primitives/ThreadListItem.mdx +160 -0
- package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +0 -11
- package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +3 -3
- package/.docs/raw/docs/copilots/assistant-frame.mdx +397 -0
- package/.docs/raw/docs/getting-started.mdx +53 -52
- package/.docs/raw/docs/guides/Attachments.mdx +7 -115
- package/.docs/raw/docs/guides/ToolUI.mdx +3 -3
- package/.docs/raw/docs/guides/Tools.mdx +152 -92
- package/.docs/raw/docs/guides/context-api.mdx +574 -0
- package/.docs/raw/docs/migrations/v0-12.mdx +125 -0
- 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 +16 -3
- package/.docs/raw/docs/runtimes/data-stream.mdx +287 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +9 -11
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +5 -0
- package/.docs/raw/docs/ui/ThreadList.mdx +54 -16
- package/dist/{chunk-L4K23SWI.js → chunk-NVNFQ5ZO.js} +4 -1
- package/dist/index.js +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- 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 -1082
- package/.docs/organized/code-examples/with-openai-assistants.md +0 -1175
- package/.docs/raw/docs/concepts/architecture.mdx +0 -19
- package/.docs/raw/docs/concepts/runtime-layer.mdx +0 -163
- package/.docs/raw/docs/concepts/why.mdx +0 -9
- 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 -212
|
@@ -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}>
|
|
@@ -887,6 +883,7 @@ const CircleStopIcon = () => {
|
|
|
887
883
|
"use client";
|
|
888
884
|
|
|
889
885
|
import { ComponentPropsWithoutRef, forwardRef } from "react";
|
|
886
|
+
import { Slottable } from "@radix-ui/react-slot";
|
|
890
887
|
|
|
891
888
|
import {
|
|
892
889
|
Tooltip,
|
|
@@ -915,7 +912,7 @@ export const TooltipIconButton = forwardRef<
|
|
|
915
912
|
className={cn("size-6 p-1", className)}
|
|
916
913
|
ref={ref}
|
|
917
914
|
>
|
|
918
|
-
{children}
|
|
915
|
+
<Slottable>{children}</Slottable>
|
|
919
916
|
<span className="sr-only">{tooltip}</span>
|
|
920
917
|
</Button>
|
|
921
918
|
</TooltipTrigger>
|
|
@@ -1649,7 +1646,7 @@ export default nextConfig;
|
|
|
1649
1646
|
"lint": "next lint"
|
|
1650
1647
|
},
|
|
1651
1648
|
"dependencies": {
|
|
1652
|
-
"@ai-sdk/openai": "^
|
|
1649
|
+
"@ai-sdk/openai": "^2.0.15",
|
|
1653
1650
|
"@assistant-ui/react": "workspace:*",
|
|
1654
1651
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1655
1652
|
"@assistant-ui/react-hook-form": "workspace:*",
|
|
@@ -1659,23 +1656,23 @@ export default nextConfig;
|
|
|
1659
1656
|
"@radix-ui/react-icons": "^1.3.2",
|
|
1660
1657
|
"@radix-ui/react-label": "^2.1.7",
|
|
1661
1658
|
"@radix-ui/react-slot": "^1.2.3",
|
|
1662
|
-
"@radix-ui/react-tabs": "^1.1.
|
|
1663
|
-
"@radix-ui/react-tooltip": "^1.2.
|
|
1659
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
1660
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
1664
1661
|
"@react-hook/media-query": "^1.1.1",
|
|
1665
|
-
"ai": "^
|
|
1662
|
+
"ai": "^5.0.15",
|
|
1666
1663
|
"class-variance-authority": "^0.7.1",
|
|
1667
1664
|
"clsx": "^2.1.1",
|
|
1668
1665
|
"json-schema-to-zod": "^2.6.1",
|
|
1669
|
-
"lucide-react": "^0.
|
|
1670
|
-
"next": "15.4.
|
|
1666
|
+
"lucide-react": "^0.539.0",
|
|
1667
|
+
"next": "15.4.6",
|
|
1671
1668
|
"react": "19.1.1",
|
|
1672
1669
|
"react-dom": "19.1.1",
|
|
1673
|
-
"react-hook-form": "^7.
|
|
1670
|
+
"react-hook-form": "^7.62.0",
|
|
1674
1671
|
"react-resizable-panels": "^3.0.4",
|
|
1675
1672
|
"remark-gfm": "^4.0.1",
|
|
1676
1673
|
"tailwind-merge": "^3.3.1",
|
|
1677
1674
|
"tw-animate-css": "^1.3.6",
|
|
1678
|
-
"zod": "^4.0.
|
|
1675
|
+
"zod": "^4.0.17",
|
|
1679
1676
|
"zustand": "^5.0.7"
|
|
1680
1677
|
},
|
|
1681
1678
|
"devDependencies": {
|
|
@@ -1684,9 +1681,9 @@ export default nextConfig;
|
|
|
1684
1681
|
"@types/react": "^19",
|
|
1685
1682
|
"@types/react-dom": "^19",
|
|
1686
1683
|
"eslint": "^9",
|
|
1687
|
-
"eslint-config-next": "15.4.
|
|
1684
|
+
"eslint-config-next": "15.4.6",
|
|
1688
1685
|
"postcss": "^8",
|
|
1689
|
-
"tailwindcss": "^4.1.
|
|
1686
|
+
"tailwindcss": "^4.1.12",
|
|
1690
1687
|
"typescript": "^5.9.2"
|
|
1691
1688
|
}
|
|
1692
1689
|
}
|
|
@@ -1714,6 +1711,7 @@ export default nextConfig;
|
|
|
1714
1711
|
"@/*": ["./*"],
|
|
1715
1712
|
"@assistant-ui/*": ["../../packages/*/src"],
|
|
1716
1713
|
"@assistant-ui/react/*": ["../../packages/react/src/*"],
|
|
1714
|
+
"@assistant-ui/tap/*": ["../../packages/tap/src/*"],
|
|
1717
1715
|
"assistant-stream": ["../../packages/assistant-stream/src"],
|
|
1718
1716
|
"assistant-stream/*": ["../../packages/assistant-stream/src/*"]
|
|
1719
1717
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "@assistant-ui/react-data-stream"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Data Stream protocol integration for assistant-ui.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
|
|
9
|
+
## API Reference
|
|
10
|
+
|
|
11
|
+
### `useDataStreamRuntime`
|
|
12
|
+
|
|
13
|
+
Create a runtime that connects to a data stream protocol endpoint.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { useDataStreamRuntime } from "@assistant-ui/react-data-stream";
|
|
17
|
+
|
|
18
|
+
const MyRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
|
|
19
|
+
const runtime = useDataStreamRuntime({
|
|
20
|
+
api: "/api/chat",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
25
|
+
{children}
|
|
26
|
+
</AssistantRuntimeProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<ParametersTable
|
|
32
|
+
parameters={[
|
|
33
|
+
{
|
|
34
|
+
name: "api",
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "The API endpoint URL for the data stream protocol.",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "onResponse",
|
|
40
|
+
type: "(response: Response) => void | Promise<void>",
|
|
41
|
+
description: "Optional callback called when a response is received.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "onFinish",
|
|
45
|
+
type: "(message: ThreadMessage) => void",
|
|
46
|
+
description: "Optional callback called when a message is finished.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "onError",
|
|
50
|
+
type: "(error: Error) => void",
|
|
51
|
+
description: "Optional callback called when an error occurs.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "onCancel",
|
|
55
|
+
type: "() => void",
|
|
56
|
+
description: "Optional callback called when a request is cancelled.",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "credentials",
|
|
60
|
+
type: "RequestCredentials",
|
|
61
|
+
description: "Optional credentials mode for the fetch request.",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "headers",
|
|
65
|
+
type: "Record<string, string> | Headers | (() => Promise<Record<string, string> | Headers>)",
|
|
66
|
+
description: "Optional headers to include in the request.",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "body",
|
|
70
|
+
type: "object",
|
|
71
|
+
description: "Optional additional body parameters to include in the request.",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "sendExtraMessageFields",
|
|
75
|
+
type: "boolean",
|
|
76
|
+
description: "Whether to include extra message fields like IDs in the request.",
|
|
77
|
+
},
|
|
78
|
+
]}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
### `useCloudRuntime`
|
|
82
|
+
|
|
83
|
+
Create a runtime that connects to Assistant Cloud using the data stream protocol.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { useCloudRuntime } from "@assistant-ui/react-data-stream";
|
|
87
|
+
|
|
88
|
+
const MyRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
|
|
89
|
+
const runtime = useCloudRuntime({
|
|
90
|
+
cloud: assistantCloud,
|
|
91
|
+
assistantId: "my-assistant-id",
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
96
|
+
{children}
|
|
97
|
+
</AssistantRuntimeProvider>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
<ParametersTable
|
|
103
|
+
parameters={[
|
|
104
|
+
{
|
|
105
|
+
name: "cloud",
|
|
106
|
+
type: "AssistantCloud",
|
|
107
|
+
description: "The Assistant Cloud instance.",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "assistantId",
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "The ID of the assistant to connect to.",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "onResponse",
|
|
116
|
+
type: "(response: Response) => void | Promise<void>",
|
|
117
|
+
description: "Optional callback called when a response is received.",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "onFinish",
|
|
121
|
+
type: "(message: ThreadMessage) => void",
|
|
122
|
+
description: "Optional callback called when a message is finished.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "onError",
|
|
126
|
+
type: "(error: Error) => void",
|
|
127
|
+
description: "Optional callback called when an error occurs.",
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "onCancel",
|
|
131
|
+
type: "() => void",
|
|
132
|
+
description: "Optional callback called when a request is cancelled.",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "credentials",
|
|
136
|
+
type: "RequestCredentials",
|
|
137
|
+
description: "Optional credentials mode for the fetch request.",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "headers",
|
|
141
|
+
type: "Record<string, string> | Headers | (() => Promise<Record<string, string> | Headers>)",
|
|
142
|
+
description: "Optional headers to include in the request.",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "body",
|
|
146
|
+
type: "object",
|
|
147
|
+
description: "Optional additional body parameters to include in the request.",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "sendExtraMessageFields",
|
|
151
|
+
type: "boolean",
|
|
152
|
+
description: "Whether to include extra message fields like IDs in the request.",
|
|
153
|
+
},
|
|
154
|
+
]}
|
|
155
|
+
/>
|
|
156
|
+
|
|
157
|
+
### `toLanguageModelMessages`
|
|
158
|
+
|
|
159
|
+
Convert assistant-ui messages to language model format.
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
import { toLanguageModelMessages } from "@assistant-ui/react-data-stream";
|
|
163
|
+
|
|
164
|
+
const languageModelMessages = toLanguageModelMessages(messages, {
|
|
165
|
+
unstable_includeId: true,
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
<ParametersTable
|
|
170
|
+
parameters={[
|
|
171
|
+
{
|
|
172
|
+
name: "messages",
|
|
173
|
+
type: "readonly ThreadMessage[]",
|
|
174
|
+
description: "The messages to convert.",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "options",
|
|
178
|
+
type: "{ unstable_includeId?: boolean }",
|
|
179
|
+
description: "Optional conversion options.",
|
|
180
|
+
children: [
|
|
181
|
+
{
|
|
182
|
+
type: "{ unstable_includeId?: boolean }",
|
|
183
|
+
parameters: [
|
|
184
|
+
{
|
|
185
|
+
name: "unstable_includeId",
|
|
186
|
+
type: "boolean",
|
|
187
|
+
description: "Whether to include message IDs in the converted messages.",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
]}
|
|
194
|
+
/>
|
|
@@ -29,10 +29,13 @@ export const contextColors = {
|
|
|
29
29
|
### AI SDK
|
|
30
30
|
|
|
31
31
|
- [`useChatRuntime`](#use-chat-runtime)
|
|
32
|
-
- [`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
- [`useAISDKRuntime`](#use-aisdk-runtime)
|
|
33
|
+
|
|
34
|
+
### Data Stream
|
|
35
|
+
|
|
36
|
+
- [`useDataStreamRuntime`](#use-data-stream-runtime)
|
|
37
|
+
- [`useCloudRuntime`](#use-cloud-runtime)
|
|
38
|
+
- [`toLanguageModelMessages`](#to-language-model-messages)
|
|
36
39
|
|
|
37
40
|
### LangGraph
|
|
38
41
|
|
|
@@ -168,6 +168,37 @@ Renders attachments. This primitive renders a separate component for each attach
|
|
|
168
168
|
]}
|
|
169
169
|
/>
|
|
170
170
|
|
|
171
|
+
### AttachmentByIndex
|
|
172
|
+
|
|
173
|
+
Renders a single attachment at the specified index within the composer.
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
<ComposerPrimitive.AttachmentByIndex
|
|
177
|
+
index={0}
|
|
178
|
+
components={{
|
|
179
|
+
Image: MyImageAttachment,
|
|
180
|
+
Document: MyDocumentAttachment
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
<ParametersTable
|
|
186
|
+
type="ComposerPrimitive.AttachmentByIndex.Props"
|
|
187
|
+
parameters={[
|
|
188
|
+
{
|
|
189
|
+
name: "index",
|
|
190
|
+
type: "number",
|
|
191
|
+
required: true,
|
|
192
|
+
description: "The index of the attachment to render.",
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: "components",
|
|
196
|
+
type: "ComposerAttachmentsComponents",
|
|
197
|
+
description: "The components to render for the attachment.",
|
|
198
|
+
},
|
|
199
|
+
]}
|
|
200
|
+
/>
|
|
201
|
+
|
|
171
202
|
### AddAttachment
|
|
172
203
|
|
|
173
204
|
Renders a button to add an attachment.
|
|
@@ -13,7 +13,7 @@ import { MessagePrimitive } from "@assistant-ui/react";
|
|
|
13
13
|
|
|
14
14
|
const UserMessage = () => (
|
|
15
15
|
<MessagePrimitive.Root>
|
|
16
|
-
User: <MessagePrimitive.
|
|
16
|
+
User: <MessagePrimitive.Parts />
|
|
17
17
|
<BranchPicker />
|
|
18
18
|
<ActionBar />
|
|
19
19
|
</MessagePrimitive.Root>
|
|
@@ -21,7 +21,7 @@ const UserMessage = () => (
|
|
|
21
21
|
|
|
22
22
|
const AssistantMessage = () => (
|
|
23
23
|
<MessagePrimitive.Root>
|
|
24
|
-
Assistant: <MessagePrimitive.
|
|
24
|
+
Assistant: <MessagePrimitive.Parts />
|
|
25
25
|
<BranchPicker />
|
|
26
26
|
<ActionBar />
|
|
27
27
|
</MessagePrimitive.Root>
|
|
@@ -45,7 +45,7 @@ This primitive renders a `<div>` element unless `asChild` is set.
|
|
|
45
45
|
]}
|
|
46
46
|
/>
|
|
47
47
|
|
|
48
|
-
###
|
|
48
|
+
### Parts
|
|
49
49
|
|
|
50
50
|
The content of the message. This renders a separate component for each content part of the message.
|
|
51
51
|
|
|
@@ -154,6 +154,111 @@ The content of the message. This renders a separate component for each content p
|
|
|
154
154
|
]}
|
|
155
155
|
/>
|
|
156
156
|
|
|
157
|
+
### PartByIndex
|
|
158
|
+
|
|
159
|
+
Renders a single message part at the specified index.
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
<MessagePrimitive.PartByIndex
|
|
163
|
+
index={0}
|
|
164
|
+
components={{
|
|
165
|
+
Text: MyTextComponent,
|
|
166
|
+
Image: MyImageComponent
|
|
167
|
+
}}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
<ParametersTable
|
|
172
|
+
type="MessagePrimitive.PartByIndex.Props"
|
|
173
|
+
parameters={[
|
|
174
|
+
{
|
|
175
|
+
name: "index",
|
|
176
|
+
type: "number",
|
|
177
|
+
required: true,
|
|
178
|
+
description: "The index of the message part to render.",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "components",
|
|
182
|
+
required: false,
|
|
183
|
+
type: "ContentPartComponents",
|
|
184
|
+
description: "The components to render for the message part.",
|
|
185
|
+
},
|
|
186
|
+
]}
|
|
187
|
+
/>
|
|
188
|
+
|
|
189
|
+
### Attachments
|
|
190
|
+
|
|
191
|
+
Renders all attachments of the message.
|
|
192
|
+
|
|
193
|
+
<ParametersTable
|
|
194
|
+
type="MessagePrimitive.Attachments.Props"
|
|
195
|
+
parameters={[
|
|
196
|
+
{
|
|
197
|
+
name: "components",
|
|
198
|
+
type: "AttachmentComponents",
|
|
199
|
+
description: "The components to render for each attachment.",
|
|
200
|
+
children: [
|
|
201
|
+
{
|
|
202
|
+
type: "AttachmentComponents",
|
|
203
|
+
parameters: [
|
|
204
|
+
{
|
|
205
|
+
name: "Image",
|
|
206
|
+
type: "ComponentType",
|
|
207
|
+
description: "The component to render for image attachments.",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "Document",
|
|
211
|
+
type: "ComponentType",
|
|
212
|
+
description: "The component to render for document attachments.",
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "File",
|
|
216
|
+
type: "ComponentType",
|
|
217
|
+
description: "The component to render for file attachments.",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "Attachment",
|
|
221
|
+
type: "ComponentType",
|
|
222
|
+
description: "The fallback component to render for any attachment type.",
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
]}
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
### AttachmentByIndex
|
|
232
|
+
|
|
233
|
+
Renders a single attachment at the specified index within the message.
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
<MessagePrimitive.AttachmentByIndex
|
|
237
|
+
index={0}
|
|
238
|
+
components={{
|
|
239
|
+
Image: MyImageAttachment,
|
|
240
|
+
Document: MyDocumentAttachment
|
|
241
|
+
}}
|
|
242
|
+
/>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
<ParametersTable
|
|
246
|
+
type="MessagePrimitive.AttachmentByIndex.Props"
|
|
247
|
+
parameters={[
|
|
248
|
+
{
|
|
249
|
+
name: "index",
|
|
250
|
+
type: "number",
|
|
251
|
+
required: true,
|
|
252
|
+
description: "The index of the attachment to render.",
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "components",
|
|
256
|
+
type: "AttachmentComponents",
|
|
257
|
+
description: "The components to render for the attachment.",
|
|
258
|
+
},
|
|
259
|
+
]}
|
|
260
|
+
/>
|
|
261
|
+
|
|
157
262
|
### If
|
|
158
263
|
|
|
159
264
|
Renders children if a condition is met.
|
|
@@ -104,6 +104,65 @@ Renders all messages. This primitive renders a separate component for each messa
|
|
|
104
104
|
]}
|
|
105
105
|
/>
|
|
106
106
|
|
|
107
|
+
### MessageByIndex
|
|
108
|
+
|
|
109
|
+
Renders a single message at the specified index in the current thread.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
<ThreadPrimitive.MessageByIndex
|
|
113
|
+
index={0}
|
|
114
|
+
components={{
|
|
115
|
+
UserMessage: MyUserMessage,
|
|
116
|
+
AssistantMessage: MyAssistantMessage
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
<ParametersTable
|
|
122
|
+
type="ThreadPrimitive.MessageByIndex.Props"
|
|
123
|
+
parameters={[
|
|
124
|
+
{
|
|
125
|
+
name: "index",
|
|
126
|
+
type: "number",
|
|
127
|
+
required: true,
|
|
128
|
+
description: "The index of the message to render.",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "components",
|
|
132
|
+
type: "MessageComponents",
|
|
133
|
+
description: "The component configuration for rendering the message.",
|
|
134
|
+
children: [
|
|
135
|
+
{
|
|
136
|
+
type: "MessageComponents",
|
|
137
|
+
parameters: [
|
|
138
|
+
{
|
|
139
|
+
name: "Message",
|
|
140
|
+
type: "ComponentType",
|
|
141
|
+
description: "The component to render for each message.",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "UserMessage",
|
|
145
|
+
type: "ComponentType",
|
|
146
|
+
description: "The component to render for user messages.",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "EditComposer",
|
|
150
|
+
type: "ComponentType",
|
|
151
|
+
description:
|
|
152
|
+
"The component to render for user messages that are being edited.",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "AssistantMessage",
|
|
156
|
+
type: "ComponentType",
|
|
157
|
+
description: "The component to render for assistant messages.",
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
]}
|
|
164
|
+
/>
|
|
165
|
+
|
|
107
166
|
### Empty
|
|
108
167
|
|
|
109
168
|
Renders children only when there are no messages.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThreadListPrimitive
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Displays a list of conversation threads.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { ThreadListPrimitive } from "@assistant-ui/react";
|
|
13
|
+
|
|
14
|
+
const ThreadList = () => (
|
|
15
|
+
<ThreadListPrimitive.Root>
|
|
16
|
+
<ThreadListPrimitive.New />
|
|
17
|
+
<ThreadListPrimitive.Items
|
|
18
|
+
components={{
|
|
19
|
+
ThreadListItem: MyThreadListItem
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
</ThreadListPrimitive.Root>
|
|
23
|
+
);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Reference
|
|
27
|
+
|
|
28
|
+
### Root
|
|
29
|
+
|
|
30
|
+
Contains all parts of the thread list.
|
|
31
|
+
|
|
32
|
+
This primitive renders a `<div>` element unless `asChild` is set.
|
|
33
|
+
|
|
34
|
+
<ParametersTable
|
|
35
|
+
type="ThreadListPrimitiveRootProps"
|
|
36
|
+
parameters={[
|
|
37
|
+
{
|
|
38
|
+
name: "asChild",
|
|
39
|
+
},
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
### New
|
|
44
|
+
|
|
45
|
+
A button to create a new thread.
|
|
46
|
+
|
|
47
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
48
|
+
|
|
49
|
+
<ParametersTable
|
|
50
|
+
type="ThreadListPrimitiveNewProps"
|
|
51
|
+
parameters={[
|
|
52
|
+
{
|
|
53
|
+
name: "asChild",
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
### Items
|
|
59
|
+
|
|
60
|
+
Renders all items in the thread list.
|
|
61
|
+
|
|
62
|
+
<ParametersTable
|
|
63
|
+
type="ThreadListPrimitive.Items.Props"
|
|
64
|
+
parameters={[
|
|
65
|
+
{
|
|
66
|
+
name: "archived",
|
|
67
|
+
type: "boolean",
|
|
68
|
+
default: "false",
|
|
69
|
+
description: "Whether to show archived threads instead of active threads.",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "components",
|
|
73
|
+
type: "ThreadListItemComponents",
|
|
74
|
+
required: true,
|
|
75
|
+
description: "The components to render for each thread list item.",
|
|
76
|
+
children: [
|
|
77
|
+
{
|
|
78
|
+
type: "ThreadListItemComponents",
|
|
79
|
+
parameters: [
|
|
80
|
+
{
|
|
81
|
+
name: "ThreadListItem",
|
|
82
|
+
type: "ComponentType",
|
|
83
|
+
required: true,
|
|
84
|
+
description: "The component to render for each thread in the list.",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
]}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
### ItemByIndex
|
|
94
|
+
|
|
95
|
+
Renders a single thread list item at the specified index.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<ThreadListPrimitive.ItemByIndex
|
|
99
|
+
index={0}
|
|
100
|
+
components={{
|
|
101
|
+
ThreadListItem: MyThreadListItem
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
<ParametersTable
|
|
107
|
+
type="ThreadListPrimitive.ItemByIndex.Props"
|
|
108
|
+
parameters={[
|
|
109
|
+
{
|
|
110
|
+
name: "index",
|
|
111
|
+
type: "number",
|
|
112
|
+
required: true,
|
|
113
|
+
description: "The index of the thread list item to render.",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "archived",
|
|
117
|
+
type: "boolean",
|
|
118
|
+
default: "false",
|
|
119
|
+
description: "Whether to render from archived threads instead of active threads.",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "components",
|
|
123
|
+
type: "ThreadListItemComponents",
|
|
124
|
+
required: true,
|
|
125
|
+
description: "The components to render for the thread list item.",
|
|
126
|
+
},
|
|
127
|
+
]}
|
|
128
|
+
/>
|