@assistant-ui/mcp-docs-server 0.1.1
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 +1135 -0
- package/.docs/organized/code-examples/search-agent-for-e-commerce.md +1721 -0
- package/.docs/organized/code-examples/with-ai-sdk.md +1081 -0
- package/.docs/organized/code-examples/with-cloud.md +1164 -0
- package/.docs/organized/code-examples/with-external-store.md +1064 -0
- package/.docs/organized/code-examples/with-ffmpeg.md +1305 -0
- package/.docs/organized/code-examples/with-langgraph.md +1819 -0
- package/.docs/organized/code-examples/with-openai-assistants.md +1175 -0
- package/.docs/organized/code-examples/with-react-hook-form.md +1727 -0
- package/.docs/organized/code-examples/with-vercel-ai-rsc.md +1157 -0
- package/.docs/raw/blog/2024-07-29-hello/index.mdx +65 -0
- package/.docs/raw/blog/2024-09-11/index.mdx +10 -0
- package/.docs/raw/blog/2024-12-15/index.mdx +10 -0
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +129 -0
- package/.docs/raw/docs/about-assistantui.mdx +44 -0
- package/.docs/raw/docs/api-reference/context-providers/AssistantRuntimeProvider.mdx +30 -0
- package/.docs/raw/docs/api-reference/context-providers/TextContentPartProvider.mdx +26 -0
- package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +103 -0
- package/.docs/raw/docs/api-reference/integrations/vercel-ai-sdk.mdx +145 -0
- package/.docs/raw/docs/api-reference/overview.mdx +583 -0
- package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +264 -0
- package/.docs/raw/docs/api-reference/primitives/AssistantModal.mdx +129 -0
- package/.docs/raw/docs/api-reference/primitives/Attachment.mdx +96 -0
- package/.docs/raw/docs/api-reference/primitives/BranchPicker.mdx +87 -0
- package/.docs/raw/docs/api-reference/primitives/Composer.mdx +204 -0
- package/.docs/raw/docs/api-reference/primitives/ContentPart.mdx +173 -0
- package/.docs/raw/docs/api-reference/primitives/Error.mdx +70 -0
- package/.docs/raw/docs/api-reference/primitives/Message.mdx +181 -0
- package/.docs/raw/docs/api-reference/primitives/Thread.mdx +197 -0
- package/.docs/raw/docs/api-reference/primitives/composition.mdx +21 -0
- package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +33 -0
- package/.docs/raw/docs/api-reference/runtimes/AttachmentRuntime.mdx +46 -0
- package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +69 -0
- package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +22 -0
- package/.docs/raw/docs/api-reference/runtimes/MessageRuntime.mdx +49 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadListItemRuntime.mdx +32 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +31 -0
- package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +48 -0
- package/.docs/raw/docs/architecture.mdx +92 -0
- package/.docs/raw/docs/cloud/authorization.mdx +152 -0
- package/.docs/raw/docs/cloud/overview.mdx +55 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +54 -0
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +123 -0
- package/.docs/raw/docs/concepts/architecture.mdx +19 -0
- package/.docs/raw/docs/concepts/runtime-layer.mdx +163 -0
- package/.docs/raw/docs/concepts/why.mdx +9 -0
- package/.docs/raw/docs/copilots/make-assistant-readable.mdx +71 -0
- package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +76 -0
- package/.docs/raw/docs/copilots/make-assistant-tool.mdx +117 -0
- package/.docs/raw/docs/copilots/model-context.mdx +135 -0
- package/.docs/raw/docs/copilots/motivation.mdx +191 -0
- package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +62 -0
- package/.docs/raw/docs/getting-started.mdx +1133 -0
- package/.docs/raw/docs/guides/Attachments.mdx +640 -0
- package/.docs/raw/docs/guides/Branching.mdx +59 -0
- package/.docs/raw/docs/guides/Editing.mdx +56 -0
- package/.docs/raw/docs/guides/Speech.mdx +43 -0
- package/.docs/raw/docs/guides/ToolUI.mdx +663 -0
- package/.docs/raw/docs/guides/Tools.mdx +496 -0
- package/.docs/raw/docs/index.mdx +7 -0
- package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +85 -0
- package/.docs/raw/docs/legacy/styled/Decomposition.mdx +633 -0
- package/.docs/raw/docs/legacy/styled/Markdown.mdx +86 -0
- package/.docs/raw/docs/legacy/styled/Scrollbar.mdx +71 -0
- package/.docs/raw/docs/legacy/styled/Thread.mdx +84 -0
- package/.docs/raw/docs/legacy/styled/ThreadWidth.mdx +21 -0
- package/.docs/raw/docs/mcp-docs-server.mdx +324 -0
- package/.docs/raw/docs/migrations/deprecation-policy.mdx +41 -0
- package/.docs/raw/docs/migrations/v0-7.mdx +188 -0
- package/.docs/raw/docs/migrations/v0-8.mdx +160 -0
- package/.docs/raw/docs/migrations/v0-9.mdx +75 -0
- package/.docs/raw/docs/react-compatibility.mdx +208 -0
- package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +226 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +195 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +138 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +136 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +1624 -0
- package/.docs/raw/docs/runtimes/custom/local.mdx +1185 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +60 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +320 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +11 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +28 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +120 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +336 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +385 -0
- package/.docs/raw/docs/runtimes/langserve.mdx +126 -0
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +218 -0
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +17 -0
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +196 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +222 -0
- package/.docs/raw/docs/ui/AssistantModal.mdx +46 -0
- package/.docs/raw/docs/ui/AssistantSidebar.mdx +42 -0
- package/.docs/raw/docs/ui/Attachment.mdx +82 -0
- package/.docs/raw/docs/ui/Markdown.mdx +72 -0
- package/.docs/raw/docs/ui/Mermaid.mdx +79 -0
- package/.docs/raw/docs/ui/Scrollbar.mdx +59 -0
- package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +253 -0
- package/.docs/raw/docs/ui/Thread.mdx +47 -0
- package/.docs/raw/docs/ui/ThreadList.mdx +49 -0
- package/.docs/raw/docs/ui/ToolFallback.mdx +64 -0
- package/.docs/raw/docs/ui/primitives/Thread.mdx +197 -0
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/chunk-C7O7EFKU.js +38 -0
- package/dist/chunk-CZCDQ3YH.js +420 -0
- package/dist/index.js +1 -0
- package/dist/prepare-docs/prepare.js +199 -0
- package/dist/stdio.js +8 -0
- package/package.json +43 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ComposerPrimitive
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The user interface to add new messages or edit existing ones.
|
|
6
|
+
|
|
7
|
+
import { Callout } from "fumadocs-ui/components/callout";
|
|
8
|
+
|
|
9
|
+
import { ParametersTable, KeyboardTable } from "@/components/docs";
|
|
10
|
+
import { Code } from "@radix-ui/themes";
|
|
11
|
+
|
|
12
|
+
<Callout>
|
|
13
|
+
**Dual Use!** A Composer placed directly inside a `Thread` will compose new
|
|
14
|
+
messages. A Composer placed inside a `Message` will edit that message.
|
|
15
|
+
</Callout>
|
|
16
|
+
|
|
17
|
+
## Anatomy
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { ComposerPrimitive } from "@assistant-ui/react";
|
|
21
|
+
|
|
22
|
+
// creating a new message
|
|
23
|
+
const Composer = () => (
|
|
24
|
+
<ComposerPrimitive.Root>
|
|
25
|
+
<ComposerPrimitive.Attachments />
|
|
26
|
+
<ComposerPrimitive.AddAttachment />
|
|
27
|
+
<ComposerPrimitive.Input />
|
|
28
|
+
<ComposerPrimitive.Send />
|
|
29
|
+
</ComposerPrimitive.Root>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// editing an existing message
|
|
33
|
+
const EditComposer = () => (
|
|
34
|
+
<ComposerPrimitive.Root>
|
|
35
|
+
<ComposerPrimitive.Input />
|
|
36
|
+
<ComposerPrimitive.Send />
|
|
37
|
+
<ComposerPrimitive.Cancel />
|
|
38
|
+
</ComposerPrimitive.Root>
|
|
39
|
+
);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API Reference
|
|
43
|
+
|
|
44
|
+
### Root
|
|
45
|
+
|
|
46
|
+
Containts all parts of the composer.
|
|
47
|
+
|
|
48
|
+
This primitive renders a `<form>` element unless `asChild` is set.
|
|
49
|
+
|
|
50
|
+
<ParametersTable
|
|
51
|
+
type="ComposerRootProps"
|
|
52
|
+
parameters={[
|
|
53
|
+
{
|
|
54
|
+
name: "asChild",
|
|
55
|
+
},
|
|
56
|
+
]}
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
### Input
|
|
60
|
+
|
|
61
|
+
The text input field for the user to type a new message.
|
|
62
|
+
|
|
63
|
+
This primitive renders a `<textarea>` element unless `asChild` is set.
|
|
64
|
+
|
|
65
|
+
<ParametersTable
|
|
66
|
+
type="ComposerPrimitiveInputProps"
|
|
67
|
+
parameters={[
|
|
68
|
+
{
|
|
69
|
+
name: "asChild",
|
|
70
|
+
},
|
|
71
|
+
]}
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
#### Keyboard Shortcuts
|
|
75
|
+
|
|
76
|
+
<KeyboardTable
|
|
77
|
+
data={[
|
|
78
|
+
{
|
|
79
|
+
keys: ["Enter"],
|
|
80
|
+
description: "Sends the message.",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
keys: ["Escape"],
|
|
84
|
+
description: "Sends a cancel action.",
|
|
85
|
+
},
|
|
86
|
+
]}
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
### Send
|
|
90
|
+
|
|
91
|
+
The button to send the message.
|
|
92
|
+
|
|
93
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
94
|
+
|
|
95
|
+
<ParametersTable
|
|
96
|
+
type="ComposerPrimitiveSendProps"
|
|
97
|
+
parameters={[
|
|
98
|
+
{
|
|
99
|
+
name: "asChild",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "multiple",
|
|
103
|
+
type: "boolean | undefined",
|
|
104
|
+
description: "Allow selecting multiple attachments at the same time.",
|
|
105
|
+
default: "true",
|
|
106
|
+
},
|
|
107
|
+
]}
|
|
108
|
+
/>
|
|
109
|
+
|
|
110
|
+
### Cancel
|
|
111
|
+
|
|
112
|
+
Sends a cancel action.
|
|
113
|
+
|
|
114
|
+
In edit composers, this action exits the edit mode.
|
|
115
|
+
In thread composers, this action stops the current run.
|
|
116
|
+
|
|
117
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
118
|
+
|
|
119
|
+
<ParametersTable
|
|
120
|
+
type="ComposerPrimitiveCancelProps"
|
|
121
|
+
parameters={[
|
|
122
|
+
{
|
|
123
|
+
name: "asChild",
|
|
124
|
+
},
|
|
125
|
+
]}
|
|
126
|
+
/>
|
|
127
|
+
|
|
128
|
+
### Attachments
|
|
129
|
+
|
|
130
|
+
Renders attachments. This primitive renders a separate component for each attachment.
|
|
131
|
+
|
|
132
|
+
<ParametersTable
|
|
133
|
+
type="ComposerPrimitiveAttachmentsProps"
|
|
134
|
+
parameters={[
|
|
135
|
+
{
|
|
136
|
+
name: "components",
|
|
137
|
+
type: "ComposerAttachmentsComponents",
|
|
138
|
+
description: "The component to render for each attachment.",
|
|
139
|
+
children: [
|
|
140
|
+
{
|
|
141
|
+
type: "ComposerPrimitiveAttachmentsProps['components']",
|
|
142
|
+
parameters: [
|
|
143
|
+
{
|
|
144
|
+
name: "Image",
|
|
145
|
+
type: "ComponentType",
|
|
146
|
+
description: "The component to render for each image attachment.",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "Document",
|
|
150
|
+
type: "ComponentType",
|
|
151
|
+
description:
|
|
152
|
+
"The component to render for each document attachment.",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "File",
|
|
156
|
+
type: "ComponentType",
|
|
157
|
+
description: "The component to render for each file attachment.",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "Fallback",
|
|
161
|
+
type: "ComponentType",
|
|
162
|
+
description: "The component to render for each attachment type.",
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
]}
|
|
169
|
+
/>
|
|
170
|
+
|
|
171
|
+
### AddAttachment
|
|
172
|
+
|
|
173
|
+
Renders a button to add an attachment.
|
|
174
|
+
|
|
175
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
176
|
+
|
|
177
|
+
<ParametersTable
|
|
178
|
+
type="ComposerPrimitiveAddAttachmentProps"
|
|
179
|
+
parameters={[
|
|
180
|
+
{
|
|
181
|
+
name: "asChild",
|
|
182
|
+
},
|
|
183
|
+
]}
|
|
184
|
+
/>
|
|
185
|
+
|
|
186
|
+
### If
|
|
187
|
+
|
|
188
|
+
Renders children if a condition is met.
|
|
189
|
+
|
|
190
|
+
<ParametersTable
|
|
191
|
+
type="UseComposerIfProps"
|
|
192
|
+
parameters={[
|
|
193
|
+
{
|
|
194
|
+
name: "editing",
|
|
195
|
+
required: false,
|
|
196
|
+
type: "boolean | undefined",
|
|
197
|
+
description: "Render children if the message is being edited.",
|
|
198
|
+
},
|
|
199
|
+
]}
|
|
200
|
+
/>
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
<Composer.If editing>{/* rendered if message is being edited */}</Composer.If>
|
|
204
|
+
```
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ContentPartPrimitive
|
|
3
|
+
description: A part of a message's content. Content parts may be text, image, tool call or UI elements.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { ParametersTable } from "@/components/docs";
|
|
7
|
+
import {
|
|
8
|
+
ContentPartRuntime,
|
|
9
|
+
TextContentPartState,
|
|
10
|
+
AudioContentPartState,
|
|
11
|
+
ToolCallContentPartState,
|
|
12
|
+
} from "@/generated/typeDocs";
|
|
13
|
+
|
|
14
|
+
Each message can have any number of content parts.
|
|
15
|
+
Content parts are usually one of text, reasoning, audio or tool-call.
|
|
16
|
+
|
|
17
|
+
## Content Part Types
|
|
18
|
+
|
|
19
|
+
### Text
|
|
20
|
+
|
|
21
|
+
Standard text content, used for both user and assistant messages.
|
|
22
|
+
|
|
23
|
+
### Reasoning
|
|
24
|
+
|
|
25
|
+
Exposes the assistant's reasoning process, showing how it arrived at its responses. This is typically used only in assistant messages.
|
|
26
|
+
|
|
27
|
+
### Audio
|
|
28
|
+
|
|
29
|
+
Audio content that can be played back.
|
|
30
|
+
|
|
31
|
+
### Tool Call
|
|
32
|
+
|
|
33
|
+
Interactive elements that represent tool operations.
|
|
34
|
+
|
|
35
|
+
## Anatomy
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { ContentPartPrimitive } from "@assistant-ui/react";
|
|
39
|
+
|
|
40
|
+
const TextContentPart = () => {
|
|
41
|
+
return <ContentPartPrimitive.Text />;
|
|
42
|
+
};
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Primitives
|
|
46
|
+
|
|
47
|
+
### Plain Text
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { ContentPartPrimitive } from "@assistant/react";
|
|
51
|
+
|
|
52
|
+
<ContentPartPrimitive.Text />;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Markdown Text
|
|
56
|
+
|
|
57
|
+
Renders the message's text as Markdown.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
|
|
61
|
+
|
|
62
|
+
<MarkdownTextPrimitive />;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Audio
|
|
66
|
+
|
|
67
|
+
Coming soon.
|
|
68
|
+
|
|
69
|
+
### InProgress
|
|
70
|
+
|
|
71
|
+
Renders children only if the content part is in progress.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { ContentPartPrimitive } from "@assistant/react";
|
|
75
|
+
|
|
76
|
+
<ContentPartPrimitive.InProgress>
|
|
77
|
+
<LoadingIndicator />
|
|
78
|
+
</ContentPartPrimitive.InProgress>;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Tool UI
|
|
82
|
+
|
|
83
|
+
You can map tool calls to UI components. We provide a few utility functions to make this easier, such as `makeAssistantToolUI`.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
const MyWeatherToolUI = makeAssistantToolUI({
|
|
87
|
+
toolName: "get_weather",
|
|
88
|
+
render: function MyWeatherToolUI({ args, result }) {
|
|
89
|
+
return (
|
|
90
|
+
<div className="mb-4 flex flex-col items-center">
|
|
91
|
+
<pre className="whitespace-pre-wrap break-all text-center">
|
|
92
|
+
get_weather({JSON.stringify(args)})
|
|
93
|
+
</pre>
|
|
94
|
+
{"result" in result && (
|
|
95
|
+
<pre className="whitespace-pre-wrap break-all text-center">
|
|
96
|
+
{JSON.stringify(result.result)}
|
|
97
|
+
</pre>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Context Provider
|
|
106
|
+
|
|
107
|
+
Content part context is provided by `MessagePrimitive.Content` or `TextContentPartProvider`
|
|
108
|
+
|
|
109
|
+
### MessagePrimitive.Content
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { MessagePrimitive } from "@assistant/react";
|
|
113
|
+
|
|
114
|
+
<MessagePrimitive.Content
|
|
115
|
+
components={{
|
|
116
|
+
Text: MyText,
|
|
117
|
+
Reasoning: MyReasoning,
|
|
118
|
+
Audio: MyAudio,
|
|
119
|
+
tools: {
|
|
120
|
+
by_name: {
|
|
121
|
+
get_weather: MyWeatherToolUI,
|
|
122
|
+
},
|
|
123
|
+
Fallback: MyFallbackToolUI,
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
/>;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### TextContentPartProvider
|
|
130
|
+
|
|
131
|
+
This is a helper context provider to allow you to reuse the content part components outside a message content part.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { TextContentPartProvider } from "@assistant-ui/react";
|
|
135
|
+
|
|
136
|
+
<TextContentPartProvider text="Hello world" isRunning={false}>
|
|
137
|
+
<ContentPart.Text />
|
|
138
|
+
</TextContentPartProvider>;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Runtime API
|
|
142
|
+
|
|
143
|
+
### `useContentPartRuntime`
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { useContentPartRuntime } from "@assistant-ui/react";
|
|
147
|
+
|
|
148
|
+
const contentPartRuntime = useContentPartRuntime();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
<ParametersTable {...ContentPartRuntime} />
|
|
152
|
+
|
|
153
|
+
### `useContentPart`
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { useContentPart } from "@assistant-ui/react";
|
|
157
|
+
|
|
158
|
+
const contentPart = useContentPart();
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
<ParametersTable {...TextContentPartState} />
|
|
162
|
+
<ParametersTable {...AudioContentPartState} />
|
|
163
|
+
<ParametersTable {...ToolCallContentPartState} />
|
|
164
|
+
|
|
165
|
+
### `useContentPartText`
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { useContentPartText } from "@assistant-ui/react";
|
|
169
|
+
|
|
170
|
+
const contentPartText = useContentPartText();
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
<ParametersTable {...TextContentPartState} />
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ErrorPrimitive
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
A component for displaying error messages in the UI.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { ErrorPrimitive } from "@assistant-ui/react";
|
|
13
|
+
|
|
14
|
+
const ErrorDisplay = () => (
|
|
15
|
+
<ErrorPrimitive.Root>
|
|
16
|
+
<ErrorPrimitive.Message />
|
|
17
|
+
</ErrorPrimitive.Root>
|
|
18
|
+
);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API Reference
|
|
22
|
+
|
|
23
|
+
### Root
|
|
24
|
+
|
|
25
|
+
Contains all parts of the error display. Renders a `<div>` element with `role="alert"`.
|
|
26
|
+
|
|
27
|
+
<ParametersTable
|
|
28
|
+
type="ErrorPrimitiveRootProps"
|
|
29
|
+
parameters={[
|
|
30
|
+
{
|
|
31
|
+
name: "asChild",
|
|
32
|
+
type: "boolean",
|
|
33
|
+
description: "Change the component to the HTML tag or custom component of the only child.",
|
|
34
|
+
},
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
### Message
|
|
39
|
+
|
|
40
|
+
Displays the error message. By default, it shows the error from the message context if available, or you can provide custom content.
|
|
41
|
+
|
|
42
|
+
<ParametersTable
|
|
43
|
+
type="ErrorPrimitiveMessageProps"
|
|
44
|
+
parameters={[
|
|
45
|
+
{
|
|
46
|
+
name: "children",
|
|
47
|
+
type: "ReactNode",
|
|
48
|
+
description: "Optional custom content to display instead of the default error message.",
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
The ErrorPrimitive is typically used within a MessagePrimitive.Error component to display error states in messages:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { MessagePrimitive, ErrorPrimitive } from "@assistant-ui/react";
|
|
59
|
+
|
|
60
|
+
const MessageWithError = () => (
|
|
61
|
+
<MessagePrimitive.Root>
|
|
62
|
+
<MessagePrimitive.Content />
|
|
63
|
+
<MessagePrimitive.Error>
|
|
64
|
+
<ErrorPrimitive.Root>
|
|
65
|
+
<ErrorPrimitive.Message />
|
|
66
|
+
</ErrorPrimitive.Root>
|
|
67
|
+
</MessagePrimitive.Error>
|
|
68
|
+
</MessagePrimitive.Root>
|
|
69
|
+
);
|
|
70
|
+
```
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MessagePrimitive
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
A single message in a conversation. Messages may consist of multiple parts.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { MessagePrimitive } from "@assistant-ui/react";
|
|
13
|
+
|
|
14
|
+
const UserMessage = () => (
|
|
15
|
+
<MessagePrimitive.Root>
|
|
16
|
+
User: <MessagePrimitive.Content />
|
|
17
|
+
<BranchPicker />
|
|
18
|
+
<ActionBar />
|
|
19
|
+
</MessagePrimitive.Root>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const AssistantMessage = () => (
|
|
23
|
+
<MessagePrimitive.Root>
|
|
24
|
+
Assistant: <MessagePrimitive.Content />
|
|
25
|
+
<BranchPicker />
|
|
26
|
+
<ActionBar />
|
|
27
|
+
</MessagePrimitive.Root>
|
|
28
|
+
);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API Reference
|
|
32
|
+
|
|
33
|
+
### Root
|
|
34
|
+
|
|
35
|
+
Containts all parts of the message.
|
|
36
|
+
|
|
37
|
+
This primitive renders a `<div>` element unless `asChild` is set.
|
|
38
|
+
|
|
39
|
+
<ParametersTable
|
|
40
|
+
type="MessagePrimitiveRootProps"
|
|
41
|
+
parameters={[
|
|
42
|
+
{
|
|
43
|
+
name: "asChild",
|
|
44
|
+
},
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
### Content
|
|
49
|
+
|
|
50
|
+
The content of the message. This renders a separate component for each content part of the message.
|
|
51
|
+
|
|
52
|
+
<ParametersTable
|
|
53
|
+
type="MessagePrimitiveContentProps"
|
|
54
|
+
parameters={[
|
|
55
|
+
{
|
|
56
|
+
name: "components",
|
|
57
|
+
required: false,
|
|
58
|
+
type: "ContentPartComponents",
|
|
59
|
+
description: "The components to render for each content part.",
|
|
60
|
+
children: [
|
|
61
|
+
{
|
|
62
|
+
type: "ContentPartComponents",
|
|
63
|
+
parameters: [
|
|
64
|
+
{
|
|
65
|
+
name: "Text",
|
|
66
|
+
type: "TextContentPartComponent",
|
|
67
|
+
description:
|
|
68
|
+
"The component to render for each text content part.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "Image",
|
|
72
|
+
type: "ImageContentPartComponent",
|
|
73
|
+
description:
|
|
74
|
+
"The component to render for each image content part.",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "Source",
|
|
78
|
+
type: "SourceContentPartComponent",
|
|
79
|
+
description:
|
|
80
|
+
"The component to render for each source content part.",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "File",
|
|
84
|
+
type: "FileContentPartComponent",
|
|
85
|
+
description:
|
|
86
|
+
"The component to render for each file content part.",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "Unstable_Audio",
|
|
90
|
+
type: "Unstable_AudioContentPartComponent",
|
|
91
|
+
description:
|
|
92
|
+
"The component to render for each audio content part.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "tools",
|
|
96
|
+
type: "object",
|
|
97
|
+
description:
|
|
98
|
+
"The component to render for each tool call content part.",
|
|
99
|
+
children: [
|
|
100
|
+
{
|
|
101
|
+
parameters: [
|
|
102
|
+
{
|
|
103
|
+
name: "by_name",
|
|
104
|
+
type: "Record<string, ToolCallContentPartComponent>",
|
|
105
|
+
description:
|
|
106
|
+
"The components to render for each tool call content part.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "Fallback",
|
|
110
|
+
type: "ToolCallContentPartComponent",
|
|
111
|
+
description:
|
|
112
|
+
"The fallback component to render for tool call content parts.",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
]}
|
|
123
|
+
/>
|
|
124
|
+
|
|
125
|
+
### If
|
|
126
|
+
|
|
127
|
+
Renders children if a condition is met.
|
|
128
|
+
|
|
129
|
+
<ParametersTable
|
|
130
|
+
type="UseMessageIfProps"
|
|
131
|
+
parameters={[
|
|
132
|
+
{
|
|
133
|
+
name: "user",
|
|
134
|
+
type: "boolean | undefined",
|
|
135
|
+
description: "Render children if the message is from the user.",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "assistant",
|
|
139
|
+
type: "boolean | undefined",
|
|
140
|
+
description: "Render children if the message is from the assistant.",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "hasBranches",
|
|
144
|
+
type: "boolean | undefined",
|
|
145
|
+
description: "Render children if the message has branches.",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "copied",
|
|
149
|
+
type: "boolean | undefined",
|
|
150
|
+
description: "Render children if the message is copied.",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "lastOrHover",
|
|
154
|
+
type: "boolean | undefined",
|
|
155
|
+
description:
|
|
156
|
+
"Render children if the message is the last or hovered over.",
|
|
157
|
+
},
|
|
158
|
+
]}
|
|
159
|
+
/>
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
<Message.If user>
|
|
163
|
+
{/* rendered if message is from the user */}
|
|
164
|
+
</Message.If>
|
|
165
|
+
<Message.If assistant>
|
|
166
|
+
{/* rendered if message is from the assistant */}
|
|
167
|
+
</Message.If>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Error
|
|
171
|
+
|
|
172
|
+
Renders children only if the message has an error status.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<MessagePrimitive.Error>
|
|
176
|
+
{/* rendered if the message has an error status */}
|
|
177
|
+
<ErrorPrimitive.Root>
|
|
178
|
+
<ErrorPrimitive.Message />
|
|
179
|
+
</ErrorPrimitive.Root>
|
|
180
|
+
</MessagePrimitive.Error>
|
|
181
|
+
```
|