Skip to content

Commit 72ea68f

Browse files
committed
refactor: point assistant consumers (e2e, docs, skill) at the /assistant subpaths
1 parent 1c1ca72 commit 72ea68f

5 files changed

Lines changed: 49 additions & 48 deletions

File tree

docs/assistant/index.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ single typed client, keyed by whichever capabilities you declared, so you can
2222
compose them: generate an image, then hand its URL straight to the model as
2323
the next chat turn, all through one connection.
2424

25+
Both live on the `/assistant` subpath of their packages —
26+
`@tanstack/ai/assistant` for `defineAssistant()` and
27+
`@tanstack/ai-react/assistant` for `useAssistant()` (Solid, Vue, and Svelte
28+
follow the same pattern) — rather than the package root.
29+
2530
## Defining the Assistant (Server)
2631

2732
Each capability is a plain callback: `(req) => <activity call>`. The `chat`
@@ -35,12 +40,8 @@ adapter is constructed, until a request actually reaches
3540

3641
```ts
3742
// api/assistant.ts
38-
import {
39-
chat,
40-
defineAssistant,
41-
generateImage,
42-
generateSpeech,
43-
} from '@tanstack/ai'
43+
import { chat, generateImage, generateSpeech } from '@tanstack/ai'
44+
import { defineAssistant } from '@tanstack/ai/assistant'
4445
import { openaiImage, openaiSpeech, openaiText } from '@tanstack/ai-openai'
4546

4647
export const blogAssistant = defineAssistant({
@@ -89,13 +90,10 @@ object with a property per declared capability: `assistant.chat` looks like
8990

9091
```tsx
9192
// components/Assistant.tsx
92-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
93-
import {
94-
chat,
95-
defineAssistant,
96-
generateImage,
97-
generateSpeech,
98-
} from '@tanstack/ai'
93+
import { fetchServerSentEvents } from '@tanstack/ai-react'
94+
import { useAssistant } from '@tanstack/ai-react/assistant'
95+
import { chat, generateImage, generateSpeech } from '@tanstack/ai'
96+
import { defineAssistant } from '@tanstack/ai/assistant'
9997
import { openaiImage, openaiSpeech, openaiText } from '@tanstack/ai-openai'
10098

10199
// The same object your server route exports — share it from one module in a
@@ -172,8 +170,10 @@ Generate an image, then hand its URL to the model as multimodal input
172170
alongside a follow-up instruction:
173171

174172
```tsx
175-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
176-
import { chat, defineAssistant, generateImage } from '@tanstack/ai'
173+
import { fetchServerSentEvents } from '@tanstack/ai-react'
174+
import { useAssistant } from '@tanstack/ai-react/assistant'
175+
import { chat, generateImage } from '@tanstack/ai'
176+
import { defineAssistant } from '@tanstack/ai/assistant'
177177
import { openaiImage, openaiText } from '@tanstack/ai-openai'
178178

179179
// The same object your server route exports — share it from one module in a
@@ -233,8 +233,10 @@ The reverse works too — read the model's latest reply out of
233233
narrating it with `assistant.speech.generate`:
234234

235235
```tsx
236-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
237-
import { chat, defineAssistant, generateSpeech } from '@tanstack/ai'
236+
import { fetchServerSentEvents } from '@tanstack/ai-react'
237+
import { useAssistant } from '@tanstack/ai-react/assistant'
238+
import { chat, generateSpeech } from '@tanstack/ai'
239+
import { defineAssistant } from '@tanstack/ai/assistant'
238240
import { openaiSpeech, openaiText } from '@tanstack/ai-openai'
239241

240242
// The same object your server route exports — share it from one module in a
@@ -283,8 +285,10 @@ re-declare on the client to get typed tool-call parts:
283285

284286
```tsx
285287
// components/WeatherChat.tsx
286-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
287-
import { chat, defineAssistant, toolDefinition } from '@tanstack/ai'
288+
import { fetchServerSentEvents } from '@tanstack/ai-react'
289+
import { useAssistant } from '@tanstack/ai-react/assistant'
290+
import { chat, toolDefinition } from '@tanstack/ai'
291+
import { defineAssistant } from '@tanstack/ai/assistant'
288292
import { openaiText } from '@tanstack/ai-openai'
289293
import { z } from 'zod'
290294

@@ -372,8 +376,10 @@ export const showToast = showToastDef.client((input) => {
372376
```
373377

374378
```tsx
375-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
376-
import { chat, defineAssistant } from '@tanstack/ai'
379+
import { fetchServerSentEvents } from '@tanstack/ai-react'
380+
import { useAssistant } from '@tanstack/ai-react/assistant'
381+
import { chat } from '@tanstack/ai'
382+
import { defineAssistant } from '@tanstack/ai/assistant'
377383
import { openaiText } from '@tanstack/ai-openai'
378384
import { showToastDef, showToast } from './tools'
379385

@@ -407,8 +413,10 @@ terminal object) fields — the same inference
407413

408414
```tsx
409415
// components/BlogOutlineForm.tsx
410-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
411-
import { chat, defineAssistant } from '@tanstack/ai'
416+
import { fetchServerSentEvents } from '@tanstack/ai-react'
417+
import { useAssistant } from '@tanstack/ai-react/assistant'
418+
import { chat } from '@tanstack/ai'
419+
import { defineAssistant } from '@tanstack/ai/assistant'
412420
import { openaiText } from '@tanstack/ai-openai'
413421
import { z } from 'zod'
414422

docs/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
"label": "Assistant",
316316
"to": "assistant/index",
317317
"addedAt": "2026-07-13",
318-
"updatedAt": "2026-07-13"
318+
"updatedAt": "2026-07-14"
319319
}
320320
]
321321
},

packages/ai/skills/ai-core/assistant/SKILL.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,8 @@ it's safe to import into an isomorphic module shared with the client.
4343

4444
```typescript
4545
// src/lib/assistant.ts — shared/isomorphic module
46-
import {
47-
chat,
48-
defineAssistant,
49-
generateImage,
50-
generateSpeech,
51-
} from '@tanstack/ai'
46+
import { chat, generateImage, generateSpeech } from '@tanstack/ai'
47+
import { defineAssistant } from '@tanstack/ai/assistant'
5248
import {
5349
openaiText,
5450
openaiImage,
@@ -107,7 +103,8 @@ capabilities get a `400` before any callback runs.
107103
### Client: `useAssistant`
108104

109105
```tsx
110-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
106+
import { fetchServerSentEvents } from '@tanstack/ai-react'
107+
import { useAssistant } from '@tanstack/ai-react/assistant'
111108
import { assistant } from '../lib/assistant'
112109

113110
function AssistantPanel() {
@@ -155,7 +152,7 @@ is the full `useChat` return (`messages`, `sendMessage`, `isLoading`,
155152
`status`, `stop`, `reset`).
156153

157154
Vue/Solid/Svelte have identical patterns with different hook imports
158-
(e.g. `import { useAssistant } from '@tanstack/ai-solid'`).
155+
(e.g. `import { useAssistant } from '@tanstack/ai-solid/assistant'`).
159156

160157
## Core Patterns
161158

@@ -167,7 +164,8 @@ narrowed by tool name, input, and output — with **no** client-side
167164
re-declaration needed for typing:
168165

169166
```typescript
170-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
167+
import { fetchServerSentEvents } from '@tanstack/ai-react'
168+
import { useAssistant } from '@tanstack/ai-react/assistant'
171169
import { blogAssistant } from '../lib/assistant' // chat callback passed tools: [getWeather]
172170
173171
const assistant = useAssistant(blogAssistant, {
@@ -186,7 +184,8 @@ tool's _definition_ (for the model and for typing). Pass the client
186184
implementation there to register its runtime:
187185

188186
```typescript
189-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
187+
import { fetchServerSentEvents } from '@tanstack/ai-react'
188+
import { useAssistant } from '@tanstack/ai-react/assistant'
190189
import { blogAssistant } from '../lib/assistant' // chat callback passed tools: [showToastDef]
191190
import { showToast } from '../lib/tools' // showToastDef.client((input) => ...)
192191
@@ -208,7 +207,8 @@ outputSchema })` returns. Omit `outputSchema` and neither field is present on
208207
the type.
209208

210209
```typescript
211-
import { useAssistant, fetchServerSentEvents } from '@tanstack/ai-react'
210+
import { fetchServerSentEvents } from '@tanstack/ai-react'
211+
import { useAssistant } from '@tanstack/ai-react/assistant'
212212
import { blogAssistant } from '../lib/assistant' // chat callback passed outputSchema: BlogOutlineSchema
213213
214214
const assistant = useAssistant(blogAssistant, {

testing/e2e/src/routes/api.assistant.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { createFileRoute } from '@tanstack/react-router'
2-
import {
3-
chat,
4-
defineAssistant,
5-
generateImage,
6-
maxIterations,
7-
} from '@tanstack/ai'
2+
import { chat, generateImage, maxIterations } from '@tanstack/ai'
3+
import { defineAssistant } from '@tanstack/ai/assistant'
84
import type { Provider } from '@/lib/types'
95
import { createTextAdapter } from '@/lib/providers'
106
import { createImageAdapter } from '@/lib/media-providers'

testing/e2e/src/routes/assistant.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { createFileRoute } from '@tanstack/react-router'
2-
import {
3-
chat,
4-
defineAssistant,
5-
generateImage,
6-
maxIterations,
7-
} from '@tanstack/ai'
8-
import { fetchServerSentEvents, useAssistant } from '@tanstack/ai-react'
2+
import { chat, generateImage, maxIterations } from '@tanstack/ai'
3+
import { defineAssistant } from '@tanstack/ai/assistant'
4+
import { fetchServerSentEvents } from '@tanstack/ai-react'
5+
import { useAssistant } from '@tanstack/ai-react/assistant'
96
import { openaiImage, openaiText } from '@tanstack/ai-openai'
107
import { ChatUI } from '@/components/ChatUI'
118
import type { Provider } from '@/lib/types'

0 commit comments

Comments
 (0)