ai 7.0.16 → 7.0.18
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/CHANGELOG.md +15 -0
- package/dist/index.js +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +2 -2
- package/docs/04-ai-sdk-ui/05-completion.mdx +2 -2
- package/docs/04-ai-sdk-ui/08-object-generation.mdx +7 -10
- package/docs/07-reference/02-ai-sdk-ui/01-use-chat.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/03-use-object.mdx +6 -9
- package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +3 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ac306ed]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.6
|
|
9
|
+
- @ai-sdk/gateway@4.0.14
|
|
10
|
+
|
|
11
|
+
## 7.0.17
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [cad8227]
|
|
16
|
+
- @ai-sdk/gateway@4.0.13
|
|
17
|
+
|
|
3
18
|
## 7.0.16
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,7 @@ import {
|
|
|
1089
1089
|
} from "@ai-sdk/provider-utils";
|
|
1090
1090
|
|
|
1091
1091
|
// src/version.ts
|
|
1092
|
-
var VERSION = true ? "7.0.
|
|
1092
|
+
var VERSION = true ? "7.0.18" : "0.0.0-test";
|
|
1093
1093
|
|
|
1094
1094
|
// src/util/download/download.ts
|
|
1095
1095
|
var download = async ({
|
package/dist/internal/index.js
CHANGED
|
@@ -326,12 +326,12 @@ When the user clicks the "Regenerate" button, the AI provider will regenerate th
|
|
|
326
326
|
<Note>This feature is currently only available for React.</Note>
|
|
327
327
|
|
|
328
328
|
By default, the `useChat` hook will trigger a render every time a new chunk is received.
|
|
329
|
-
You can throttle the UI updates with the `
|
|
329
|
+
You can throttle the UI updates with the `throttle` option.
|
|
330
330
|
|
|
331
331
|
```tsx filename="page.tsx" highlight="2-3"
|
|
332
332
|
const { messages, ... } = useChat({
|
|
333
333
|
// Throttle the messages and data updates to 50ms:
|
|
334
|
-
|
|
334
|
+
throttle: 50
|
|
335
335
|
})
|
|
336
336
|
```
|
|
337
337
|
|
|
@@ -143,12 +143,12 @@ When the user clicks the "Stop" button, the fetch request will be aborted. This
|
|
|
143
143
|
<Note>This feature is currently only available for React.</Note>
|
|
144
144
|
|
|
145
145
|
By default, the `useCompletion` hook will trigger a render every time a new chunk is received.
|
|
146
|
-
You can throttle the UI updates with the `
|
|
146
|
+
You can throttle the UI updates with the `throttle` option.
|
|
147
147
|
|
|
148
148
|
```tsx filename="page.tsx" highlight="2-3"
|
|
149
149
|
const { completion, ... } = useCompletion({
|
|
150
150
|
// Throttle the completion and data updates to 50ms:
|
|
151
|
-
|
|
151
|
+
throttle: 50
|
|
152
152
|
})
|
|
153
153
|
```
|
|
154
154
|
|
|
@@ -5,10 +5,7 @@ description: Learn how to use the useObject hook.
|
|
|
5
5
|
|
|
6
6
|
# Object Generation
|
|
7
7
|
|
|
8
|
-
<Note>
|
|
9
|
-
`useObject` is an experimental feature and only available in React, Svelte,
|
|
10
|
-
and Vue.
|
|
11
|
-
</Note>
|
|
8
|
+
<Note>`useObject` is only available in React, Svelte, and Vue.</Note>
|
|
12
9
|
|
|
13
10
|
The [`useObject`](/docs/reference/ai-sdk-ui/use-object) hook allows you to create interfaces that represent a structured JSON object that is being streamed.
|
|
14
11
|
|
|
@@ -46,7 +43,7 @@ Please note the code for handling `undefined` values in the JSX.
|
|
|
46
43
|
```tsx filename='app/page.tsx'
|
|
47
44
|
'use client';
|
|
48
45
|
|
|
49
|
-
import {
|
|
46
|
+
import { useObject } from '@ai-sdk/react';
|
|
50
47
|
import { notificationSchema } from './api/notifications/schema';
|
|
51
48
|
|
|
52
49
|
export default function Page() {
|
|
@@ -115,7 +112,7 @@ When using `useObject` with enum output mode, your schema must be an object with
|
|
|
115
112
|
```tsx filename='app/classify/page.tsx'
|
|
116
113
|
'use client';
|
|
117
114
|
|
|
118
|
-
import {
|
|
115
|
+
import { useObject } from '@ai-sdk/react';
|
|
119
116
|
import { z } from 'zod';
|
|
120
117
|
|
|
121
118
|
export default function ClassifyPage() {
|
|
@@ -174,7 +171,7 @@ purposes:
|
|
|
174
171
|
```tsx filename='app/page.tsx' highlight="6,13-20,24"
|
|
175
172
|
'use client';
|
|
176
173
|
|
|
177
|
-
import {
|
|
174
|
+
import { useObject } from '@ai-sdk/react';
|
|
178
175
|
|
|
179
176
|
export default function Page() {
|
|
180
177
|
const { isLoading, object, submit } = useObject({
|
|
@@ -211,7 +208,7 @@ The `stop` function can be used to stop the object generation process. This can
|
|
|
211
208
|
```tsx filename='app/page.tsx' highlight="6,14-16"
|
|
212
209
|
'use client';
|
|
213
210
|
|
|
214
|
-
import {
|
|
211
|
+
import { useObject } from '@ai-sdk/react';
|
|
215
212
|
|
|
216
213
|
export default function Page() {
|
|
217
214
|
const { isLoading, stop, object, submit } = useObject({
|
|
@@ -256,7 +253,7 @@ It can be used to display an error message, or to disable the submit button:
|
|
|
256
253
|
```tsx file="app/page.tsx" highlight="6,13"
|
|
257
254
|
'use client';
|
|
258
255
|
|
|
259
|
-
import {
|
|
256
|
+
import { useObject } from '@ai-sdk/react';
|
|
260
257
|
|
|
261
258
|
export default function Page() {
|
|
262
259
|
const { error, object, submit } = useObject({
|
|
@@ -295,7 +292,7 @@ These callbacks can be used to trigger additional actions, such as logging, anal
|
|
|
295
292
|
```tsx filename='app/page.tsx' highlight="10-20"
|
|
296
293
|
'use client';
|
|
297
294
|
|
|
298
|
-
import {
|
|
295
|
+
import { useObject } from '@ai-sdk/react';
|
|
299
296
|
import { notificationSchema } from './api/notifications/schema';
|
|
300
297
|
|
|
301
298
|
export default function Page() {
|
|
@@ -334,7 +334,7 @@ Allows you to easily create a conversational user interface for your chatbot app
|
|
|
334
334
|
'Optional callback function that is called when a data part is received.',
|
|
335
335
|
},
|
|
336
336
|
{
|
|
337
|
-
name: '
|
|
337
|
+
name: 'throttle',
|
|
338
338
|
type: 'number',
|
|
339
339
|
isOptional: true,
|
|
340
340
|
description:
|
|
@@ -113,7 +113,7 @@ Allows you to create text completion based capabilities for your application. It
|
|
|
113
113
|
'Optional. A custom fetch function to be used for the API call. Defaults to the global fetch function.',
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
|
-
name: '
|
|
116
|
+
name: 'throttle',
|
|
117
117
|
type: 'number',
|
|
118
118
|
isOptional: true,
|
|
119
119
|
description:
|
|
@@ -3,12 +3,9 @@ title: useObject
|
|
|
3
3
|
description: API reference for the useObject hook.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# `
|
|
6
|
+
# `useObject()`
|
|
7
7
|
|
|
8
|
-
<Note>
|
|
9
|
-
`useObject` is an experimental feature and only available in React, Svelte,
|
|
10
|
-
and Vue.
|
|
11
|
-
</Note>
|
|
8
|
+
<Note>`useObject` is only available in React, Svelte, and Vue.</Note>
|
|
12
9
|
|
|
13
10
|
Allows you to consume text streams that represent a JSON object and parse them into a complete object based on a schema.
|
|
14
11
|
You can use it together with [`streamText`](/docs/reference/ai-sdk-core/stream-text) and [`Output.object()`](/docs/reference/ai-sdk-core/output#output-object) in the backend.
|
|
@@ -16,7 +13,7 @@ You can use it together with [`streamText`](/docs/reference/ai-sdk-core/stream-t
|
|
|
16
13
|
```tsx
|
|
17
14
|
'use client';
|
|
18
15
|
|
|
19
|
-
import {
|
|
16
|
+
import { useObject } from '@ai-sdk/react';
|
|
20
17
|
|
|
21
18
|
export default function Page() {
|
|
22
19
|
const { object, submit } = useObject({
|
|
@@ -38,21 +35,21 @@ export default function Page() {
|
|
|
38
35
|
<Tabs items={['React', 'Svelte', 'Vue']}>
|
|
39
36
|
<Tab>
|
|
40
37
|
<Snippet
|
|
41
|
-
text="import {
|
|
38
|
+
text="import { useObject } from '@ai-sdk/react'"
|
|
42
39
|
dark
|
|
43
40
|
prompt={false}
|
|
44
41
|
/>
|
|
45
42
|
</Tab>
|
|
46
43
|
<Tab>
|
|
47
44
|
<Snippet
|
|
48
|
-
text="import {
|
|
45
|
+
text="import { StructuredObject } from '@ai-sdk/svelte'"
|
|
49
46
|
dark
|
|
50
47
|
prompt={false}
|
|
51
48
|
/>
|
|
52
49
|
</Tab>
|
|
53
50
|
<Tab>
|
|
54
51
|
<Snippet
|
|
55
|
-
text="import {
|
|
52
|
+
text="import { useObject } from '@ai-sdk/vue'"
|
|
56
53
|
dark
|
|
57
54
|
prompt={false}
|
|
58
55
|
/>
|
|
@@ -18,14 +18,14 @@ need updating (e.g. Markdown). Throttling can mitigate this.
|
|
|
18
18
|
|
|
19
19
|
## Solution
|
|
20
20
|
|
|
21
|
-
Use the `
|
|
21
|
+
Use the `throttle` option to throttle the UI updates:
|
|
22
22
|
|
|
23
23
|
### `useChat`
|
|
24
24
|
|
|
25
25
|
```tsx filename="page.tsx" highlight="2-3"
|
|
26
26
|
const { messages, ... } = useChat({
|
|
27
27
|
// Throttle the messages and data updates to 50ms:
|
|
28
|
-
|
|
28
|
+
throttle: 50
|
|
29
29
|
})
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -34,6 +34,6 @@ const { messages, ... } = useChat({
|
|
|
34
34
|
```tsx filename="page.tsx" highlight="2-3"
|
|
35
35
|
const { completion, ... } = useCompletion({
|
|
36
36
|
// Throttle the completion and data updates to 50ms:
|
|
37
|
-
|
|
37
|
+
throttle: 50
|
|
38
38
|
})
|
|
39
39
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.14",
|
|
46
46
|
"@ai-sdk/provider": "4.0.2",
|
|
47
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
47
|
+
"@ai-sdk/provider-utils": "5.0.6"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@edge-runtime/vm": "^5.0.0",
|