Migration to v0.8
This migration guide is for an upcoming release. More changes may land before v0.8.0 is released.
Styled Components moved to @assistant-ui/react-ui
All styled components (Thread, ThreadList, AssistantModal, makeMarkdownText, etc.) have been moved to a new package, @assistant-ui/react-ui
.
To migrate, use the migration codemod:
Vercel AI SDK RSC requires additional setup
Built-in RSC support in assistant-ui has been removed, so an additional setup step is required. The RSC runtime now requires additional setup to display React Server Components.
Migrate away from UIContentPart
For instructions on migrating for Vercel AI SDK RSC, see section above.
This migration guide is for users of useExternalStoreRuntime
.
Recommended Approach: Use ToolUI
First, reconsider your approach.
Creating UI components in the convertMessage
callback is considered an anti-pattern.
The recommended alternative approach is to pass tool-call content parts, and use makeAssistantToolUI
to map these tool calls to UI components.
This ensures that the data layer is separate and decoupled from the UI layer.
Example
Consider the following example, where you are using a UIContentPart to show a loading indicator.
(if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Content)
Example 2
Consider the following example, where you are displaying a custom chart based on data received from an external source.
(if you are using unstyled primitives, render the <ChartToolUI />
component anywhere inside your AssistantRuntimeProvider)
Fallback Approach: Override ContentPartText
However, sometimes you receive UI components from an external source.
The example below assumes that your custom MyMessage
type has a display
field.
First, we define a dummy UI_PLACEHOLDER
content part, which we will replace with the UI component later:
Then, we define a custom TextContentPartComponent
:
We pass this component to our Thread:
(if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Content)
Now, the UI_PLACEHOLDER
content part is replaced with the UI component we defined earlier.