@assistant-ui/mcp-docs-server 0.1.24 → 0.1.26
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/waterfall.md +8 -6
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +10 -11
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +31 -19
- package/.docs/organized/code-examples/with-artifacts.md +8 -8
- package/.docs/organized/code-examples/with-assistant-transport.md +6 -6
- package/.docs/organized/code-examples/with-chain-of-thought.md +37 -29
- package/.docs/organized/code-examples/with-cloud-standalone.md +14 -11
- package/.docs/organized/code-examples/with-cloud.md +8 -8
- package/.docs/organized/code-examples/with-custom-thread-list.md +10 -10
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +11 -11
- package/.docs/organized/code-examples/with-expo.md +571 -520
- package/.docs/organized/code-examples/with-external-store.md +6 -6
- package/.docs/organized/code-examples/with-ffmpeg.md +8 -8
- package/.docs/organized/code-examples/with-google-adk.md +353 -0
- package/.docs/organized/code-examples/with-heat-graph.md +304 -0
- package/.docs/organized/code-examples/with-interactables.md +778 -0
- package/.docs/organized/code-examples/with-langgraph.md +28 -26
- package/.docs/organized/code-examples/with-parent-id-grouping.md +7 -7
- package/.docs/organized/code-examples/with-react-hook-form.md +9 -9
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-store.md +33 -22
- package/.docs/organized/code-examples/with-tanstack.md +10 -10
- package/.docs/organized/code-examples/with-tap-runtime.md +12 -10
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +258 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +74 -9
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
- package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +74 -15
- package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
- package/.docs/raw/docs/(docs)/guides/interactables.mdx +292 -0
- package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +5 -4
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +174 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
- package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
- package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
- package/.docs/raw/docs/(docs)/index.mdx +3 -3
- package/.docs/raw/docs/(docs)/installation.mdx +69 -46
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +226 -44
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
- package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
- package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
- package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +90 -6
- package/.docs/raw/docs/cloud/ai-sdk.mdx +95 -5
- package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
- package/.docs/raw/docs/ink/adapters.mdx +41 -0
- package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
- package/.docs/raw/docs/ink/hooks.mdx +448 -0
- package/.docs/raw/docs/ink/index.mdx +239 -0
- package/.docs/raw/docs/ink/migration.mdx +140 -0
- package/.docs/raw/docs/ink/primitives.mdx +840 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +351 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +215 -0
- package/.docs/raw/docs/primitives/attachment.mdx +216 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +221 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +311 -0
- package/.docs/raw/docs/primitives/composer.mdx +526 -0
- package/.docs/raw/docs/primitives/error.mdx +141 -0
- package/.docs/raw/docs/primitives/index.mdx +98 -0
- package/.docs/raw/docs/primitives/message.mdx +524 -0
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +165 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +242 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +404 -0
- package/.docs/raw/docs/primitives/thread.mdx +482 -0
- package/.docs/raw/docs/react-native/adapters.mdx +63 -87
- package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
- package/.docs/raw/docs/react-native/hooks.mdx +214 -232
- package/.docs/raw/docs/react-native/index.mdx +118 -159
- package/.docs/raw/docs/react-native/migration.mdx +144 -0
- package/.docs/raw/docs/react-native/primitives.mdx +431 -302
- package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
- package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
- package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
- package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
- package/.docs/raw/docs/ui/file.mdx +5 -4
- package/.docs/raw/docs/ui/image.mdx +5 -4
- package/.docs/raw/docs/ui/markdown.mdx +3 -1
- package/.docs/raw/docs/ui/mention.mdx +168 -0
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
- package/.docs/raw/docs/ui/quote.mdx +210 -0
- package/.docs/raw/docs/ui/reasoning.mdx +12 -11
- package/.docs/raw/docs/ui/sources.mdx +88 -17
- package/.docs/raw/docs/ui/streamdown.mdx +16 -7
- package/.docs/raw/docs/ui/thread-list.mdx +11 -13
- package/.docs/raw/docs/ui/thread.mdx +28 -33
- package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
- package/.docs/raw/docs/ui/tool-group.mdx +9 -8
- package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
- package/package.json +5 -5
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
- package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
- /package/.docs/raw/docs/cloud/{overview.mdx → index.mdx} +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ChainOfThought
|
|
3
|
+
description: Collapsible accordion for grouping reasoning steps and tool calls.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { ChainOfThoughtPrimitiveSample } from "@/components/docs/samples/chain-of-thought-primitive";
|
|
7
|
+
import { ChainOfThoughtPrimitive as ChainOfThoughtPrimitiveDocs } from "@/generated/primitiveDocs";
|
|
8
|
+
|
|
9
|
+
The ChainOfThought primitive groups consecutive reasoning and tool-call parts into a collapsible accordion. Reasoning models emit reasoning tokens and tool calls before producing a final answer. This primitive lets you collapse those intermediate steps behind a "Thinking" toggle.
|
|
10
|
+
|
|
11
|
+
<Callout type="info">
|
|
12
|
+
Grouped Chain of Thought currently plugs into `MessagePrimitive.Parts` via `components.ChainOfThought`. If you're wiring grouped CoT, use that API.
|
|
13
|
+
</Callout>
|
|
14
|
+
|
|
15
|
+
<Tabs items={["Preview", "Code"]}>
|
|
16
|
+
<Tab>
|
|
17
|
+
<ChainOfThoughtPrimitiveSample />
|
|
18
|
+
</Tab>
|
|
19
|
+
<Tab>
|
|
20
|
+
```tsx
|
|
21
|
+
import {
|
|
22
|
+
AuiIf,
|
|
23
|
+
ChainOfThoughtPrimitive,
|
|
24
|
+
MessagePrimitive,
|
|
25
|
+
} from "@assistant-ui/react";
|
|
26
|
+
|
|
27
|
+
function AssistantMessage() {
|
|
28
|
+
return (
|
|
29
|
+
<MessagePrimitive.Root>
|
|
30
|
+
<MessagePrimitive.Parts>
|
|
31
|
+
{({ part }) => {
|
|
32
|
+
if (part.type === "text") return <MyText />;
|
|
33
|
+
return null;
|
|
34
|
+
}}
|
|
35
|
+
</MessagePrimitive.Parts>
|
|
36
|
+
<ChainOfThought />
|
|
37
|
+
</MessagePrimitive.Root>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function ChainOfThought() {
|
|
42
|
+
return (
|
|
43
|
+
<ChainOfThoughtPrimitive.Root className="my-2 rounded-lg border">
|
|
44
|
+
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2.5 font-medium text-sm hover:bg-muted/50">
|
|
45
|
+
Thinking
|
|
46
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
47
|
+
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
48
|
+
<ChainOfThoughtPrimitive.Parts
|
|
49
|
+
components={{
|
|
50
|
+
Reasoning: ({ text }) => (
|
|
51
|
+
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
52
|
+
{text}
|
|
53
|
+
</p>
|
|
54
|
+
),
|
|
55
|
+
tools: {
|
|
56
|
+
Fallback: ({ toolName, status }) => (
|
|
57
|
+
<div className="flex items-center gap-2 px-4 py-2 text-sm">
|
|
58
|
+
<span className="font-medium">{toolName}</span>
|
|
59
|
+
<span className="text-muted-foreground">
|
|
60
|
+
{status.type === "running" ? "running..." : "done"}
|
|
61
|
+
</span>
|
|
62
|
+
</div>
|
|
63
|
+
),
|
|
64
|
+
},
|
|
65
|
+
}}
|
|
66
|
+
/>
|
|
67
|
+
</AuiIf>
|
|
68
|
+
</ChainOfThoughtPrimitive.Root>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
</Tab>
|
|
73
|
+
</Tabs>
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
Render your normal message parts with `MessagePrimitive.Parts`, then place a `ChainOfThought` component alongside them inside the same `MessagePrimitive.Root`:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import {
|
|
81
|
+
ChainOfThoughtPrimitive,
|
|
82
|
+
MessagePrimitive,
|
|
83
|
+
} from "@assistant-ui/react";
|
|
84
|
+
|
|
85
|
+
<MessagePrimitive.Root>
|
|
86
|
+
<MessagePrimitive.Parts>
|
|
87
|
+
{({ part }) => {
|
|
88
|
+
if (part.type === "text") return <MyText />;
|
|
89
|
+
return null;
|
|
90
|
+
}}
|
|
91
|
+
</MessagePrimitive.Parts>
|
|
92
|
+
<MyChainOfThought />
|
|
93
|
+
</MessagePrimitive.Root>
|
|
94
|
+
|
|
95
|
+
function MyChainOfThought() {
|
|
96
|
+
return (
|
|
97
|
+
<ChainOfThoughtPrimitive.Root>
|
|
98
|
+
<ChainOfThoughtPrimitive.AccordionTrigger>
|
|
99
|
+
Thinking
|
|
100
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
101
|
+
<ChainOfThoughtPrimitive.Parts />
|
|
102
|
+
</ChainOfThoughtPrimitive.Root>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`Root` renders a `<div>`, `AccordionTrigger` renders a `<button>` that toggles the collapsed state, and `Parts` renders the grouped reasoning and tool-call parts.
|
|
108
|
+
|
|
109
|
+
<Callout type="info">
|
|
110
|
+
Runtime setup: primitives require runtime context. Wrap your UI in `AssistantRuntimeProvider` with a runtime (for example `useLocalRuntime(...)`). See [Pick a Runtime](/docs/runtimes/pick-a-runtime).
|
|
111
|
+
</Callout>
|
|
112
|
+
|
|
113
|
+
## Core Concepts
|
|
114
|
+
|
|
115
|
+
### How Grouping Works
|
|
116
|
+
|
|
117
|
+
`ChainOfThoughtPrimitive.Parts` reads the current message's grouped reasoning and tool-call context. In practice, render your normal text/image/data parts with `MessagePrimitive.Parts`, and render `ChainOfThoughtPrimitive` separately where you want the collapsible reasoning block to appear.
|
|
118
|
+
|
|
119
|
+
### Collapsed State
|
|
120
|
+
|
|
121
|
+
The accordion starts collapsed by default. `AccordionTrigger` toggles between collapsed and expanded. Use `AuiIf` to conditionally render parts based on the collapsed state:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { AuiIf, ChainOfThoughtPrimitive } from "@assistant-ui/react";
|
|
125
|
+
|
|
126
|
+
<ChainOfThoughtPrimitive.Root>
|
|
127
|
+
<ChainOfThoughtPrimitive.AccordionTrigger>
|
|
128
|
+
Thinking
|
|
129
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
130
|
+
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
131
|
+
<ChainOfThoughtPrimitive.Parts
|
|
132
|
+
components={{ Reasoning }}
|
|
133
|
+
/>
|
|
134
|
+
</AuiIf>
|
|
135
|
+
</ChainOfThoughtPrimitive.Root>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Chevron Indicators
|
|
139
|
+
|
|
140
|
+
Use `AuiIf` to show directional icons that reflect the current state:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
import { AuiIf, ChainOfThoughtPrimitive } from "@assistant-ui/react";
|
|
144
|
+
import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
|
|
145
|
+
|
|
146
|
+
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2 text-sm">
|
|
147
|
+
<AuiIf condition={(s) => s.chainOfThought.collapsed}>
|
|
148
|
+
<ChevronRightIcon className="size-4" />
|
|
149
|
+
</AuiIf>
|
|
150
|
+
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
151
|
+
<ChevronDownIcon className="size-4" />
|
|
152
|
+
</AuiIf>
|
|
153
|
+
Thinking
|
|
154
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Parts Components
|
|
158
|
+
|
|
159
|
+
`ChainOfThoughtPrimitive.Parts` accepts a `components` prop to control how each part type renders:
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
<ChainOfThoughtPrimitive.Parts
|
|
163
|
+
components={{
|
|
164
|
+
Reasoning: ({ text }) => (
|
|
165
|
+
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
166
|
+
{text}
|
|
167
|
+
</p>
|
|
168
|
+
),
|
|
169
|
+
tools: {
|
|
170
|
+
Fallback: ({ toolName, status }) => (
|
|
171
|
+
<div className="px-4 py-2 text-sm">
|
|
172
|
+
{status.type === "running" ? `Running ${toolName}...` : `${toolName} completed`}
|
|
173
|
+
</div>
|
|
174
|
+
),
|
|
175
|
+
},
|
|
176
|
+
Layout: ({ children }) => (
|
|
177
|
+
<div className="border-t">{children}</div>
|
|
178
|
+
),
|
|
179
|
+
}}
|
|
180
|
+
/>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| Prop | Type | Description |
|
|
184
|
+
|------|------|-------------|
|
|
185
|
+
| `components.Reasoning` | `FC<{ text: string }>` | Renders reasoning parts |
|
|
186
|
+
| `components.tools.Fallback` | `ToolCallMessagePartComponent` | Fallback for tool-call parts |
|
|
187
|
+
| `components.Layout` | `ComponentType<PropsWithChildren>` | Wrapper around each rendered part |
|
|
188
|
+
|
|
189
|
+
## Parts
|
|
190
|
+
|
|
191
|
+
### Root
|
|
192
|
+
|
|
193
|
+
Container for the chain-of-thought disclosure UI. Renders a `<div>` element unless `asChild` is set.
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
<ChainOfThoughtPrimitive.Root className="rounded-lg border">
|
|
197
|
+
...
|
|
198
|
+
</ChainOfThoughtPrimitive.Root>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### AccordionTrigger
|
|
202
|
+
|
|
203
|
+
Trigger that toggles the collapsed state. Renders a `<button>` element unless `asChild` is set.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full items-center justify-between px-4 py-2 text-sm">
|
|
207
|
+
Thinking
|
|
208
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Parts
|
|
212
|
+
|
|
213
|
+
Renders reasoning and tool-call parts. This component does not track collapsed state internally, so control visibility with `AuiIf` as shown in the patterns below.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<ChainOfThoughtPrimitive.Parts
|
|
217
|
+
components={{
|
|
218
|
+
Reasoning: ({ text }) => (
|
|
219
|
+
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
220
|
+
{text}
|
|
221
|
+
</p>
|
|
222
|
+
),
|
|
223
|
+
tools: {
|
|
224
|
+
Fallback: ({ toolName, status }) => (
|
|
225
|
+
<div className="px-4 py-2 text-sm">
|
|
226
|
+
{status.type === "running" ? `Running ${toolName}...` : `${toolName} completed`}
|
|
227
|
+
</div>
|
|
228
|
+
),
|
|
229
|
+
},
|
|
230
|
+
}}
|
|
231
|
+
/>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
<PrimitivesTypeTable type="ChainOfThoughtPrimitivePartsProps" parameters={ChainOfThoughtPrimitiveDocs.Parts.props} />
|
|
235
|
+
|
|
236
|
+
## Patterns
|
|
237
|
+
|
|
238
|
+
### Minimal Accordion
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
function ChainOfThought() {
|
|
242
|
+
return (
|
|
243
|
+
<ChainOfThoughtPrimitive.Root className="my-2 rounded-lg border">
|
|
244
|
+
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2 font-medium text-sm hover:bg-muted/50">
|
|
245
|
+
Thinking
|
|
246
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
247
|
+
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
248
|
+
<ChainOfThoughtPrimitive.Parts
|
|
249
|
+
components={{
|
|
250
|
+
Reasoning: ({ text }) => (
|
|
251
|
+
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
252
|
+
{text}
|
|
253
|
+
</p>
|
|
254
|
+
),
|
|
255
|
+
}}
|
|
256
|
+
/>
|
|
257
|
+
</AuiIf>
|
|
258
|
+
</ChainOfThoughtPrimitive.Root>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### With Tool Calls
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
function ChainOfThought() {
|
|
267
|
+
return (
|
|
268
|
+
<ChainOfThoughtPrimitive.Root className="my-2 rounded-lg border">
|
|
269
|
+
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2 font-medium text-sm hover:bg-muted/50">
|
|
270
|
+
Thinking
|
|
271
|
+
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
272
|
+
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
273
|
+
<ChainOfThoughtPrimitive.Parts
|
|
274
|
+
components={{
|
|
275
|
+
Reasoning: ({ text }) => (
|
|
276
|
+
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
277
|
+
{text}
|
|
278
|
+
</p>
|
|
279
|
+
),
|
|
280
|
+
tools: {
|
|
281
|
+
Fallback: ({ toolName, status }) => (
|
|
282
|
+
<div className="flex items-center gap-2 px-4 py-2 text-sm">
|
|
283
|
+
<span className="font-medium">{toolName}</span>
|
|
284
|
+
<span className="text-muted-foreground">
|
|
285
|
+
{status.type === "running" ? "running..." : "done"}
|
|
286
|
+
</span>
|
|
287
|
+
</div>
|
|
288
|
+
),
|
|
289
|
+
},
|
|
290
|
+
Layout: ({ children }) => (
|
|
291
|
+
<div className="border-t">{children}</div>
|
|
292
|
+
),
|
|
293
|
+
}}
|
|
294
|
+
/>
|
|
295
|
+
</AuiIf>
|
|
296
|
+
</ChainOfThoughtPrimitive.Root>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Relationship to Components
|
|
302
|
+
|
|
303
|
+
The [Chain of Thought guide](/docs/guides/chain-of-thought) covers end-to-end setup including backend configuration with reasoning models. See the complete [with-chain-of-thought example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-chain-of-thought) for a full working implementation.
|
|
304
|
+
|
|
305
|
+
## API Reference
|
|
306
|
+
|
|
307
|
+
For the complete guide including backend configuration, see [Chain of Thought](/docs/guides/chain-of-thought). For prop details, see the [ChainOfThoughtPrimitive source](https://github.com/assistant-ui/assistant-ui/tree/main/packages/react/src/primitives/chainOfThought).
|
|
308
|
+
|
|
309
|
+
Related:
|
|
310
|
+
- [Chain of Thought Guide](/docs/guides/chain-of-thought)
|
|
311
|
+
- [MessagePrimitive](/docs/primitives/message)
|