@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
|
@@ -1,28 +1,41 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: Introduction
|
|
3
|
+
description: Beautiful, enterprise-grade AI chat interfaces for React applications.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { Sparkles, PanelsTopLeft, Database, Terminal, Bot } from "lucide-react";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
assistant-ui helps you create beautiful, enterprise-grade AI chat interfaces in minutes. Whether you're building a ChatGPT clone, a customer support chatbot, an AI assistant, or a complex multi-agent application, assistant-ui provides the frontend primitive components and state management layers to focus on what makes your application unique.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Key Features
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
<Cards>
|
|
13
|
+
<Card icon={<PanelsTopLeft className="text-purple-300" />} title="Instant Chat UI">
|
|
14
|
+
Pre-built beautiful, customizable chat interfaces out of the box. Easy to quickly iterate on your idea.
|
|
15
|
+
</Card>
|
|
16
|
+
|
|
17
|
+
<Card icon={<PanelsTopLeft className="text-blue-300" />} title="Chat State Management">
|
|
18
|
+
Powerful state management for chat interactions, optimized for streaming responses and efficient rendering.
|
|
19
|
+
</Card>
|
|
13
20
|
|
|
14
|
-
<
|
|
15
|
-
|
|
21
|
+
<Card icon={<Database className="text-green-300" />} title="High Performance">
|
|
22
|
+
Optimized for speed and efficiency with minimal bundle size, ensuring your AI chat interfaces remain responsive.
|
|
23
|
+
</Card>
|
|
24
|
+
|
|
25
|
+
<Card icon={<Terminal className="text-orange-300" />} title="Framework Agnostic">
|
|
26
|
+
Easily integrate with any backend system, whether using Vercel AI SDK, direct LLM connections, or custom solutions. Works with any React-based framework.
|
|
27
|
+
</Card>
|
|
28
|
+
</Cards>
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
## Quick Try
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
The fastest way to get started:
|
|
20
33
|
|
|
21
34
|
```sh
|
|
22
35
|
npx assistant-ui@latest create
|
|
23
36
|
```
|
|
24
37
|
|
|
25
|
-
Or choose a template:
|
|
38
|
+
This creates a new project with everything configured. Or choose a template:
|
|
26
39
|
|
|
27
40
|
```sh
|
|
28
41
|
# Assistant Cloud - with persistence and thread management
|
|
@@ -35,413 +48,23 @@ npx assistant-ui@latest create -t langgraph
|
|
|
35
48
|
npx assistant-ui@latest create -t mcp
|
|
36
49
|
```
|
|
37
50
|
|
|
38
|
-
**Add to an existing project:**
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
npx assistant-ui@latest init
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
</Step>
|
|
45
|
-
<Step>
|
|
46
|
-
|
|
47
|
-
### Add API key
|
|
48
|
-
|
|
49
|
-
Create a `.env` file with your API key:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
</Step>
|
|
56
|
-
<Step>
|
|
57
|
-
|
|
58
|
-
### Start the app
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
npm run dev
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
</Step>
|
|
65
|
-
</Steps>
|
|
66
|
-
|
|
67
|
-
## Add to Existing Project
|
|
68
|
-
|
|
69
|
-
If you prefer not to use the CLI, you can install components manually.
|
|
70
|
-
|
|
71
|
-
<Steps>
|
|
72
|
-
<Step>
|
|
73
|
-
|
|
74
|
-
### Add assistant-ui
|
|
75
|
-
|
|
76
|
-
<InstallCommand shadcn={["thread", "thread-list"]} manualSetupInstructions />
|
|
77
|
-
|
|
78
|
-
</Step>
|
|
79
|
-
<Step>
|
|
80
|
-
|
|
81
|
-
### Setup Backend Endpoint
|
|
82
|
-
|
|
83
|
-
Install provider SDK:
|
|
84
|
-
|
|
85
|
-
<Tabs groupId="provider" items={["OpenAI", "Anthropic", "Azure", "AWS", "Gemini", "GCP", "Groq", "Fireworks", "Cohere", "Ollama", "Chrome AI"]}>
|
|
86
|
-
<Tab>
|
|
87
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/openai"]} />
|
|
88
|
-
</Tab>
|
|
89
|
-
<Tab>
|
|
90
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/anthropic"]} />
|
|
91
|
-
</Tab>
|
|
92
|
-
<Tab>
|
|
93
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/azure"]} />
|
|
94
|
-
</Tab>
|
|
95
|
-
<Tab>
|
|
96
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/amazon-bedrock"]} />
|
|
97
|
-
</Tab>
|
|
98
|
-
<Tab>
|
|
99
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/google"]} />
|
|
100
|
-
</Tab>
|
|
101
|
-
<Tab>
|
|
102
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/google-vertex"]} />
|
|
103
|
-
</Tab>
|
|
104
|
-
<Tab>
|
|
105
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/openai"]} />
|
|
106
|
-
</Tab>
|
|
107
|
-
<Tab>
|
|
108
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/openai"]} />
|
|
109
|
-
</Tab>
|
|
110
|
-
<Tab>
|
|
111
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "@ai-sdk/cohere"]} />
|
|
112
|
-
</Tab>
|
|
113
|
-
<Tab>
|
|
114
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "ollama-ai-provider-v2"]} />
|
|
115
|
-
</Tab>
|
|
116
|
-
<Tab>
|
|
117
|
-
<InstallCommand npm={["ai", "@assistant-ui/react-ai-sdk", "chrome-ai"]} />
|
|
118
|
-
</Tab>
|
|
119
|
-
</Tabs>
|
|
120
|
-
|
|
121
|
-
Add an API endpoint:
|
|
122
|
-
|
|
123
|
-
<Tabs groupId="provider" items={["OpenAI", "Anthropic", "Azure", "AWS", "Gemini", "GCP", "Groq", "Fireworks", "Cohere", "Ollama", "Chrome AI"]}>
|
|
124
|
-
```ts title="/app/api/chat/route.ts" tab="OpenAI"
|
|
125
|
-
import { openai } from "@ai-sdk/openai";
|
|
126
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
127
|
-
|
|
128
|
-
export const maxDuration = 30;
|
|
129
|
-
|
|
130
|
-
export async function POST(req: Request) {
|
|
131
|
-
const { messages } = await req.json();
|
|
132
|
-
const result = streamText({
|
|
133
|
-
model: openai("gpt-4o-mini"),
|
|
134
|
-
messages: convertToModelMessages(messages),
|
|
135
|
-
});
|
|
136
|
-
return result.toUIMessageStreamResponse();
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
```ts title="/app/api/chat/route.ts" tab="Anthropic"
|
|
141
|
-
import { anthropic } from "@ai-sdk/anthropic";
|
|
142
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
143
|
-
|
|
144
|
-
export const maxDuration = 30;
|
|
145
|
-
|
|
146
|
-
export async function POST(req: Request) {
|
|
147
|
-
const { messages } = await req.json();
|
|
148
|
-
const result = streamText({
|
|
149
|
-
model: anthropic("claude-3-5-sonnet-20240620"),
|
|
150
|
-
messages: convertToModelMessages(messages),
|
|
151
|
-
});
|
|
152
|
-
return result.toUIMessageStreamResponse();
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
```ts title="/app/api/chat/route.ts" tab="Azure"
|
|
157
|
-
import { azure } from "@ai-sdk/azure";
|
|
158
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
159
|
-
|
|
160
|
-
export const maxDuration = 30;
|
|
161
|
-
|
|
162
|
-
export async function POST(req: Request) {
|
|
163
|
-
const { messages } = await req.json();
|
|
164
|
-
const result = streamText({
|
|
165
|
-
model: azure("your-deployment-name"),
|
|
166
|
-
messages: convertToModelMessages(messages),
|
|
167
|
-
});
|
|
168
|
-
return result.toUIMessageStreamResponse();
|
|
169
|
-
}
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
```ts title="/app/api/chat/route.ts" tab="AWS"
|
|
173
|
-
import { bedrock } from "@ai-sdk/amazon-bedrock";
|
|
174
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
175
|
-
|
|
176
|
-
export const maxDuration = 30;
|
|
177
|
-
|
|
178
|
-
export async function POST(req: Request) {
|
|
179
|
-
const { messages } = await req.json();
|
|
180
|
-
const result = streamText({
|
|
181
|
-
model: bedrock("anthropic.claude-3-5-sonnet-20240620-v1:0"),
|
|
182
|
-
messages: convertToModelMessages(messages),
|
|
183
|
-
});
|
|
184
|
-
return result.toUIMessageStreamResponse();
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
```ts title="/app/api/chat/route.ts" tab="Gemini"
|
|
189
|
-
import { google } from "@ai-sdk/google";
|
|
190
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
191
|
-
|
|
192
|
-
export const maxDuration = 30;
|
|
193
|
-
|
|
194
|
-
export async function POST(req: Request) {
|
|
195
|
-
const { messages } = await req.json();
|
|
196
|
-
const result = streamText({
|
|
197
|
-
model: google("gemini-2.0-flash"),
|
|
198
|
-
messages: convertToModelMessages(messages),
|
|
199
|
-
});
|
|
200
|
-
return result.toUIMessageStreamResponse();
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
```ts title="/app/api/chat/route.ts" tab="GCP"
|
|
205
|
-
import { vertex } from "@ai-sdk/google-vertex";
|
|
206
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
207
|
-
|
|
208
|
-
export const maxDuration = 30;
|
|
209
|
-
|
|
210
|
-
export async function POST(req: Request) {
|
|
211
|
-
const { messages } = await req.json();
|
|
212
|
-
const result = streamText({
|
|
213
|
-
model: vertex("gemini-1.5-pro"),
|
|
214
|
-
messages: convertToModelMessages(messages),
|
|
215
|
-
});
|
|
216
|
-
return result.toUIMessageStreamResponse();
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
```ts title="/app/api/chat/route.ts" tab="Groq"
|
|
221
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
222
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
223
|
-
|
|
224
|
-
export const maxDuration = 30;
|
|
225
|
-
|
|
226
|
-
const groq = createOpenAI({
|
|
227
|
-
apiKey: process.env.GROQ_API_KEY ?? "",
|
|
228
|
-
baseURL: "https://api.groq.com/openai/v1",
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
export async function POST(req: Request) {
|
|
232
|
-
const { messages } = await req.json();
|
|
233
|
-
const result = streamText({
|
|
234
|
-
model: groq("llama3-70b-8192"),
|
|
235
|
-
messages: convertToModelMessages(messages),
|
|
236
|
-
});
|
|
237
|
-
return result.toUIMessageStreamResponse();
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
```ts title="/app/api/chat/route.ts" tab="Fireworks"
|
|
242
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
243
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
244
|
-
|
|
245
|
-
export const maxDuration = 30;
|
|
246
|
-
|
|
247
|
-
const fireworks = createOpenAI({
|
|
248
|
-
apiKey: process.env.FIREWORKS_API_KEY ?? "",
|
|
249
|
-
baseURL: "https://api.fireworks.ai/inference/v1",
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
export async function POST(req: Request) {
|
|
253
|
-
const { messages } = await req.json();
|
|
254
|
-
const result = streamText({
|
|
255
|
-
model: fireworks("accounts/fireworks/models/firefunction-v2"),
|
|
256
|
-
messages: convertToModelMessages(messages),
|
|
257
|
-
});
|
|
258
|
-
return result.toUIMessageStreamResponse();
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
```ts title="/app/api/chat/route.ts" tab="Cohere"
|
|
263
|
-
import { cohere } from "@ai-sdk/cohere";
|
|
264
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
265
|
-
|
|
266
|
-
export const maxDuration = 30;
|
|
267
|
-
|
|
268
|
-
export async function POST(req: Request) {
|
|
269
|
-
const { messages } = await req.json();
|
|
270
|
-
const result = streamText({
|
|
271
|
-
model: cohere("command-r-plus"),
|
|
272
|
-
messages: convertToModelMessages(messages),
|
|
273
|
-
});
|
|
274
|
-
return result.toUIMessageStreamResponse();
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
```ts title="/app/api/chat/route.ts" tab="Ollama"
|
|
279
|
-
import { ollama } from "ollama-ai-provider-v2";
|
|
280
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
281
|
-
|
|
282
|
-
export const maxDuration = 30;
|
|
283
|
-
|
|
284
|
-
export async function POST(req: Request) {
|
|
285
|
-
const { messages } = await req.json();
|
|
286
|
-
const result = streamText({
|
|
287
|
-
model: ollama("llama3"),
|
|
288
|
-
messages: convertToModelMessages(messages),
|
|
289
|
-
});
|
|
290
|
-
return result.toUIMessageStreamResponse();
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
```ts title="/app/api/chat/route.ts" tab="Chrome AI"
|
|
295
|
-
import { chromeai } from "chrome-ai";
|
|
296
|
-
import { convertToModelMessages, streamText } from "ai";
|
|
297
|
-
|
|
298
|
-
export const maxDuration = 30;
|
|
299
|
-
|
|
300
|
-
export async function POST(req: Request) {
|
|
301
|
-
const { messages } = await req.json();
|
|
302
|
-
const result = streamText({
|
|
303
|
-
model: chromeai(),
|
|
304
|
-
messages: convertToModelMessages(messages),
|
|
305
|
-
});
|
|
306
|
-
return result.toUIMessageStreamResponse();
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
</Tabs>
|
|
311
|
-
|
|
312
|
-
Define environment variables:
|
|
313
|
-
|
|
314
|
-
<Tabs groupId="provider" items={["OpenAI", "Anthropic", "Azure", "AWS", "Gemini", "GCP", "Groq", "Fireworks", "Cohere", "Ollama", "Chrome AI"]}>
|
|
315
|
-
|
|
316
|
-
```sh title="/.env.local" tab="OpenAI"
|
|
317
|
-
OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
```sh title="/.env.local" tab="Anthropic"
|
|
321
|
-
ANTHROPIC_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
```sh title="/.env.local" tab="Azure"
|
|
325
|
-
AZURE_RESOURCE_NAME="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
326
|
-
AZURE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
```sh title="/.env.local" tab="AWS"
|
|
330
|
-
AWS_ACCESS_KEY_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
331
|
-
AWS_SECRET_ACCESS_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
332
|
-
AWS_REGION="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
```sh title="/.env.local" tab="Gemini"
|
|
336
|
-
GOOGLE_GENERATIVE_AI_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
```sh title="/.env.local" tab="GCP"
|
|
340
|
-
GOOGLE_VERTEX_PROJECT="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
341
|
-
GOOGLE_VERTEX_LOCATION="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
342
|
-
GOOGLE_APPLICATION_CREDENTIALS="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
```sh title="/.env.local" tab="Groq"
|
|
346
|
-
GROQ_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
```sh title="/.env.local" tab="Fireworks"
|
|
350
|
-
FIREWORKS_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
```sh title="/.env.local" tab="Cohere"
|
|
354
|
-
COHERE_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
```sh tab="Ollama"
|
|
358
|
-
<none>
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
```sh tab="Chrome AI"
|
|
362
|
-
<none>
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
</Tabs>
|
|
366
|
-
|
|
367
|
-
If you aren't using Next.js, you can also deploy this endpoint to Cloudflare Workers, or any other serverless platform.
|
|
368
|
-
|
|
369
|
-
</Step>
|
|
370
|
-
|
|
371
|
-
<Step>
|
|
372
|
-
|
|
373
|
-
### Use it in your app
|
|
374
|
-
|
|
375
|
-
<Tabs items={["Thread", "AssistantModal"]}>
|
|
376
|
-
|
|
377
|
-
```tsx title="/app/page.tsx" tab="Thread"
|
|
378
|
-
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
379
|
-
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
380
|
-
import { ThreadList } from "@/components/assistant-ui/thread-list";
|
|
381
|
-
import { Thread } from "@/components/assistant-ui/thread";
|
|
382
|
-
|
|
383
|
-
const MyApp = () => {
|
|
384
|
-
const runtime = useChatRuntime({
|
|
385
|
-
transport: new AssistantChatTransport({
|
|
386
|
-
api: "/api/chat",
|
|
387
|
-
}),
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
return (
|
|
391
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
|
392
|
-
<div>
|
|
393
|
-
<ThreadList />
|
|
394
|
-
<Thread />
|
|
395
|
-
</div>
|
|
396
|
-
</AssistantRuntimeProvider>
|
|
397
|
-
);
|
|
398
|
-
};
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
```tsx title="/app/page.tsx" tab="AssistantModal"
|
|
402
|
-
// run `npx shadcn@latest add https://r.assistant-ui.com/assistant-modal.json`
|
|
403
|
-
|
|
404
|
-
import { AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
405
|
-
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
|
|
406
|
-
import { AssistantModal } from "@/components/assistant-ui/assistant-modal";
|
|
407
|
-
|
|
408
|
-
const MyApp = () => {
|
|
409
|
-
const runtime = useChatRuntime({
|
|
410
|
-
transport: new AssistantChatTransport({
|
|
411
|
-
api: "/api/chat",
|
|
412
|
-
}),
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
return (
|
|
416
|
-
<AssistantRuntimeProvider runtime={runtime}>
|
|
417
|
-
<AssistantModal />
|
|
418
|
-
</AssistantRuntimeProvider>
|
|
419
|
-
);
|
|
420
|
-
};
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
</Tabs>
|
|
424
|
-
|
|
425
|
-
</Step>
|
|
426
|
-
</Steps>
|
|
427
|
-
|
|
428
51
|
## What's Next?
|
|
429
52
|
|
|
430
53
|
<Cards>
|
|
431
54
|
<Card
|
|
432
|
-
title="
|
|
433
|
-
description="
|
|
434
|
-
href="/docs/
|
|
55
|
+
title="Installation"
|
|
56
|
+
description="Full installation guide with CLI and manual setup options"
|
|
57
|
+
href="/docs/installation"
|
|
435
58
|
/>
|
|
436
59
|
<Card
|
|
437
|
-
title="
|
|
438
|
-
description="
|
|
439
|
-
href="/docs/
|
|
60
|
+
title="AI-Assisted Development"
|
|
61
|
+
description="Use AI tools to build with assistant-ui faster"
|
|
62
|
+
href="/docs/llm"
|
|
440
63
|
/>
|
|
441
64
|
<Card
|
|
442
|
-
title="
|
|
443
|
-
description="
|
|
444
|
-
href="/docs/
|
|
65
|
+
title="Pick a Runtime"
|
|
66
|
+
description="Choose the right runtime for your needs"
|
|
67
|
+
href="/docs/runtimes/pick-a-runtime"
|
|
445
68
|
/>
|
|
446
69
|
<Card
|
|
447
70
|
title="Examples"
|