@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,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThreadPrimitive
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
A conversation between a user and an assistant.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { ThreadPrimitive } from "@assistant-ui/react";
|
|
13
|
+
|
|
14
|
+
const Thread = () => (
|
|
15
|
+
<ThreadPrimitive.Root>
|
|
16
|
+
<ThreadPrimitive.Viewport>
|
|
17
|
+
<ThreadPrimitive.Empty>...</ThreadPrimitive.Empty>
|
|
18
|
+
<ThreadPrimitive.Messages components={...} />
|
|
19
|
+
</ThreadPrimitive.Viewport>
|
|
20
|
+
<Composer />
|
|
21
|
+
</ThreadPrimitive.Root>
|
|
22
|
+
);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API Reference
|
|
26
|
+
|
|
27
|
+
### Root
|
|
28
|
+
|
|
29
|
+
Containts all parts of the thread.
|
|
30
|
+
|
|
31
|
+
This primitive renders a `<div>` element unless `asChild` is set.
|
|
32
|
+
|
|
33
|
+
<ParametersTable
|
|
34
|
+
type="ThreadPrimitiveRootProps"
|
|
35
|
+
parameters={[
|
|
36
|
+
{
|
|
37
|
+
name: "asChild",
|
|
38
|
+
},
|
|
39
|
+
]}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
### Viewport
|
|
43
|
+
|
|
44
|
+
The scrollable area containing all messages. Anchors scroll to the bottom as new messages are added.
|
|
45
|
+
|
|
46
|
+
This primitive renders a `<div>` element unless `asChild` is set.
|
|
47
|
+
|
|
48
|
+
<ParametersTable
|
|
49
|
+
type="ThreadPrimitiveViewportProps"
|
|
50
|
+
parameters={[
|
|
51
|
+
{
|
|
52
|
+
name: "asChild",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "autoScroll",
|
|
56
|
+
type: "boolean",
|
|
57
|
+
default: "true",
|
|
58
|
+
description:
|
|
59
|
+
"Whether to automatically scroll to the bottom of the viewport when new messages are added while the viewport is was previously scrolled to the bottom.",
|
|
60
|
+
},
|
|
61
|
+
]}
|
|
62
|
+
/>
|
|
63
|
+
|
|
64
|
+
### Messages
|
|
65
|
+
|
|
66
|
+
Renders all messages. This primitive renders a separate component for each message.
|
|
67
|
+
|
|
68
|
+
<ParametersTable
|
|
69
|
+
type="ThreadPrimitiveMessagesProps"
|
|
70
|
+
parameters={[
|
|
71
|
+
{
|
|
72
|
+
name: "components",
|
|
73
|
+
type: "MessageComponents",
|
|
74
|
+
description: "The component to render for each message.",
|
|
75
|
+
children: [
|
|
76
|
+
{
|
|
77
|
+
type: "MessageComponents",
|
|
78
|
+
parameters: [
|
|
79
|
+
{
|
|
80
|
+
name: "Message",
|
|
81
|
+
type: "ComponentType",
|
|
82
|
+
description: "The component to render for each message.",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "UserMessage",
|
|
86
|
+
type: "ComponentType",
|
|
87
|
+
description: "The component to render for user messages.",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "EditComposer",
|
|
91
|
+
type: "ComponentType",
|
|
92
|
+
description:
|
|
93
|
+
"The component to render for user messages that are being edited.",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "AssistantMessage",
|
|
97
|
+
type: "ComponentType",
|
|
98
|
+
description: "The component to render for assistant messages.",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
]}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
### Empty
|
|
108
|
+
|
|
109
|
+
Renders children only when there are no messages.
|
|
110
|
+
|
|
111
|
+
### ScrollToBottom
|
|
112
|
+
|
|
113
|
+
A button to scroll the viewport to the bottom. Disabled when the viewport is already at bottom.
|
|
114
|
+
|
|
115
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
116
|
+
|
|
117
|
+
<ParametersTable
|
|
118
|
+
type="ThreadPrimitiveScrollToBottomProps"
|
|
119
|
+
parameters={[
|
|
120
|
+
{
|
|
121
|
+
name: "asChild",
|
|
122
|
+
},
|
|
123
|
+
]}
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
### `ThreadPrimitive.Suggestion`
|
|
127
|
+
|
|
128
|
+
Shows a suggestion to the user. When the user clicks on the suggestion, the composer's value is set to the suggestion's prompt.
|
|
129
|
+
|
|
130
|
+
This primitive renders a `<button>` element unless `asChild` is set.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
import { ThreadPrimitive } from "@assistant-ui/react";
|
|
134
|
+
|
|
135
|
+
const Suggestion = () => {
|
|
136
|
+
return (
|
|
137
|
+
<ThreadPrimitive.Suggestion
|
|
138
|
+
prompt="I need help with product search"
|
|
139
|
+
method="replace"
|
|
140
|
+
autoSend
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
<ParametersTable
|
|
147
|
+
type="ThreadPrimitiveSuggestionProps"
|
|
148
|
+
parameters={[
|
|
149
|
+
{
|
|
150
|
+
name: "prompt",
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "The suggestion's prompt.",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "method",
|
|
156
|
+
type: "'replace'",
|
|
157
|
+
description:
|
|
158
|
+
"How does the suggestion interact with the composer's existing value.",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "autoSend",
|
|
162
|
+
type: "boolean",
|
|
163
|
+
description:
|
|
164
|
+
"Whether to automatically send the suggestion when the user clicks on it.",
|
|
165
|
+
default: "false",
|
|
166
|
+
},
|
|
167
|
+
]}
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
### If
|
|
171
|
+
|
|
172
|
+
Renders children if a condition is met.
|
|
173
|
+
|
|
174
|
+
<ParametersTable
|
|
175
|
+
type="ThreadPrimitiveIfProps"
|
|
176
|
+
parameters={[
|
|
177
|
+
{
|
|
178
|
+
name: "empty",
|
|
179
|
+
type: "boolean | undefined",
|
|
180
|
+
description: "Render children if the thread is empty.",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: "running",
|
|
184
|
+
type: "boolean | undefined",
|
|
185
|
+
description: "Render children if the thread is running.",
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<Thread.If empty>
|
|
192
|
+
{/* equivalent to <Thread.Empty> */}
|
|
193
|
+
</Thread.If>
|
|
194
|
+
<Thread.If empty={false}>
|
|
195
|
+
{/* rendered if thread is not empty */}
|
|
196
|
+
</Thread.If>
|
|
197
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Composition
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { Code } from "@radix-ui/themes";
|
|
6
|
+
|
|
7
|
+
`assistant-ui` primitives are composable. This means that all props are forwarded, classes are merged, and event handlers are chained.
|
|
8
|
+
|
|
9
|
+
Most primitives come with a default HTML element (usually `div` or `button`). If you already have a custom component, you can use the `asChild` prop to replace it:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// use the primitive's <button> element
|
|
13
|
+
<Composer.Send>Send</Composer.Send>;
|
|
14
|
+
|
|
15
|
+
// use your own <Button> component
|
|
16
|
+
<Composer.Send asChild>
|
|
17
|
+
<Button>Send</Button>
|
|
18
|
+
</Composer.Send>;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Learn more on [Radix's composition guide](https://www.radix-ui.com/primitives/docs/guides/composition).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AssistantRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import { AssistantRuntime, AssistantToolUIsState } from "@/generated/typeDocs";
|
|
7
|
+
|
|
8
|
+
The `AssistantRuntime` is the root runtime of the application.
|
|
9
|
+
|
|
10
|
+
### `useAssistantRuntime`
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { useAssistantRuntime } from "@assistant-ui/react";
|
|
14
|
+
|
|
15
|
+
const runtime = useAssistantRuntime();
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
<ParametersTable {...AssistantRuntime} />
|
|
19
|
+
|
|
20
|
+
### Tool UI Registry
|
|
21
|
+
|
|
22
|
+
The tool UI registry is part of the assistant runtime. It allows you to display custom UI for tool calls, enabling generative UI.
|
|
23
|
+
|
|
24
|
+
#### `useToolUIs`
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useToolUIs } from "@assistant-ui/react";
|
|
28
|
+
|
|
29
|
+
const toolUIs = useToolUIs();
|
|
30
|
+
const webSearchToolUI = useToolUIs((m) => m.getToolUI("web_search"));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<ParametersTable {...AssistantToolUIsState} />
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: AttachmentRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import {
|
|
7
|
+
ComposerAttachmentState,
|
|
8
|
+
MessageAttachmentState,
|
|
9
|
+
} from "@/components/docs/parameters/context";
|
|
10
|
+
|
|
11
|
+
### `useAttachment`
|
|
12
|
+
|
|
13
|
+
Access the current attachment state:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { useAttachment } from "@assistant-ui/react";
|
|
17
|
+
|
|
18
|
+
const { attachment } = useAttachment();
|
|
19
|
+
const att = useAttachment((m) => m.attachment);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### `useComposerAttachment` (Composer)
|
|
23
|
+
|
|
24
|
+
When working with a composer’s attachment:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useComposerAttachment } from "@assistant-ui/react";
|
|
28
|
+
|
|
29
|
+
const { attachment } = useComposerAttachment();
|
|
30
|
+
const composerAttachment = useComposerAttachment((m) => m.attachment);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<ParametersTable {...ComposerAttachmentState} />
|
|
34
|
+
|
|
35
|
+
### `useMessageAttachment` (Message)
|
|
36
|
+
|
|
37
|
+
For managing a message’s attachment:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { useMessageAttachment } from "@assistant-ui/react";
|
|
41
|
+
|
|
42
|
+
const { attachment } = useMessageAttachment();
|
|
43
|
+
const messageAttachment = useMessageAttachment((m) => m.attachment);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
<ParametersTable {...MessageAttachmentState} />
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ComposerRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The composer runtime allows you to view or edit anything related to how new information is added and sent. For instance you can use the composer runtime to read the state, add attachments, update text, send a message, etc.
|
|
6
|
+
|
|
7
|
+
import { ParametersTable } from "@/components/docs";
|
|
8
|
+
import { ComposerRuntime, ThreadComposerRuntime, ThreadComposerState, EditComposerState } from "@/generated/typeDocs";
|
|
9
|
+
|
|
10
|
+
### `useComposer`
|
|
11
|
+
|
|
12
|
+
Grabs the nearest composer (whether it’s the edit composer or the thread’s composer):
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
// Example
|
|
16
|
+
import { useComposer } from "@assistant-ui/react";
|
|
17
|
+
|
|
18
|
+
const composerRuntime = useComposer();
|
|
19
|
+
|
|
20
|
+
// set the text
|
|
21
|
+
composerRuntime.setText("Hello from the composer runtime");
|
|
22
|
+
|
|
23
|
+
// send whatever is in the composer
|
|
24
|
+
composerRuntime.send();
|
|
25
|
+
|
|
26
|
+
// get the current text in the composer state
|
|
27
|
+
const composerState = composerRuntime.getState();
|
|
28
|
+
const currentText = composerState.text;
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<ParametersTable {...ComposerRuntime} />
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### `useThreadComposer`
|
|
36
|
+
|
|
37
|
+
Access the thread’s new message composer state:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { useThreadComposer } from "@assistant-ui/react";
|
|
41
|
+
|
|
42
|
+
const threadComposerRuntime = useThreadComposer();
|
|
43
|
+
|
|
44
|
+
// set the text
|
|
45
|
+
threadComposerRuntime.setText("Hello from the thread composer runtime");
|
|
46
|
+
|
|
47
|
+
// send whatever is in the thread composer
|
|
48
|
+
threadComposerRuntime.send();
|
|
49
|
+
|
|
50
|
+
// get the current text in the composer state
|
|
51
|
+
const threadComposerState = threadComposerRuntime.getState();
|
|
52
|
+
const currentText = threadComposerRuntime.text;
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
<ParametersTable {...ThreadComposerRuntime} />
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### `ThreadComposerState`
|
|
60
|
+
|
|
61
|
+
The state of the thread composer which is the composer the user can interact with at the bottom.
|
|
62
|
+
|
|
63
|
+
<ParametersTable {...ThreadComposerState} />
|
|
64
|
+
|
|
65
|
+
### `EditComposerState`
|
|
66
|
+
|
|
67
|
+
The state of the edit composer which is the composer the user can edit messages with.
|
|
68
|
+
|
|
69
|
+
<ParametersTable {...EditComposerState} />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ContentPartRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import { ContentPartState } from "@/components/docs/parameters/context";
|
|
7
|
+
|
|
8
|
+
### `useContentPart`
|
|
9
|
+
|
|
10
|
+
Access the content part state:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { useContentPart } from "@assistant-ui/react";
|
|
14
|
+
|
|
15
|
+
const part = useContentPart();
|
|
16
|
+
const partState = useContentPart.getState();
|
|
17
|
+
|
|
18
|
+
const status = useContentPart((m) => m.status);
|
|
19
|
+
const statusAgain = useContentPart.getState().status;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<ParametersTable {...ContentPartState} />
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MessageRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import {
|
|
7
|
+
MessageState,
|
|
8
|
+
MessageUtilsState,
|
|
9
|
+
EditComposerState,
|
|
10
|
+
} from "@/components/docs/parameters/context";
|
|
11
|
+
|
|
12
|
+
### `useMessage`
|
|
13
|
+
|
|
14
|
+
Retrieve the message object:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { useMessage } from "@assistant-ui/react";
|
|
18
|
+
|
|
19
|
+
const { message } = useMessage();
|
|
20
|
+
const msg = useMessage((m) => m.message);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<ParametersTable {...MessageState} />
|
|
24
|
+
|
|
25
|
+
### `useMessageUtils`
|
|
26
|
+
|
|
27
|
+
Provides utility functions for a message (e.g., copy status):
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { useMessageUtils } from "@assistant-ui/react";
|
|
31
|
+
|
|
32
|
+
const messageUtils = useMessageUtils();
|
|
33
|
+
const isCopied = useMessageUtils((m) => m.isCopied);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
<ParametersTable {...MessageUtilsState} />
|
|
37
|
+
|
|
38
|
+
### `useEditComposer`
|
|
39
|
+
|
|
40
|
+
Access the edit composer state (used when editing a message):
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { useEditComposer } from "@assistant-ui/react";
|
|
44
|
+
|
|
45
|
+
const editComposer = useEditComposer();
|
|
46
|
+
const text = useEditComposer((m) => m.text);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
<ParametersTable {...EditComposerState} />
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThreadListItemRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import {
|
|
7
|
+
ThreadListItemRuntime,
|
|
8
|
+
ThreadListItemState,
|
|
9
|
+
} from "@/generated/typeDocs";
|
|
10
|
+
|
|
11
|
+
### `useThreadListItemRuntime`
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useThreadListItemRuntime } from "@assistant-ui/react";
|
|
15
|
+
|
|
16
|
+
const threadListItemRuntime = useThreadListItemRuntime();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<ParametersTable {...ThreadListItemRuntime} />
|
|
20
|
+
|
|
21
|
+
### `useThreadListItem`
|
|
22
|
+
|
|
23
|
+
Access the state for a specific thread list item:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useThreadListItem } from "@assistant-ui/react";
|
|
27
|
+
|
|
28
|
+
const threadListItem = useThreadListItem();
|
|
29
|
+
const title = useThreadListItem((m) => m.title);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
<ParametersTable {...ThreadListItemState} />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThreadListRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import { ThreadListRuntime, ThreadListState } from "@/generated/typeDocs";
|
|
7
|
+
|
|
8
|
+
### Access via `useAssistantRuntime`
|
|
9
|
+
|
|
10
|
+
You can access the thread list runtime via the assistant runtime:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { useAssistantRuntime } from "@assistant-ui/react";
|
|
14
|
+
|
|
15
|
+
const threadListRuntime = useAssistantRuntime().threadList;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
<ParametersTable {...ThreadListRuntime} />
|
|
19
|
+
|
|
20
|
+
### `useThreadList`
|
|
21
|
+
|
|
22
|
+
This hook provides access to the thread list state:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useThreadList } from "@assistant-ui/react";
|
|
26
|
+
|
|
27
|
+
const threadList = useThreadList();
|
|
28
|
+
const threads = useThreadList((m) => m.threads);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<ParametersTable {...ThreadListState} />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ThreadRuntime
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { ParametersTable } from "@/components/docs";
|
|
6
|
+
import { ThreadRuntime, ThreadState } from "@/generated/typeDocs";
|
|
7
|
+
import {
|
|
8
|
+
ThreadMessagesState,
|
|
9
|
+
ThreadViewportState,
|
|
10
|
+
} from "@/components/docs/parameters/context";
|
|
11
|
+
|
|
12
|
+
### `useThreadRuntime`
|
|
13
|
+
|
|
14
|
+
Get the thread runtime object:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { useThreadRuntime } from "@assistant-ui/react";
|
|
18
|
+
|
|
19
|
+
const thread = useThreadRuntime();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<ParametersTable {...ThreadRuntime} />
|
|
23
|
+
|
|
24
|
+
### `useThread`
|
|
25
|
+
|
|
26
|
+
Access the thread state directly:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { useThread } from "@assistant-ui/react";
|
|
30
|
+
|
|
31
|
+
const thread = useThread();
|
|
32
|
+
const isRunning = useThread((m) => m.isRunning);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<ParametersTable {...ThreadState} />
|
|
36
|
+
|
|
37
|
+
### `useThreadViewport`
|
|
38
|
+
|
|
39
|
+
Manage thread viewport state (e.g., scrolling):
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { useThreadViewport } from "@assistant-ui/react";
|
|
43
|
+
|
|
44
|
+
const threadViewport = useThreadViewport();
|
|
45
|
+
const isAtBottom = useThreadViewport((m) => m.isAtBottom);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
<ParametersTable {...ThreadViewportState} />
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Architecture"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { Sparkles, PanelsTopLeft, Database, Terminal } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
## assistant-ui is built on these main pillars:
|
|
8
|
+
|
|
9
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 my-8">
|
|
10
|
+
<Card title='1. Frontend components'>
|
|
11
|
+
Shadcn UI chat components with built-in state management
|
|
12
|
+
</Card>
|
|
13
|
+
|
|
14
|
+
<Card title='2. Runtime'>
|
|
15
|
+
State management layer connecting UI to LLMs and backend services
|
|
16
|
+
</Card>
|
|
17
|
+
|
|
18
|
+
<Card title='3. Assistant Cloud'>
|
|
19
|
+
Hosted service for thread persistence, history, and user management
|
|
20
|
+
</Card>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### 1. Frontend components
|
|
26
|
+
Stylized and functional chat components built on top of Shadcn components that have context state management provided by the assistantUI runtime provider. These pre-built React components come with intelligent state management. [View our components](/docs/ui/Thread)
|
|
27
|
+
|
|
28
|
+
### 2. Runtime
|
|
29
|
+
A React state management context for assistant chat. The runtime handles data conversions between the local state and calls to backends and LLMs. We offer different runtime solutions that work with various frameworks like Vercel AI SDK, LangGraph, LangChain, Helicone, local runtime, and an ExternalStore when you need full control of the frontend message state. [You can view the runtimes we support](/docs/runtimes/pick-a-runtime)
|
|
30
|
+
|
|
31
|
+
### 3. Assistant Cloud
|
|
32
|
+
A hosted service that enhances your assistant experience with comprehensive thread management and message history. Assistant Cloud stores complete message history, automatically persists threads, supports human-in-the-loop workflows, and integrates with common auth providers to seamlessly allow users to resume conversations at any point. [Cloud Docs](/docs/cloud/overview)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### There are three common ways to architect your assistant-ui application:
|
|
36
|
+
|
|
37
|
+
#### **1. Direct Integration with External Providers**
|
|
38
|
+
|
|
39
|
+
```mermaid
|
|
40
|
+
graph TD
|
|
41
|
+
A[Frontend Components] --> B[Runtime]
|
|
42
|
+
B --> D[External Providers or LLM APIs]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
classDef default color:#f8fafc,text-align:center
|
|
46
|
+
|
|
47
|
+
style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold
|
|
48
|
+
style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold
|
|
49
|
+
style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold
|
|
50
|
+
|
|
51
|
+
class A,B,C,D,E default
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### **2. Using your own API endpoint**
|
|
55
|
+
|
|
56
|
+
```mermaid
|
|
57
|
+
graph TD
|
|
58
|
+
A[Frontend Components] --> B[Runtime]
|
|
59
|
+
B --> E[Your API Backend]
|
|
60
|
+
E --> D[External Providers or LLM APIs]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
classDef default color:#f8fafc,text-align:center
|
|
64
|
+
|
|
65
|
+
style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold
|
|
66
|
+
style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold
|
|
67
|
+
style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold
|
|
68
|
+
style E fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold
|
|
69
|
+
|
|
70
|
+
class A,B,C,D,E default
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### **3. With Assistant Cloud**
|
|
74
|
+
|
|
75
|
+
```mermaid
|
|
76
|
+
graph TD
|
|
77
|
+
A[Frontend Components] --> B[Runtime]
|
|
78
|
+
B --> C[Cloud]
|
|
79
|
+
E --> C
|
|
80
|
+
C --> D[External Providers or LLM APIs]
|
|
81
|
+
B --> E[Your API Backend]
|
|
82
|
+
|
|
83
|
+
classDef default color:#f8fafc,text-align:center
|
|
84
|
+
|
|
85
|
+
style A fill:#e879f9,stroke:#2e1065,stroke-width:2px,color:#2e1065,font-weight:bold
|
|
86
|
+
style B fill:#93c5fd,stroke:#1e3a8a,stroke-width:2px,color:#1e3a8a,font-weight:bold
|
|
87
|
+
style C fill:#86efac,stroke:#064e3b,stroke-width:2px,color:#064e3b,font-weight:bold
|
|
88
|
+
style D fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold
|
|
89
|
+
style E fill:#fca5a5,stroke:#7f1d1d,stroke-width:2px,color:#7f1d1d,font-weight:bold
|
|
90
|
+
|
|
91
|
+
class A,B,C,D,E default
|
|
92
|
+
```
|