@tanstack/ai-solid 0.2.0 → 0.2.1
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/README.md +8 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ Your backend should use the `chat()` method which **automatically handles tool e
|
|
|
157
157
|
2. Use `chat()` to stream responses (with automatic tool execution):
|
|
158
158
|
|
|
159
159
|
```typescript
|
|
160
|
-
import { chat,
|
|
160
|
+
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
|
|
161
161
|
import { openaiText } from '@tanstack/ai-openai'
|
|
162
162
|
|
|
163
163
|
export async function POST(request: Request) {
|
|
@@ -172,7 +172,7 @@ export async function POST(request: Request) {
|
|
|
172
172
|
})
|
|
173
173
|
|
|
174
174
|
// Convert to HTTP streaming response with SSE headers
|
|
175
|
-
return
|
|
175
|
+
return toServerSentEventsResponse(stream)
|
|
176
176
|
}
|
|
177
177
|
```
|
|
178
178
|
|
|
@@ -311,7 +311,7 @@ function App() {
|
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
313
|
import express from 'express'
|
|
314
|
-
import { chat,
|
|
314
|
+
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
|
|
315
315
|
import { openaiText } from '@tanstack/ai-openai'
|
|
316
316
|
|
|
317
317
|
const app = express()
|
|
@@ -327,7 +327,7 @@ app.post('/api/chat', async (req, res) => {
|
|
|
327
327
|
messages,
|
|
328
328
|
})
|
|
329
329
|
|
|
330
|
-
const response =
|
|
330
|
+
const response = toServerSentEventsResponse(stream)
|
|
331
331
|
|
|
332
332
|
// Copy headers and stream to Express response
|
|
333
333
|
response.headers.forEach((value, key) => {
|
|
@@ -352,7 +352,7 @@ app.listen(3000)
|
|
|
352
352
|
|
|
353
353
|
```typescript
|
|
354
354
|
// app/api/chat/route.ts
|
|
355
|
-
import { chat,
|
|
355
|
+
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
|
|
356
356
|
import { openaiText } from '@tanstack/ai-openai'
|
|
357
357
|
|
|
358
358
|
export const runtime = 'edge'
|
|
@@ -361,7 +361,7 @@ export async function POST(req: Request) {
|
|
|
361
361
|
const { messages } = await req.json()
|
|
362
362
|
|
|
363
363
|
// One line!
|
|
364
|
-
return
|
|
364
|
+
return toServerSentEventsResponse(
|
|
365
365
|
chat({
|
|
366
366
|
adapter: openaiText(),
|
|
367
367
|
model: 'gpt-4o',
|
|
@@ -375,7 +375,7 @@ export async function POST(req: Request) {
|
|
|
375
375
|
|
|
376
376
|
```typescript
|
|
377
377
|
import { createFileRoute } from '@tanstack/react-router'
|
|
378
|
-
import { chat,
|
|
378
|
+
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
|
|
379
379
|
import { anthropicText } from '@tanstack/ai-anthropic'
|
|
380
380
|
|
|
381
381
|
export const Route = createFileRoute('/api/chat')({
|
|
@@ -385,7 +385,7 @@ export const Route = createFileRoute('/api/chat')({
|
|
|
385
385
|
const { messages } = await request.json()
|
|
386
386
|
|
|
387
387
|
// One line with automatic tool execution!
|
|
388
|
-
return
|
|
388
|
+
return toServerSentEventsResponse(
|
|
389
389
|
chat({
|
|
390
390
|
adapter: anthropicText(),
|
|
391
391
|
model: 'claude-sonnet-4-20250514',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-solid",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Solid hooks for TanStack AI",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"streaming"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tanstack/ai-client": "0.2.
|
|
34
|
+
"@tanstack/ai-client": "0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@solidjs/testing-library": "^0.8.10",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"solid-js": ">=1.9.10",
|
|
48
|
-
"@tanstack/ai": "^0.2.
|
|
48
|
+
"@tanstack/ai": "^0.2.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"clean": "premove ./build ./dist",
|