@assistant-ui/mcp-docs-server 0.1.19 → 0.1.21
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-ag-ui.md +172 -1633
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +42 -1640
- package/.docs/organized/code-examples/with-assistant-transport.md +40 -1743
- package/.docs/organized/code-examples/with-cloud.md +71 -1745
- package/.docs/organized/code-examples/with-custom-thread-list.md +87 -1723
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +70 -1637
- package/.docs/organized/code-examples/with-external-store.md +67 -1624
- package/.docs/organized/code-examples/with-ffmpeg.md +71 -1629
- package/.docs/organized/code-examples/with-langgraph.md +95 -1893
- package/.docs/organized/code-examples/with-parent-id-grouping.md +57 -1654
- package/.docs/organized/code-examples/with-react-hook-form.md +220 -2163
- package/.docs/organized/code-examples/with-react-router.md +66 -1318
- package/.docs/organized/code-examples/with-store.md +31 -31
- package/.docs/organized/code-examples/with-tanstack.md +77 -861
- package/.docs/organized/code-examples/with-tap-runtime.md +812 -0
- package/.docs/raw/docs/(docs)/cli.mdx +66 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -1
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -1
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +4 -4
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +3 -3
- package/.docs/raw/docs/(docs)/devtools.mdx +0 -1
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +2 -3
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +117 -117
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +296 -0
- package/.docs/raw/docs/(docs)/guides/tools.mdx +336 -513
- package/.docs/raw/docs/(docs)/index.mdx +33 -410
- package/.docs/raw/docs/(docs)/installation.mdx +450 -0
- package/.docs/raw/docs/(docs)/llm.mdx +209 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +48 -3
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +9 -3
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +20 -52
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +16 -39
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +49 -50
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +3 -11
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -3
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +5 -16
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +152 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +28 -40
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +2 -3
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +1 -2
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +5 -5
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -1
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -1
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +207 -33
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -1
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +118 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +198 -0
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +3 -3
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +5 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -11
- package/.docs/raw/docs/runtimes/custom/local.mdx +43 -36
- package/.docs/raw/docs/runtimes/data-stream.mdx +35 -3
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -2
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -1
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -1
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -1
- package/.docs/raw/docs/ui/accordion.mdx +259 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -3
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -3
- package/.docs/raw/docs/ui/attachment.mdx +0 -2
- package/.docs/raw/docs/ui/badge.mdx +138 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +279 -0
- package/.docs/raw/docs/ui/file.mdx +152 -0
- package/.docs/raw/docs/ui/image.mdx +100 -0
- package/.docs/raw/docs/ui/markdown.mdx +0 -1
- package/.docs/raw/docs/ui/mermaid.mdx +0 -1
- package/.docs/raw/docs/ui/model-selector.mdx +224 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +4 -5
- package/.docs/raw/docs/ui/reasoning.mdx +6 -5
- package/.docs/raw/docs/ui/scrollbar.mdx +26 -9
- package/.docs/raw/docs/ui/select.mdx +245 -0
- package/.docs/raw/docs/ui/sources.mdx +6 -5
- package/.docs/raw/docs/ui/streamdown.mdx +348 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +8 -63
- package/.docs/raw/docs/ui/tabs.mdx +259 -0
- package/.docs/raw/docs/ui/thread-list.mdx +98 -16
- package/.docs/raw/docs/ui/thread.mdx +57 -73
- package/.docs/raw/docs/ui/tool-fallback.mdx +0 -1
- package/.docs/raw/docs/ui/tool-group.mdx +1 -3
- package/README.md +3 -3
- package/package.json +4 -4
- package/src/tools/tests/examples.test.ts +1 -1
- package/.docs/raw/docs/(docs)/about-assistantui.mdx +0 -54
- package/.docs/raw/docs/(docs)/mcp-docs-server.mdx +0 -321
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +0 -219
|
@@ -5,7 +5,6 @@ description: Hooks for connecting to data stream protocol endpoints and Assistan
|
|
|
5
5
|
|
|
6
6
|
Data Stream protocol integration for assistant-ui.
|
|
7
7
|
|
|
8
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
9
8
|
|
|
10
9
|
## API Reference
|
|
11
10
|
|
|
@@ -157,7 +156,12 @@ const MyRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
|
|
|
157
156
|
|
|
158
157
|
### `toLanguageModelMessages`
|
|
159
158
|
|
|
160
|
-
Convert assistant-ui messages to
|
|
159
|
+
Convert assistant-ui messages to AI SDK's `LanguageModelV2Message` format.
|
|
160
|
+
|
|
161
|
+
<Callout type="info">
|
|
162
|
+
For custom integrations, consider using `toGenericMessages` from `assistant-stream` instead.
|
|
163
|
+
This function is specific to the AI SDK format.
|
|
164
|
+
</Callout>
|
|
161
165
|
|
|
162
166
|
```tsx
|
|
163
167
|
import { toLanguageModelMessages } from "@assistant-ui/react-data-stream";
|
|
@@ -192,4 +196,45 @@ const languageModelMessages = toLanguageModelMessages(messages, {
|
|
|
192
196
|
],
|
|
193
197
|
},
|
|
194
198
|
]}
|
|
195
|
-
/>
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Framework-Agnostic Utilities
|
|
204
|
+
|
|
205
|
+
For custom integrations that don't use the AI SDK, use these utilities from `assistant-stream`:
|
|
206
|
+
|
|
207
|
+
### `toGenericMessages`
|
|
208
|
+
|
|
209
|
+
Convert thread messages to a framework-agnostic format.
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { toGenericMessages } from "assistant-stream";
|
|
213
|
+
|
|
214
|
+
const genericMessages = toGenericMessages(messages);
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Returns an array of `GenericMessage` which can be one of:
|
|
218
|
+
- `{ role: "system"; content: string }`
|
|
219
|
+
- `{ role: "user"; content: (GenericTextPart | GenericFilePart)[] }`
|
|
220
|
+
- `{ role: "assistant"; content: (GenericTextPart | GenericToolCallPart)[] }`
|
|
221
|
+
- `{ role: "tool"; content: GenericToolResultPart[] }`
|
|
222
|
+
|
|
223
|
+
### `toToolsJSONSchema`
|
|
224
|
+
|
|
225
|
+
Convert tool definitions to JSON Schema format.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
import { toToolsJSONSchema } from "assistant-stream";
|
|
229
|
+
|
|
230
|
+
const toolSchemas = toToolsJSONSchema(tools);
|
|
231
|
+
// Returns: Record<string, { description?: string; parameters: JSONSchema7 }>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
By default, filters out disabled tools and backend-only tools. Use the `filter` option to customize:
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
const allTools = toToolsJSONSchema(tools, {
|
|
238
|
+
filter: () => true, // Include all tools
|
|
239
|
+
});
|
|
240
|
+
```
|
|
@@ -5,7 +5,6 @@ description: Vercel AI SDK v5 integration with chat runtime hooks and transport
|
|
|
5
5
|
|
|
6
6
|
Vercel AI SDK integration for assistant-ui.
|
|
7
7
|
|
|
8
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
9
8
|
|
|
10
9
|
<Callout type="info">
|
|
11
10
|
This package provides integration with AI SDK v5. For AI SDK v4, see the [AI
|
|
@@ -35,7 +35,13 @@ export const contextColors = {
|
|
|
35
35
|
|
|
36
36
|
- [`useDataStreamRuntime`](#use-data-stream-runtime)
|
|
37
37
|
- [`useCloudRuntime`](#use-cloud-runtime)
|
|
38
|
-
- [`toLanguageModelMessages`](#to-language-model-messages)
|
|
38
|
+
- [`toLanguageModelMessages`](#to-language-model-messages) (AI SDK specific)
|
|
39
|
+
|
|
40
|
+
### assistant-stream (Framework-Agnostic)
|
|
41
|
+
|
|
42
|
+
- [`toGenericMessages`](#to-generic-messages)
|
|
43
|
+
- [`toToolsJSONSchema`](#to-tools-json-schema)
|
|
44
|
+
- [`GenericMessage`](#generic-message)
|
|
39
45
|
|
|
40
46
|
### LangGraph
|
|
41
47
|
|
|
@@ -239,7 +245,7 @@ A conversation thread.
|
|
|
239
245
|
tooltip="Displayed when the thread is empty"
|
|
240
246
|
/>
|
|
241
247
|
<Component
|
|
242
|
-
name="
|
|
248
|
+
name="AuiIf"
|
|
243
249
|
docsLink="#assistant-if"
|
|
244
250
|
tooltip="Conditional rendering based on assistant state"
|
|
245
251
|
/>
|
|
@@ -383,7 +389,7 @@ Manages the state and actions for individual messages
|
|
|
383
389
|
tooltip="Displays attachments in the message"
|
|
384
390
|
/>
|
|
385
391
|
<Component
|
|
386
|
-
name="
|
|
392
|
+
name="AuiIf"
|
|
387
393
|
docsLink="#assistant-if"
|
|
388
394
|
tooltip="Conditional rendering based on assistant state"
|
|
389
395
|
/>
|
|
@@ -4,9 +4,6 @@ title: ActionBarMorePrimitive
|
|
|
4
4
|
|
|
5
5
|
A dropdown menu for additional actions that don't fit in the main action bar.
|
|
6
6
|
|
|
7
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
8
|
-
import { DataAttributesTable } from "@/components/docs/tables/DataAttributesTable";
|
|
9
|
-
import { Code } from "@radix-ui/themes";
|
|
10
7
|
|
|
11
8
|
## Anatomy
|
|
12
9
|
|
|
@@ -97,18 +94,10 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
97
94
|
]}
|
|
98
95
|
/>
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
values: <Code>"open" | "closed"</Code>,
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
attribute: "[data-disabled]",
|
|
108
|
-
values: "Present when disabled",
|
|
109
|
-
},
|
|
110
|
-
]}
|
|
111
|
-
/>
|
|
97
|
+
| Data attribute | Values |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `[data-state]` | `"open" \| "closed"` |
|
|
100
|
+
| `[data-disabled]` | Present when disabled |
|
|
112
101
|
|
|
113
102
|
### Content
|
|
114
103
|
|
|
@@ -154,22 +143,11 @@ This primitive renders a `<div>` element unless `asChild` is set.
|
|
|
154
143
|
]}
|
|
155
144
|
/>
|
|
156
145
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
attribute: "[data-side]",
|
|
165
|
-
values: <Code>"top" | "right" | "bottom" | "left"</Code>,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
attribute: "[data-align]",
|
|
169
|
-
values: <Code>"start" | "center" | "end"</Code>,
|
|
170
|
-
},
|
|
171
|
-
]}
|
|
172
|
-
/>
|
|
146
|
+
| Data attribute | Values |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `[data-state]` | `"open" \| "closed"` |
|
|
149
|
+
| `[data-side]` | `"top" \| "right" \| "bottom" \| "left"` |
|
|
150
|
+
| `[data-align]` | `"start" \| "center" \| "end"` |
|
|
173
151
|
|
|
174
152
|
Refer to Radix UI's Documentation for [DropdownMenu.Content](https://www.radix-ui.com/primitives/docs/components/dropdown-menu#content) for more details.
|
|
175
153
|
|
|
@@ -205,18 +183,10 @@ This primitive renders a `<div>` element unless `asChild` is set.
|
|
|
205
183
|
]}
|
|
206
184
|
/>
|
|
207
185
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
values: "Present when disabled",
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
attribute: "[data-highlighted]",
|
|
216
|
-
values: "Present when highlighted",
|
|
217
|
-
},
|
|
218
|
-
]}
|
|
219
|
-
/>
|
|
186
|
+
| Data attribute | Values |
|
|
187
|
+
| --- | --- |
|
|
188
|
+
| `[data-disabled]` | Present when disabled |
|
|
189
|
+
| `[data-highlighted]` | Present when highlighted |
|
|
220
190
|
|
|
221
191
|
Refer to Radix UI's Documentation for [DropdownMenu.Item](https://www.radix-ui.com/primitives/docs/components/dropdown-menu#item) for more details.
|
|
222
192
|
|
|
@@ -284,22 +254,22 @@ You can combine the dropdown menu items with action hooks from ActionBarPrimitiv
|
|
|
284
254
|
import {
|
|
285
255
|
ActionBarPrimitive,
|
|
286
256
|
ActionBarMorePrimitive,
|
|
287
|
-
|
|
288
|
-
|
|
257
|
+
useAui,
|
|
258
|
+
useAuiState,
|
|
289
259
|
} from "@assistant-ui/react";
|
|
290
260
|
import { useCallback } from "react";
|
|
291
261
|
|
|
292
262
|
const useEditAction = () => {
|
|
293
|
-
const
|
|
294
|
-
const disabled =
|
|
295
|
-
const callback = useCallback(() =>
|
|
263
|
+
const aui = useAui();
|
|
264
|
+
const disabled = useAuiState(({ composer }) => composer.isEditing);
|
|
265
|
+
const callback = useCallback(() => aui.composer().beginEdit(), [aui]);
|
|
296
266
|
if (disabled) return null;
|
|
297
267
|
return callback;
|
|
298
268
|
};
|
|
299
269
|
|
|
300
270
|
const useSpeakAction = () => {
|
|
301
|
-
const
|
|
302
|
-
return useCallback(() =>
|
|
271
|
+
const aui = useAui();
|
|
272
|
+
return useCallback(() => aui.message().speak(), [aui]);
|
|
303
273
|
};
|
|
304
274
|
|
|
305
275
|
const MoreActionsWithHooks = () => {
|
|
@@ -323,5 +293,3 @@ const MoreActionsWithHooks = () => {
|
|
|
323
293
|
);
|
|
324
294
|
};
|
|
325
295
|
```
|
|
326
|
-
|
|
327
|
-
|
|
@@ -5,9 +5,6 @@ description: Buttons for message actions like copy, edit, reload, speak, and fee
|
|
|
5
5
|
|
|
6
6
|
Buttons to interact with the message.
|
|
7
7
|
|
|
8
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
9
|
-
import { DataAttributesTable } from "@/components/docs/tables/DataAttributesTable";
|
|
10
|
-
import { Code } from "@radix-ui/themes";
|
|
11
8
|
|
|
12
9
|
## Anatomy
|
|
13
10
|
|
|
@@ -93,14 +90,9 @@ This primitive renders a `<div>` element unless `asChild` is set.
|
|
|
93
90
|
]}
|
|
94
91
|
/>
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
attribute: "[data-floating]",
|
|
100
|
-
values: "Present when floating",
|
|
101
|
-
},
|
|
102
|
-
]}
|
|
103
|
-
/>
|
|
93
|
+
| Data attribute | Values |
|
|
94
|
+
| --- | --- |
|
|
95
|
+
| `[data-floating]` | Present when floating |
|
|
104
96
|
|
|
105
97
|
### Edit
|
|
106
98
|
|
|
@@ -154,14 +146,9 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
154
146
|
]}
|
|
155
147
|
/>
|
|
156
148
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
attribute: "[data-copied]",
|
|
161
|
-
values: "Present when the message was recently copied.",
|
|
162
|
-
},
|
|
163
|
-
]}
|
|
164
|
-
/>
|
|
149
|
+
| Data attribute | Values |
|
|
150
|
+
| --- | --- |
|
|
151
|
+
| `[data-copied]` | Present when the message was recently copied. |
|
|
165
152
|
|
|
166
153
|
#### Copied state
|
|
167
154
|
|
|
@@ -169,12 +156,12 @@ Show a different icon for a few seconds after the message is copied.
|
|
|
169
156
|
|
|
170
157
|
```tsx
|
|
171
158
|
<ActionBarPrimitive.Copy>
|
|
172
|
-
<
|
|
159
|
+
<AuiIf condition={({ message }) => !message.isCopied}>
|
|
173
160
|
<CopyIcon />
|
|
174
|
-
</
|
|
175
|
-
<
|
|
161
|
+
</AuiIf>
|
|
162
|
+
<AuiIf condition={({ message }) => message.isCopied}>
|
|
176
163
|
<CopySuccessIcon />
|
|
177
|
-
</
|
|
164
|
+
</AuiIf>
|
|
178
165
|
</ActionBarPrimitive.Copy>
|
|
179
166
|
```
|
|
180
167
|
|
|
@@ -232,14 +219,9 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
232
219
|
]}
|
|
233
220
|
/>
|
|
234
221
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
attribute: "[data-submitted]",
|
|
239
|
-
values: "Present when positive feedback was submitted.",
|
|
240
|
-
},
|
|
241
|
-
]}
|
|
242
|
-
/>
|
|
222
|
+
| Data attribute | Values |
|
|
223
|
+
| --- | --- |
|
|
224
|
+
| `[data-submitted]` | Present when positive feedback was submitted. |
|
|
243
225
|
|
|
244
226
|
### Feedback Negative
|
|
245
227
|
|
|
@@ -256,14 +238,9 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
256
238
|
]}
|
|
257
239
|
/>
|
|
258
240
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
attribute: "[data-submitted]",
|
|
263
|
-
values: "Present when negative feedback was submitted.",
|
|
264
|
-
},
|
|
265
|
-
]}
|
|
266
|
-
/>
|
|
241
|
+
| Data attribute | Values |
|
|
242
|
+
| --- | --- |
|
|
243
|
+
| `[data-submitted]` | Present when negative feedback was submitted. |
|
|
267
244
|
|
|
268
245
|
### ExportMarkdown
|
|
269
246
|
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
2
|
+
title: AuiIf
|
|
3
3
|
description: Conditional rendering component based on thread, message, or composer state.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
Conditionally render children based on assistant state.
|
|
7
7
|
|
|
8
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
9
8
|
|
|
10
9
|
## Anatomy
|
|
11
10
|
|
|
12
11
|
```tsx
|
|
13
|
-
import {
|
|
12
|
+
import { AuiIf } from "@assistant-ui/react";
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<AuiIf condition={({ thread }) => thread.isEmpty}>
|
|
16
15
|
<WelcomeScreen />
|
|
17
|
-
</
|
|
16
|
+
</AuiIf>
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
## Overview
|
|
21
20
|
|
|
22
|
-
`
|
|
21
|
+
`AuiIf` is a generic conditional rendering component that provides access to the full assistant state. It replaces the deprecated `ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` components with a single, flexible API.
|
|
23
22
|
|
|
24
23
|
## API Reference
|
|
25
24
|
|
|
26
25
|
<ParametersTable
|
|
27
|
-
type="
|
|
26
|
+
type="AuiIfProps"
|
|
28
27
|
parameters={[
|
|
29
28
|
{
|
|
30
29
|
name: "condition",
|
|
@@ -81,120 +80,120 @@ The condition function receives an `AssistantState` object with the following pr
|
|
|
81
80
|
|
|
82
81
|
```tsx
|
|
83
82
|
// Show welcome screen when thread is empty
|
|
84
|
-
<
|
|
83
|
+
<AuiIf condition={({ thread }) => thread.isEmpty}>
|
|
85
84
|
<WelcomeScreen />
|
|
86
|
-
</
|
|
85
|
+
</AuiIf>
|
|
87
86
|
|
|
88
87
|
// Show loading indicator while running
|
|
89
|
-
<
|
|
88
|
+
<AuiIf condition={({ thread }) => thread.isRunning}>
|
|
90
89
|
<LoadingSpinner />
|
|
91
|
-
</
|
|
90
|
+
</AuiIf>
|
|
92
91
|
|
|
93
92
|
// Conditional send/cancel button
|
|
94
|
-
<
|
|
93
|
+
<AuiIf condition={({ thread }) => !thread.isRunning}>
|
|
95
94
|
<ComposerPrimitive.Send>Send</ComposerPrimitive.Send>
|
|
96
|
-
</
|
|
97
|
-
<
|
|
95
|
+
</AuiIf>
|
|
96
|
+
<AuiIf condition={({ thread }) => thread.isRunning}>
|
|
98
97
|
<ComposerPrimitive.Cancel>Cancel</ComposerPrimitive.Cancel>
|
|
99
|
-
</
|
|
98
|
+
</AuiIf>
|
|
100
99
|
```
|
|
101
100
|
|
|
102
101
|
### Message State Conditions
|
|
103
102
|
|
|
104
103
|
```tsx
|
|
105
104
|
// Show avatar only for assistant messages
|
|
106
|
-
<
|
|
105
|
+
<AuiIf condition={({ message }) => message.role === "assistant"}>
|
|
107
106
|
<AssistantAvatar />
|
|
108
|
-
</
|
|
107
|
+
</AuiIf>
|
|
109
108
|
|
|
110
109
|
// Show disclaimer on last message
|
|
111
|
-
<
|
|
110
|
+
<AuiIf condition={({ message }) => message.isLast}>
|
|
112
111
|
<Disclaimer />
|
|
113
|
-
</
|
|
112
|
+
</AuiIf>
|
|
114
113
|
|
|
115
114
|
// Toggle copy icon based on copied state
|
|
116
115
|
<ActionBarPrimitive.Copy>
|
|
117
|
-
<
|
|
116
|
+
<AuiIf condition={({ message }) => !message.isCopied}>
|
|
118
117
|
<CopyIcon />
|
|
119
|
-
</
|
|
120
|
-
<
|
|
118
|
+
</AuiIf>
|
|
119
|
+
<AuiIf condition={({ message }) => message.isCopied}>
|
|
121
120
|
<CheckIcon />
|
|
122
|
-
</
|
|
121
|
+
</AuiIf>
|
|
123
122
|
</ActionBarPrimitive.Copy>
|
|
124
123
|
|
|
125
124
|
// Show speak/stop button based on speech state
|
|
126
|
-
<
|
|
125
|
+
<AuiIf condition={({ message }) => message.speech == null}>
|
|
127
126
|
<ActionBarPrimitive.Speak>
|
|
128
127
|
<SpeakIcon />
|
|
129
128
|
</ActionBarPrimitive.Speak>
|
|
130
|
-
</
|
|
131
|
-
<
|
|
129
|
+
</AuiIf>
|
|
130
|
+
<AuiIf condition={({ message }) => message.speech != null}>
|
|
132
131
|
<ActionBarPrimitive.StopSpeaking>
|
|
133
132
|
<StopIcon />
|
|
134
133
|
</ActionBarPrimitive.StopSpeaking>
|
|
135
|
-
</
|
|
134
|
+
</AuiIf>
|
|
136
135
|
```
|
|
137
136
|
|
|
138
137
|
### Composer State Conditions
|
|
139
138
|
|
|
140
139
|
```tsx
|
|
141
140
|
// Show placeholder when composer is empty
|
|
142
|
-
<
|
|
141
|
+
<AuiIf condition={({ composer }) => composer.isEmpty}>
|
|
143
142
|
<PlaceholderText />
|
|
144
|
-
</
|
|
143
|
+
</AuiIf>
|
|
145
144
|
|
|
146
145
|
// Show attachment preview when editing
|
|
147
|
-
<
|
|
146
|
+
<AuiIf condition={({ composer }) => composer.isEditing}>
|
|
148
147
|
<EditingIndicator />
|
|
149
|
-
</
|
|
148
|
+
</AuiIf>
|
|
150
149
|
```
|
|
151
150
|
|
|
152
151
|
### Complex Conditions
|
|
153
152
|
|
|
154
153
|
```tsx
|
|
155
154
|
// Combine multiple conditions
|
|
156
|
-
<
|
|
155
|
+
<AuiIf condition={({ thread, message }) =>
|
|
157
156
|
!thread.isRunning && message.role === "assistant"
|
|
158
157
|
}>
|
|
159
158
|
<ActionBar />
|
|
160
|
-
</
|
|
159
|
+
</AuiIf>
|
|
161
160
|
|
|
162
161
|
// Custom logic
|
|
163
|
-
<
|
|
162
|
+
<AuiIf condition={({ thread }) =>
|
|
164
163
|
thread.messages.length > 0 && !thread.isRunning
|
|
165
164
|
}>
|
|
166
165
|
<FollowUpSuggestions />
|
|
167
|
-
</
|
|
166
|
+
</AuiIf>
|
|
168
167
|
```
|
|
169
168
|
|
|
170
169
|
## Type Export
|
|
171
170
|
|
|
172
|
-
You can import the `
|
|
171
|
+
You can import the `AuiIf.Condition` type for typing your condition functions:
|
|
173
172
|
|
|
174
173
|
```tsx
|
|
175
|
-
import {
|
|
174
|
+
import { AuiIf } from "@assistant-ui/react";
|
|
176
175
|
|
|
177
|
-
const isThreadEmpty:
|
|
176
|
+
const isThreadEmpty: AuiIf.Condition = ({ thread }) => thread.isEmpty;
|
|
178
177
|
|
|
179
|
-
<
|
|
178
|
+
<AuiIf condition={isThreadEmpty}>
|
|
180
179
|
<WelcomeScreen />
|
|
181
|
-
</
|
|
180
|
+
</AuiIf>
|
|
182
181
|
```
|
|
183
182
|
|
|
184
183
|
## Migration from Deprecated Components
|
|
185
184
|
|
|
186
185
|
<Callout type="warn">
|
|
187
|
-
`ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` are deprecated. Use `
|
|
186
|
+
`ThreadPrimitive.If`, `MessagePrimitive.If`, and `ComposerPrimitive.If` are deprecated. Use `AuiIf` instead.
|
|
188
187
|
</Callout>
|
|
189
188
|
|
|
190
189
|
| Before | After |
|
|
191
190
|
|--------|-------|
|
|
192
|
-
| `<ThreadPrimitive.If empty>` | `<
|
|
193
|
-
| `<ThreadPrimitive.If running>` | `<
|
|
194
|
-
| `<ThreadPrimitive.If running={false}>` | `<
|
|
195
|
-
| `<MessagePrimitive.If user>` | `<
|
|
196
|
-
| `<MessagePrimitive.If assistant>` | `<
|
|
197
|
-
| `<MessagePrimitive.If copied>` | `<
|
|
198
|
-
| `<MessagePrimitive.If speaking>` | `<
|
|
199
|
-
| `<MessagePrimitive.If last>` | `<
|
|
200
|
-
| `<ComposerPrimitive.If editing>` | `<
|
|
191
|
+
| `<ThreadPrimitive.If empty>` | `<AuiIf condition={({ thread }) => thread.isEmpty}>` |
|
|
192
|
+
| `<ThreadPrimitive.If running>` | `<AuiIf condition={({ thread }) => thread.isRunning}>` |
|
|
193
|
+
| `<ThreadPrimitive.If running={false}>` | `<AuiIf condition={({ thread }) => !thread.isRunning}>` |
|
|
194
|
+
| `<MessagePrimitive.If user>` | `<AuiIf condition={({ message }) => message.role === "user"}>` |
|
|
195
|
+
| `<MessagePrimitive.If assistant>` | `<AuiIf condition={({ message }) => message.role === "assistant"}>` |
|
|
196
|
+
| `<MessagePrimitive.If copied>` | `<AuiIf condition={({ message }) => message.isCopied}>` |
|
|
197
|
+
| `<MessagePrimitive.If speaking>` | `<AuiIf condition={({ message }) => message.speech != null}>` |
|
|
198
|
+
| `<MessagePrimitive.If last>` | `<AuiIf condition={({ message }) => message.isLast}>` |
|
|
199
|
+
| `<ComposerPrimitive.If editing>` | `<AuiIf condition={({ composer }) => composer.isEditing}>` |
|
|
@@ -5,9 +5,6 @@ description: A popover chat interface for floating assistant UI in the corner of
|
|
|
5
5
|
|
|
6
6
|
A modal chat UI usually displayed in the bottom right corner of the screen.
|
|
7
7
|
|
|
8
|
-
import { Code } from "@radix-ui/themes";
|
|
9
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
10
|
-
import { DataAttributesTable } from "@/components/docs/tables/DataAttributesTable";
|
|
11
8
|
|
|
12
9
|
## Anatomy
|
|
13
10
|
|
|
@@ -79,14 +76,9 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
79
76
|
]}
|
|
80
77
|
/>
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
attribute: "[data-state]",
|
|
86
|
-
values: <Code>"open" | "closed"</Code>,
|
|
87
|
-
},
|
|
88
|
-
]}
|
|
89
|
-
/>
|
|
79
|
+
| Data attribute | Values |
|
|
80
|
+
| --- | --- |
|
|
81
|
+
| `[data-state]` | `"open" \| "closed"` |
|
|
90
82
|
|
|
91
83
|
### Anchor
|
|
92
84
|
|
|
@@ -5,9 +5,6 @@ description: Components for displaying and managing file attachments in messages
|
|
|
5
5
|
|
|
6
6
|
Buttons to interact with attachments.
|
|
7
7
|
|
|
8
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
9
|
-
import { DataAttributesTable } from "@/components/docs/tables/DataAttributesTable";
|
|
10
|
-
import { Code } from "@radix-ui/themes";
|
|
11
8
|
|
|
12
9
|
<Callout>
|
|
13
10
|
**Dual Use!** Attachments can appear in both messages and composers.
|
|
@@ -6,9 +6,6 @@ description: Primitives for the text input, send button, and attachments.
|
|
|
6
6
|
The user interface to add new messages or edit existing ones.
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
10
|
-
import { KeyboardTable } from "@/components/docs/tables/KeyboardTable";
|
|
11
|
-
import { Code } from "@radix-ui/themes";
|
|
12
9
|
|
|
13
10
|
<Callout>
|
|
14
11
|
**Dual Use!** A Composer placed directly inside a `Thread` will compose new
|
|
@@ -88,18 +85,10 @@ This primitive renders a `<textarea>` element unless `asChild` is set.
|
|
|
88
85
|
|
|
89
86
|
#### Keyboard Shortcuts
|
|
90
87
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
description: "Sends the message.",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
keys: ["Escape"],
|
|
99
|
-
description: "Sends a cancel action.",
|
|
100
|
-
},
|
|
101
|
-
]}
|
|
102
|
-
/>
|
|
88
|
+
| Key | Description |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| <Kbd>Enter</Kbd> | Sends the message. |
|
|
91
|
+
| <Kbd>Escape</Kbd> | Sends a cancel action. |
|
|
103
92
|
|
|
104
93
|
### Send
|
|
105
94
|
|
|
@@ -126,7 +115,7 @@ This primitive renders a `<button>` element unless `asChild` is set.
|
|
|
126
115
|
|
|
127
116
|
Sends a cancel action.
|
|
128
117
|
|
|
129
|
-
In edit composers, this action exits the edit mode.
|
|
118
|
+
In edit composers, this action exits the edit mode.
|
|
130
119
|
In thread composers, this action stops the current run.
|
|
131
120
|
|
|
132
121
|
This primitive renders a `<button>` element unless `asChild` is set.
|
|
@@ -3,7 +3,6 @@ title: Composition
|
|
|
3
3
|
description: How to compose primitives with custom components using asChild.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { Code } from "@radix-ui/themes";
|
|
7
6
|
|
|
8
7
|
`assistant-ui` primitives are composable. This means that all props are forwarded, classes are merged, and event handlers are chained.
|
|
9
8
|
|
|
@@ -3,7 +3,6 @@ title: MessagePartPrimitive
|
|
|
3
3
|
description: Primitives for text, images, tool calls, and other message content.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import { ParametersTable } from "@/components/docs/tables/ParametersTable";
|
|
7
6
|
import {
|
|
8
7
|
MessagePartRuntime,
|
|
9
8
|
TextMessagePartState,
|
|
@@ -11,7 +10,7 @@ import {
|
|
|
11
10
|
ToolCallMessagePartState,
|
|
12
11
|
} from "@/generated/typeDocs";
|
|
13
12
|
|
|
14
|
-
Each message can have any number of message parts.
|
|
13
|
+
Each message can have any number of message parts.
|
|
15
14
|
Message parts are usually one of text, reasoning, audio or tool-call.
|
|
16
15
|
|
|
17
16
|
## Message part Types
|