@assistant-ui/mcp-docs-server 0.1.4 → 0.1.6
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 +10 -10
- package/.docs/organized/code-examples/search-agent-for-e-commerce.md +14 -14
- package/.docs/organized/code-examples/{with-vercel-ai-rsc.md → with-ai-sdk-v5.md} +259 -229
- package/.docs/organized/code-examples/with-ai-sdk.md +11 -10
- package/.docs/organized/code-examples/with-cloud.md +9 -8
- package/.docs/organized/code-examples/with-external-store.md +6 -6
- package/.docs/organized/code-examples/with-ffmpeg.md +15 -16
- package/.docs/organized/code-examples/with-langgraph.md +9 -8
- package/.docs/organized/code-examples/with-openai-assistants.md +9 -9
- package/.docs/organized/code-examples/with-parent-id-grouping.md +1377 -0
- package/.docs/organized/code-examples/with-react-hook-form.md +14 -15
- package/.docs/raw/docs/about-assistantui.mdx +9 -0
- package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +89 -32
- package/.docs/raw/docs/cloud/persistence/langgraph.mdx +187 -32
- package/.docs/raw/docs/guides/Latex.mdx +107 -0
- package/.docs/raw/docs/guides/ToolUI.mdx +0 -32
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat-v5.mdx +212 -0
- package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +1 -1
- package/.docs/raw/docs/runtimes/custom/local.mdx +1 -1
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +2 -2
- package/.docs/raw/docs/ui/PartGrouping.mdx +540 -0
- package/.docs/raw/docs/ui/ToolGroup.mdx +96 -0
- package/dist/{chunk-JS4PWCVA.js → chunk-L4K23SWI.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import { openai } from "@ai-sdk/openai";
|
|
7
|
-
import { frontendTools } from "@assistant-ui/react-ai-sdk";
|
|
7
|
+
import { frontendTools } from "@assistant-ui/react-ai-sdk-v4";
|
|
8
8
|
import { streamText } from "ai";
|
|
9
9
|
|
|
10
10
|
export const runtime = "edge";
|
|
@@ -189,7 +189,7 @@ export default function RootLayout({
|
|
|
189
189
|
"use client";
|
|
190
190
|
|
|
191
191
|
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
192
|
-
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
192
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk-v4";
|
|
193
193
|
|
|
194
194
|
export function MyRuntimeProvider({
|
|
195
195
|
children,
|
|
@@ -1654,7 +1654,7 @@ export default nextConfig;
|
|
|
1654
1654
|
"@assistant-ui/react-ai-sdk": "workspace:*",
|
|
1655
1655
|
"@assistant-ui/react-hook-form": "workspace:*",
|
|
1656
1656
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
1657
|
-
"@hookform/resolvers": "^5.
|
|
1657
|
+
"@hookform/resolvers": "^5.2.1",
|
|
1658
1658
|
"@radix-ui/react-avatar": "^1.1.10",
|
|
1659
1659
|
"@radix-ui/react-icons": "^1.3.2",
|
|
1660
1660
|
"@radix-ui/react-label": "^2.1.7",
|
|
@@ -1666,18 +1666,17 @@ export default nextConfig;
|
|
|
1666
1666
|
"class-variance-authority": "^0.7.1",
|
|
1667
1667
|
"clsx": "^2.1.1",
|
|
1668
1668
|
"json-schema-to-zod": "^2.6.1",
|
|
1669
|
-
"lucide-react": "^0.
|
|
1670
|
-
"next": "15.
|
|
1671
|
-
"react": "19.1.
|
|
1672
|
-
"react-dom": "19.1.
|
|
1673
|
-
"react-hook-form": "^7.
|
|
1674
|
-
"react-resizable-panels": "^3.0.
|
|
1669
|
+
"lucide-react": "^0.535.0",
|
|
1670
|
+
"next": "15.4.5",
|
|
1671
|
+
"react": "19.1.1",
|
|
1672
|
+
"react-dom": "19.1.1",
|
|
1673
|
+
"react-hook-form": "^7.61.1",
|
|
1674
|
+
"react-resizable-panels": "^3.0.4",
|
|
1675
1675
|
"remark-gfm": "^4.0.1",
|
|
1676
1676
|
"tailwind-merge": "^3.3.1",
|
|
1677
|
-
"tw-animate-css": "^1.3.
|
|
1678
|
-
"zod": "^
|
|
1679
|
-
"
|
|
1680
|
-
"zustand": "^5.0.6"
|
|
1677
|
+
"tw-animate-css": "^1.3.6",
|
|
1678
|
+
"zod": "^4.0.14",
|
|
1679
|
+
"zustand": "^5.0.7"
|
|
1681
1680
|
},
|
|
1682
1681
|
"devDependencies": {
|
|
1683
1682
|
"@assistant-ui/x-buildutils": "workspace:*",
|
|
@@ -1685,10 +1684,10 @@ export default nextConfig;
|
|
|
1685
1684
|
"@types/react": "^19",
|
|
1686
1685
|
"@types/react-dom": "^19",
|
|
1687
1686
|
"eslint": "^9",
|
|
1688
|
-
"eslint-config-next": "15.
|
|
1687
|
+
"eslint-config-next": "15.4.5",
|
|
1689
1688
|
"postcss": "^8",
|
|
1690
1689
|
"tailwindcss": "^4.1.11",
|
|
1691
|
-
"typescript": "^5.
|
|
1690
|
+
"typescript": "^5.9.2"
|
|
1692
1691
|
}
|
|
1693
1692
|
}
|
|
1694
1693
|
|
|
@@ -41,4 +41,13 @@ assistant-ui helps you create beautiful, enterprise-grade AI chat interfaces in
|
|
|
41
41
|
[Get Started in 30 Seconds](/docs/getting-started).
|
|
42
42
|
</Callout>
|
|
43
43
|
|
|
44
|
+
## AI Accessible Documentation
|
|
45
|
+
|
|
46
|
+
Our docs are easily accessible to AI assistants through several methods:
|
|
47
|
+
|
|
48
|
+
- **[MCP Docs Server](/docs/mcp-docs-server)** - Direct MCP integration for IDEs and agents
|
|
49
|
+
- **`/llms.txt`** - Structured index of all documentation pages
|
|
50
|
+
- **`/llms-full.txt`** - Complete documentation in a single file
|
|
51
|
+
- **`.mdx` suffix** - Add `.mdx` to any page's URL for raw markdown content
|
|
52
|
+
|
|
44
53
|
|
|
@@ -2,53 +2,110 @@
|
|
|
2
2
|
title: Chat History for AI SDK
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { Steps, Step } from 'fumadocs-ui/components/steps';
|
|
6
|
+
import { Callout } from 'fumadocs-ui/components/callout';
|
|
7
|
+
|
|
5
8
|
## Overview
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
assistant-cloud provides thread management and persistent chat history for applications built with the [AI SDK by Vercel](https://sdk.vercel.ai/). This guide shows you how to integrate cloud persistence into your AI SDK application.
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
<Callout type="info">
|
|
15
|
+
You need an assistant-cloud account to follow this guide. [Sign up here](https://cloud.assistant-ui.com/) to get started.
|
|
16
|
+
</Callout>
|
|
17
|
+
|
|
18
|
+
## Setup Guide
|
|
19
|
+
|
|
20
|
+
<Steps>
|
|
21
|
+
|
|
22
|
+
<Step>
|
|
23
|
+
|
|
24
|
+
### Create a Cloud Project
|
|
25
|
+
|
|
26
|
+
Create a new project in the [assistant-cloud dashboard](https://cloud.assistant-ui.com/) and from the settings page, copy:
|
|
27
|
+
|
|
28
|
+
- **Frontend API URL**: `https://proj-[ID].assistant-api.com`
|
|
29
|
+
- **Assistant Cloud API Key**: `sk_aui_proj_*`
|
|
30
|
+
|
|
31
|
+
</Step>
|
|
32
|
+
|
|
33
|
+
<Step>
|
|
34
|
+
|
|
35
|
+
### Configure Environment Variables
|
|
36
|
+
|
|
37
|
+
Add the following environment variables to your project:
|
|
8
38
|
|
|
9
|
-
|
|
39
|
+
```bash title=".env.local"
|
|
40
|
+
# Frontend API URL from your cloud project settings
|
|
41
|
+
NEXT_PUBLIC_ASSISTANT_BASE_URL=https://proj-[YOUR-ID].assistant-api.com
|
|
10
42
|
|
|
11
|
-
|
|
43
|
+
# API key for server-side operations
|
|
44
|
+
ASSISTANT_API_KEY=your-api-key-here
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
</Step>
|
|
12
48
|
|
|
13
|
-
|
|
49
|
+
<Step>
|
|
14
50
|
|
|
15
|
-
|
|
16
|
-
|
|
51
|
+
### Install Dependencies
|
|
52
|
+
|
|
53
|
+
Install the required packages:
|
|
17
54
|
|
|
18
55
|
```bash
|
|
19
|
-
|
|
56
|
+
npm install @assistant-ui/react @assistant-ui/react-ai-sdk
|
|
20
57
|
```
|
|
21
|
-
3. Create a client side AssistantCloud instance. Note: this will create an anonymous user id that is tied to the user's browser session. For connecting to an auth provider to persist threads for a user based on a workspace and/or user id, look at [Cloud Authorization Docs](/docs/cloud/authorization).
|
|
22
58
|
|
|
23
|
-
|
|
59
|
+
</Step>
|
|
60
|
+
|
|
61
|
+
<Step>
|
|
62
|
+
|
|
63
|
+
### Set Up the Cloud Runtime
|
|
64
|
+
|
|
65
|
+
Create a client-side AssistantCloud instance and integrate it with your AI SDK runtime:
|
|
66
|
+
|
|
67
|
+
```tsx title="app/chat/page.tsx"
|
|
24
68
|
"use client";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
AssistantRuntimeProvider,
|
|
28
|
-
ThreadList,
|
|
29
|
-
Thread
|
|
30
|
-
} from "@assistant-ui/react";
|
|
69
|
+
|
|
70
|
+
import { AssistantCloud, AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
31
71
|
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
72
|
+
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
73
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
74
|
+
|
|
75
|
+
export default function ChatPage() {
|
|
76
|
+
const cloud = new AssistantCloud({
|
|
77
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
78
|
+
anonymous: true, // Creates browser-session based user ID
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const runtime = useChatRuntime({
|
|
82
|
+
api: "/api/chat", // Your AI SDK endpoint
|
|
83
|
+
cloud,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
88
|
+
<div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
|
|
89
|
+
<ThreadList />
|
|
90
|
+
<Thread />
|
|
91
|
+
</div>
|
|
92
|
+
</AssistantRuntimeProvider>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
</Step>
|
|
32
98
|
|
|
99
|
+
</Steps>
|
|
33
100
|
|
|
34
|
-
|
|
35
|
-
baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
|
|
36
|
-
anonymous: true,
|
|
37
|
-
});
|
|
101
|
+
## Authentication
|
|
38
102
|
|
|
103
|
+
The example above uses `anonymous: true` which creates a browser session-based user ID. This is suitable for public demos or prototypes.
|
|
39
104
|
|
|
40
|
-
|
|
41
|
-
api: "/api/chat",
|
|
42
|
-
cloud,
|
|
43
|
-
});
|
|
105
|
+
For production apps with user accounts, see the [Cloud Authorization](/docs/cloud/authorization) guide to persist threads per user or workspace.
|
|
44
106
|
|
|
45
|
-
|
|
46
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
|
47
|
-
<div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
|
|
48
|
-
<ThreadList />
|
|
49
|
-
<Thread />
|
|
50
|
-
</div>
|
|
51
|
-
</AssistantRuntimeProvider>
|
|
52
|
-
);
|
|
107
|
+
## Next Steps
|
|
53
108
|
|
|
54
|
-
|
|
109
|
+
- Learn about [user authentication](/docs/cloud/authorization) for multi-user applications
|
|
110
|
+
- Explore [runtime hooks](/docs/api-reference/integrations/vercel-ai-sdk) and integration options
|
|
111
|
+
- Check out the [complete example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-cloud) on GitHub
|
|
@@ -2,37 +2,74 @@
|
|
|
2
2
|
title: Chat History for LangGraph Cloud
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
import { Steps, Step } from 'fumadocs-ui/components/steps';
|
|
6
|
+
import { Callout } from 'fumadocs-ui/components/callout';
|
|
7
|
+
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
|
|
8
|
+
|
|
5
9
|
## Overview
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
assistant-cloud provides thread management and persistent chat history for applications built with [LangGraph Cloud](https://langchain-ai.github.io/langgraph/cloud/). This guide shows you how to integrate cloud persistence into your LangGraph application.
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
<Callout type="info">
|
|
16
|
+
You need an assistant-cloud account to follow this guide. [Sign up here](https://cloud.assistant-ui.com/) to get started.
|
|
17
|
+
</Callout>
|
|
18
|
+
|
|
19
|
+
## Setup Guide
|
|
20
|
+
|
|
21
|
+
<Steps>
|
|
22
|
+
|
|
23
|
+
<Step>
|
|
24
|
+
|
|
25
|
+
### Create a Cloud Project
|
|
26
|
+
|
|
27
|
+
Create a new project in the [assistant-cloud dashboard](https://cloud.assistant-ui.com/) and from the settings page, copy:
|
|
28
|
+
|
|
29
|
+
- **Frontend API URL**: `https://proj-[ID].assistant-api.com`
|
|
30
|
+
- **API Key**: For server-side operations
|
|
31
|
+
|
|
32
|
+
</Step>
|
|
33
|
+
|
|
34
|
+
<Step>
|
|
35
|
+
|
|
36
|
+
### Configure Environment Variables
|
|
9
37
|
|
|
10
|
-
|
|
38
|
+
Add the following environment variables to your project:
|
|
11
39
|
|
|
12
|
-
|
|
13
|
-
|
|
40
|
+
```bash title=".env.local"
|
|
41
|
+
# Frontend API URL from your cloud project settings
|
|
42
|
+
NEXT_PUBLIC_ASSISTANT_BASE_URL=https://proj-[YOUR-ID].assistant-api.com
|
|
14
43
|
|
|
15
|
-
|
|
44
|
+
# API key for server-side operations
|
|
45
|
+
ASSISTANT_API_KEY=your-api-key-here
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</Step>
|
|
16
49
|
|
|
17
|
-
|
|
50
|
+
<Step>
|
|
18
51
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
52
|
+
### Install Dependencies
|
|
53
|
+
|
|
54
|
+
Install the required packages:
|
|
22
55
|
|
|
23
56
|
```bash
|
|
24
|
-
|
|
57
|
+
npm install @assistant-ui/react @assistant-ui/react-langgraph
|
|
25
58
|
```
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
</Step>
|
|
61
|
+
|
|
62
|
+
<Step>
|
|
28
63
|
|
|
29
|
-
|
|
64
|
+
### Create the Runtime Provider
|
|
30
65
|
|
|
31
|
-
|
|
66
|
+
Create a runtime provider that integrates LangGraph with assistant-cloud. Choose between anonymous mode for demos/prototypes or authenticated mode for production:
|
|
32
67
|
|
|
33
|
-
|
|
34
|
-
// @errors: 2307
|
|
68
|
+
<Tabs items={["Anonymous", "Authenticated (Clerk)"]}>
|
|
35
69
|
|
|
70
|
+
<Tab value="Anonymous">
|
|
71
|
+
|
|
72
|
+
```tsx title="app/chat/runtime-provider.tsx"
|
|
36
73
|
"use client";
|
|
37
74
|
|
|
38
75
|
import {
|
|
@@ -44,19 +81,22 @@ import {
|
|
|
44
81
|
import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
45
82
|
import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
46
83
|
import { LangChainMessage } from "@assistant-ui/react-langgraph";
|
|
47
|
-
import { useAuth } from "@clerk/nextjs";
|
|
48
84
|
import { useMemo } from "react";
|
|
49
85
|
|
|
50
|
-
// ---cut---
|
|
51
86
|
const useMyLangGraphRuntime = () => {
|
|
52
87
|
const threadListItemRuntime = useThreadListItemRuntime();
|
|
88
|
+
|
|
53
89
|
const runtime = useLangGraphRuntime({
|
|
54
90
|
stream: async function* (messages) {
|
|
55
91
|
const { externalId } = await threadListItemRuntime.initialize();
|
|
56
92
|
if (!externalId) throw new Error("Thread not found");
|
|
57
93
|
|
|
58
|
-
return sendMessage({
|
|
94
|
+
return sendMessage({
|
|
95
|
+
threadId: externalId,
|
|
96
|
+
messages,
|
|
97
|
+
});
|
|
59
98
|
},
|
|
99
|
+
|
|
60
100
|
onSwitchToThread: async (externalId) => {
|
|
61
101
|
const state = await getThreadState(externalId);
|
|
62
102
|
return {
|
|
@@ -69,6 +109,82 @@ const useMyLangGraphRuntime = () => {
|
|
|
69
109
|
return runtime;
|
|
70
110
|
};
|
|
71
111
|
|
|
112
|
+
export function MyRuntimeProvider({
|
|
113
|
+
children,
|
|
114
|
+
}: Readonly<{
|
|
115
|
+
children: React.ReactNode;
|
|
116
|
+
}>) {
|
|
117
|
+
const cloud = useMemo(
|
|
118
|
+
() =>
|
|
119
|
+
new AssistantCloud({
|
|
120
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
121
|
+
anonymous: true, // Creates browser session-based user ID
|
|
122
|
+
}),
|
|
123
|
+
[],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const runtime = useCloudThreadListRuntime({
|
|
127
|
+
cloud,
|
|
128
|
+
runtimeHook: useMyLangGraphRuntime,
|
|
129
|
+
create: async () => {
|
|
130
|
+
const { thread_id } = await createThread();
|
|
131
|
+
return { externalId: thread_id };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
137
|
+
{children}
|
|
138
|
+
</AssistantRuntimeProvider>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
</Tab>
|
|
144
|
+
|
|
145
|
+
<Tab value="Authenticated (Clerk)">
|
|
146
|
+
|
|
147
|
+
```tsx title="app/chat/runtime-provider.tsx"
|
|
148
|
+
"use client";
|
|
149
|
+
|
|
150
|
+
import {
|
|
151
|
+
AssistantCloud,
|
|
152
|
+
AssistantRuntimeProvider,
|
|
153
|
+
useCloudThreadListRuntime,
|
|
154
|
+
useThreadListItemRuntime,
|
|
155
|
+
} from "@assistant-ui/react";
|
|
156
|
+
import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
|
|
157
|
+
import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
|
|
158
|
+
import { LangChainMessage } from "@assistant-ui/react-langgraph";
|
|
159
|
+
import { useAuth } from "@clerk/nextjs";
|
|
160
|
+
import { useMemo } from "react";
|
|
161
|
+
|
|
162
|
+
const useMyLangGraphRuntime = () => {
|
|
163
|
+
const threadListItemRuntime = useThreadListItemRuntime();
|
|
164
|
+
|
|
165
|
+
const runtime = useLangGraphRuntime({
|
|
166
|
+
stream: async function* (messages) {
|
|
167
|
+
const { externalId } = await threadListItemRuntime.initialize();
|
|
168
|
+
if (!externalId) throw new Error("Thread not found");
|
|
169
|
+
|
|
170
|
+
return sendMessage({
|
|
171
|
+
threadId: externalId,
|
|
172
|
+
messages,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
onSwitchToThread: async (externalId) => {
|
|
177
|
+
const state = await getThreadState(externalId);
|
|
178
|
+
return {
|
|
179
|
+
messages:
|
|
180
|
+
(state.values as { messages?: LangChainMessage[] }).messages ?? []
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return runtime;
|
|
186
|
+
};
|
|
187
|
+
|
|
72
188
|
export function MyRuntimeProvider({
|
|
73
189
|
children,
|
|
74
190
|
}: Readonly<{
|
|
@@ -79,7 +195,7 @@ export function MyRuntimeProvider({
|
|
|
79
195
|
const cloud = useMemo(
|
|
80
196
|
() =>
|
|
81
197
|
new AssistantCloud({
|
|
82
|
-
baseUrl: process.env
|
|
198
|
+
baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL!,
|
|
83
199
|
authToken: async () => getToken({ template: "assistant-ui" }),
|
|
84
200
|
}),
|
|
85
201
|
[getToken],
|
|
@@ -102,22 +218,61 @@ export function MyRuntimeProvider({
|
|
|
102
218
|
}
|
|
103
219
|
```
|
|
104
220
|
|
|
105
|
-
<Callout
|
|
106
|
-
|
|
107
|
-
function. This hook will be mounted multiple times, once per active thread.
|
|
221
|
+
<Callout type="info">
|
|
222
|
+
For Clerk authentication, configure the `"assistant-ui"` token template in your Clerk dashboard.
|
|
108
223
|
</Callout>
|
|
109
224
|
|
|
110
|
-
|
|
225
|
+
</Tab>
|
|
111
226
|
|
|
112
|
-
|
|
227
|
+
</Tabs>
|
|
113
228
|
|
|
114
|
-
|
|
115
|
-
|
|
229
|
+
<Callout type="info">
|
|
230
|
+
The `useMyLangGraphRuntime` hook is extracted into a separate function because it will be mounted multiple times, once per active thread.
|
|
231
|
+
</Callout>
|
|
232
|
+
|
|
233
|
+
</Step>
|
|
234
|
+
|
|
235
|
+
<Step>
|
|
236
|
+
|
|
237
|
+
### Add Thread UI Components
|
|
238
|
+
|
|
239
|
+
Install the thread list component:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
npx assistant-ui add thread-list
|
|
116
243
|
```
|
|
117
244
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
245
|
+
Then add it to your application layout:
|
|
246
|
+
|
|
247
|
+
```tsx title="app/chat/page.tsx"
|
|
248
|
+
import { Thread } from "@/components/assistant-ui/thread";
|
|
249
|
+
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
250
|
+
|
|
251
|
+
export default function ChatPage() {
|
|
252
|
+
return (
|
|
253
|
+
<div className="grid h-dvh grid-cols-[250px_1fr] gap-x-2">
|
|
254
|
+
<ThreadList />
|
|
255
|
+
<Thread />
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
123
259
|
```
|
|
260
|
+
|
|
261
|
+
</Step>
|
|
262
|
+
|
|
263
|
+
</Steps>
|
|
264
|
+
|
|
265
|
+
## Authentication
|
|
266
|
+
|
|
267
|
+
The examples above show two authentication modes:
|
|
268
|
+
|
|
269
|
+
- **Anonymous**: Suitable for demos and prototypes. Creates a browser session-based user ID.
|
|
270
|
+
- **Authenticated**: For production use with user accounts. The authenticated example uses [Clerk](https://clerk.com/), but you can integrate any auth provider.
|
|
271
|
+
|
|
272
|
+
For other authentication providers or custom implementations, see the [Cloud Authorization](/docs/cloud/authorization) guide.
|
|
273
|
+
|
|
274
|
+
## Next Steps
|
|
275
|
+
|
|
276
|
+
- Learn about [LangGraph runtime setup](/docs/runtimes/langgraph) for your application
|
|
277
|
+
- Explore [ThreadListRuntime](/docs/api-reference/runtimes/ThreadListRuntime) for advanced thread management
|
|
278
|
+
- Check out the [LangGraph example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-langgraph) on GitHub
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: LaTeX
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { Steps, Step } from "fumadocs-ui/components/steps";
|
|
6
|
+
import { Callout } from "fumadocs-ui/components/callout";
|
|
7
|
+
|
|
8
|
+
Render LaTeX mathematical expressions in chat messages using KaTeX.
|
|
9
|
+
|
|
10
|
+
<Callout type="warn">LaTeX rendering is not enabled in markdown by default.</Callout>
|
|
11
|
+
|
|
12
|
+
<Steps>
|
|
13
|
+
<Step>
|
|
14
|
+
|
|
15
|
+
### Install dependencies
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i katex rehype-katex remark-math
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</Step>
|
|
22
|
+
<Step>
|
|
23
|
+
|
|
24
|
+
### Add KaTeX CSS to your layout
|
|
25
|
+
|
|
26
|
+
```tsx title="/app/layout.tsx"
|
|
27
|
+
import "katex/dist/katex.min.css"; // [!code ++]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
</Step>
|
|
31
|
+
<Step>
|
|
32
|
+
|
|
33
|
+
### Update `markdown-text.tsx`
|
|
34
|
+
|
|
35
|
+
```tsx title="/components/assistant-ui/markdown-text.tsx"
|
|
36
|
+
import remarkMath from "remark-math"; // [!code ++]
|
|
37
|
+
import rehypeKatex from "rehype-katex"; // [!code ++]
|
|
38
|
+
|
|
39
|
+
const MarkdownTextImpl = () => {
|
|
40
|
+
return (
|
|
41
|
+
<MarkdownTextPrimitive
|
|
42
|
+
remarkPlugins={[remarkGfm, remarkMath]} // add remarkMath // [!code ++]
|
|
43
|
+
rehypePlugins={[rehypeKatex]} // add rehypeKatex // [!code ++]
|
|
44
|
+
className="aui-md"
|
|
45
|
+
components={defaultComponents}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const MarkdownText = memo(MarkdownTextImpl);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
</Step>
|
|
54
|
+
</Steps>
|
|
55
|
+
|
|
56
|
+
## Supported Formats
|
|
57
|
+
|
|
58
|
+
By default, remark-math supports:
|
|
59
|
+
- `$...$` for inline math
|
|
60
|
+
- `$$...$$` for display math
|
|
61
|
+
- Fenced code blocks with the `math` language identifier
|
|
62
|
+
|
|
63
|
+
## Supporting Alternative LaTeX Delimiters
|
|
64
|
+
|
|
65
|
+
Many language models generate LaTeX using different delimiter formats:
|
|
66
|
+
- `\(...\)` for inline math
|
|
67
|
+
- `\[...\]` for display math
|
|
68
|
+
- Custom formats like `[/math]...[/math]`
|
|
69
|
+
|
|
70
|
+
You can use the `preprocess` prop to normalize these formats:
|
|
71
|
+
|
|
72
|
+
```tsx title="/components/assistant-ui/markdown-text.tsx"
|
|
73
|
+
const MarkdownTextImpl = () => {
|
|
74
|
+
return (
|
|
75
|
+
<MarkdownTextPrimitive
|
|
76
|
+
remarkPlugins={[remarkGfm, remarkMath]}
|
|
77
|
+
rehypePlugins={[rehypeKatex]}
|
|
78
|
+
preprocess={normalizeCustomMathTags} // [!code ++]
|
|
79
|
+
className="aui-md"
|
|
80
|
+
components={defaultComponents}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Your LaTeX preprocessing function
|
|
86
|
+
function normalizeCustomMathTags(input: string): string {
|
|
87
|
+
return (
|
|
88
|
+
input
|
|
89
|
+
// Convert [/math]...[/math] to $$...$$
|
|
90
|
+
.replace(/\[\/math\]([\s\S]*?)\[\/math\]/g, (_, content) => `$$${content.trim()}$$`)
|
|
91
|
+
|
|
92
|
+
// Convert [/inline]...[/inline] to $...$
|
|
93
|
+
.replace(/\[\/inline\]([\s\S]*?)\[\/inline\]/g, (_, content) => `$${content.trim()}$`)
|
|
94
|
+
|
|
95
|
+
// Convert \( ... \) to $...$ (inline math) - handles both single and double backslashes
|
|
96
|
+
.replace(/\\{1,2}\(([\s\S]*?)\\{1,2}\)/g, (_, content) => `$${content.trim()}$`)
|
|
97
|
+
|
|
98
|
+
// Convert \[ ... \] to $$...$$ (block math) - handles both single and double backslashes
|
|
99
|
+
.replace(/\\{1,2}\[([\s\S]*?)\\{1,2}\]/g, (_, content) => `$$${content.trim()}$$`)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
<Callout type="tip">
|
|
105
|
+
The preprocessing function runs before markdown parsing, allowing you to transform any delimiter format into the standard `$` and `$$` format.
|
|
106
|
+
</Callout>
|
|
107
|
+
|
|
@@ -663,38 +663,6 @@ useAssistantToolUI({
|
|
|
663
663
|
server.
|
|
664
664
|
</Callout>
|
|
665
665
|
|
|
666
|
-
### Collapsible Tool Groups
|
|
667
|
-
|
|
668
|
-
Create collapsible sections for consecutive tool calls:
|
|
669
|
-
|
|
670
|
-
```tsx
|
|
671
|
-
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
### Advanced Tool Group UI
|
|
675
|
-
|
|
676
|
-
Add progress indicators and enhanced styling:
|
|
677
|
-
|
|
678
|
-
```tsx
|
|
679
|
-
const ToolGroup = ({ startIndex, endIndex, children }) => {
|
|
680
|
-
return (
|
|
681
|
-
<details className="tool-group my-4">
|
|
682
|
-
<summary className="cursor-pointer rounded bg-gray-50 p-3 hover:bg-gray-100">
|
|
683
|
-
<span className="font-medium">
|
|
684
|
-
{endIndex - startIndex + 1} tool calls executed
|
|
685
|
-
</span>
|
|
686
|
-
<span className="ml-2 text-sm text-gray-500">
|
|
687
|
-
(#{startIndex + 1}-{endIndex + 1})
|
|
688
|
-
</span>
|
|
689
|
-
</summary>
|
|
690
|
-
<div className="mt-2 space-y-2 pl-4">{children}</div>
|
|
691
|
-
</details>
|
|
692
|
-
);
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
<Thread components={{ ToolGroup }} />;
|
|
696
|
-
```
|
|
697
|
-
|
|
698
666
|
## Related Guides
|
|
699
667
|
|
|
700
668
|
- [Tools Guide](/docs/guides/Tools) - Learn how to create and use tools with AI models
|