ai 7.0.60 → 7.0.62
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 +16 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +3 -3
- package/docs/03-ai-sdk-core/38-video-generation.mdx +16 -15
- package/docs/04-ai-sdk-ui/05-completion.mdx +21 -0
- package/docs/07-reference/02-ai-sdk-ui/02-use-completion.mdx +15 -2
- package/package.json +3 -3
- package/src/ui/chat.ts +20 -4
- package/src/ui/use-completion.ts +4 -4
package/dist/internal/index.js
CHANGED
|
@@ -163,9 +163,9 @@ Here are the capabilities of popular models:
|
|
|
163
163
|
| [Mistral](/providers/ai-sdk-providers/mistral) | `pixtral-12b-2409` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
164
164
|
| [DeepSeek](/providers/ai-sdk-providers/deepseek) | `deepseek-chat` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
165
165
|
| [DeepSeek](/providers/ai-sdk-providers/deepseek) | `deepseek-reasoner` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
166
|
-
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `
|
|
167
|
-
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `
|
|
168
|
-
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `
|
|
166
|
+
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `gpt-oss-120b` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
167
|
+
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `zai-glm-4.7` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
168
|
+
| [Cerebras](/providers/ai-sdk-providers/cerebras) | `gemma-4-31b` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
169
169
|
| [Groq](/providers/ai-sdk-providers/groq) | `meta-llama/llama-4-scout-17b-16e-instruct` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
170
170
|
| [Groq](/providers/ai-sdk-providers/groq) | `llama-3.3-70b-versatile` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
171
171
|
| [Groq](/providers/ai-sdk-providers/groq) | `llama-3.1-8b-instant` | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
@@ -466,20 +466,21 @@ try {
|
|
|
466
466
|
|
|
467
467
|
## Video Models
|
|
468
468
|
|
|
469
|
-
| Provider | Model | Features
|
|
470
|
-
| ----------------------------------------------------------------------- | --------------------------- |
|
|
471
|
-
| [FAL](/providers/ai-sdk-providers/fal#video-models) | `luma-dream-machine/ray-2` | Text-to-video, image-to-video
|
|
472
|
-
| [FAL](/providers/ai-sdk-providers/fal#video-models) | `minimax-video` | Text-to-video
|
|
473
|
-
| [Google](/providers/ai-sdk-providers/google#video-models) | `veo-2.0-generate-001` | Text-to-video, up to 4 videos per call
|
|
474
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.1-generate-001` | Text-to-video, audio generation
|
|
475
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.1-fast-generate-001` | Text-to-video, audio generation
|
|
476
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.0-generate-001` | Text-to-video, audio generation
|
|
477
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.0-fast-generate-001` | Text-to-video, audio generation
|
|
478
|
-
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-2.0-generate-001` | Text-to-video, up to 4 videos per call
|
|
479
|
-
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-t2v` | Text-to-video
|
|
480
|
-
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-i2v` | Image-to-video
|
|
481
|
-
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-motion-control` | Motion control
|
|
482
|
-
| [Replicate](/providers/ai-sdk-providers/replicate#video-models) | `minimax/video-01` | Text-to-video
|
|
483
|
-
| [xAI](/providers/ai-sdk-providers/xai#video-models) | `grok-imagine-video` | Text-to-video, image-to-video, editing, extension, R2V
|
|
469
|
+
| Provider | Model | Features |
|
|
470
|
+
| ----------------------------------------------------------------------- | --------------------------- | ----------------------------------------------------------------------------- |
|
|
471
|
+
| [FAL](/providers/ai-sdk-providers/fal#video-models) | `luma-dream-machine/ray-2` | Text-to-video, image-to-video |
|
|
472
|
+
| [FAL](/providers/ai-sdk-providers/fal#video-models) | `minimax-video` | Text-to-video |
|
|
473
|
+
| [Google](/providers/ai-sdk-providers/google#video-models) | `veo-2.0-generate-001` | Text-to-video, up to 4 videos per call |
|
|
474
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.1-generate-001` | Text-to-video, audio generation |
|
|
475
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.1-fast-generate-001` | Text-to-video, audio generation |
|
|
476
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.0-generate-001` | Text-to-video, audio generation |
|
|
477
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-3.0-fast-generate-001` | Text-to-video, audio generation |
|
|
478
|
+
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#video-models) | `veo-2.0-generate-001` | Text-to-video, up to 4 videos per call |
|
|
479
|
+
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-t2v` | Text-to-video |
|
|
480
|
+
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-i2v` | Image-to-video |
|
|
481
|
+
| [Kling AI](/providers/ai-sdk-providers/klingai#video-models) | `kling-v2.6-motion-control` | Motion control |
|
|
482
|
+
| [Replicate](/providers/ai-sdk-providers/replicate#video-models) | `minimax/video-01` | Text-to-video |
|
|
483
|
+
| [xAI](/providers/ai-sdk-providers/xai#video-models) | `grok-imagine-video` | Text-to-video, image-to-video, editing, extension, R2V |
|
|
484
|
+
| [xAI](/providers/ai-sdk-providers/xai#video-models) | `grok-imagine-video-1.5` | Text-to-video, image-to-video, editing, extension, R2V (with reference audio) |
|
|
484
485
|
|
|
485
486
|
Above are a small subset of the video models supported by the AI SDK providers. For more, see the respective provider documentation.
|
|
@@ -185,3 +185,24 @@ const { messages, input, handleInputChange, handleSubmit } = useCompletion({
|
|
|
185
185
|
```
|
|
186
186
|
|
|
187
187
|
In this example, the `useCompletion` hook sends a POST request to the `/api/completion` endpoint with the specified headers, additional body fields, and credentials for that fetch request. On your server side, you can handle the request with these additional information.
|
|
188
|
+
|
|
189
|
+
You can provide a type for the additional body fields. The type applies to
|
|
190
|
+
both the body configured on the hook and the body passed to `complete`:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
type CompletionBody = {
|
|
194
|
+
model: 'fast' | 'smart';
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const { complete } = useCompletion<CompletionBody>({
|
|
198
|
+
body: {
|
|
199
|
+
model: 'fast',
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
await complete('What is a completion?', {
|
|
204
|
+
body: {
|
|
205
|
+
model: 'smart',
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
```
|
|
@@ -42,6 +42,19 @@ Allows you to create text completion based capabilities for your application. It
|
|
|
42
42
|
|
|
43
43
|
## API Signature
|
|
44
44
|
|
|
45
|
+
### Type Parameters
|
|
46
|
+
|
|
47
|
+
<PropertiesTable
|
|
48
|
+
content={[
|
|
49
|
+
{
|
|
50
|
+
name: 'BODY',
|
|
51
|
+
type: 'object',
|
|
52
|
+
description:
|
|
53
|
+
'The type of the additional request body passed through the hook options or the complete function. Defaults to object.',
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
/>
|
|
57
|
+
|
|
45
58
|
### Parameters
|
|
46
59
|
|
|
47
60
|
<PropertiesTable
|
|
@@ -88,7 +101,7 @@ Allows you to create text completion based capabilities for your application. It
|
|
|
88
101
|
},
|
|
89
102
|
{
|
|
90
103
|
name: 'body',
|
|
91
|
-
type: '
|
|
104
|
+
type: 'BODY',
|
|
92
105
|
description:
|
|
93
106
|
'An optional, additional body object to be passed to the API endpoint.',
|
|
94
107
|
},
|
|
@@ -134,7 +147,7 @@ Allows you to create text completion based capabilities for your application. It
|
|
|
134
147
|
},
|
|
135
148
|
{
|
|
136
149
|
name: 'complete',
|
|
137
|
-
type: '(prompt: string, options?: { headers?: Record<string, string> | Headers, body?:
|
|
150
|
+
type: '(prompt: string, options?: { headers?: Record<string, string> | Headers, body?: BODY }) => Promise<string | null | undefined>',
|
|
138
151
|
description:
|
|
139
152
|
'Function to execute text completion based on the provided prompt. Returns the completion result when finished.',
|
|
140
153
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.62",
|
|
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.49",
|
|
46
46
|
"@ai-sdk/provider": "4.0.7",
|
|
47
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
47
|
+
"@ai-sdk/provider-utils": "5.0.27"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@edge-runtime/vm": "^5.0.0",
|
package/src/ui/chat.ts
CHANGED
|
@@ -257,6 +257,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
257
257
|
private onData?: ChatInit<UI_MESSAGE>['onData'];
|
|
258
258
|
private sendAutomaticallyWhen?: ChatInit<UI_MESSAGE>['sendAutomaticallyWhen'];
|
|
259
259
|
|
|
260
|
+
private pendingMessagePreparations = new Set<AbortController>();
|
|
260
261
|
private activeResponse: ActiveResponse<UI_MESSAGE> | undefined = undefined;
|
|
261
262
|
private activeResumeRequest: ActiveResumeRequest | undefined = undefined;
|
|
262
263
|
private jobExecutor = new SerialJobExecutor();
|
|
@@ -370,9 +371,21 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
370
371
|
let uiMessage: CreateUIMessage<UI_MESSAGE>;
|
|
371
372
|
|
|
372
373
|
if ('text' in message || 'files' in message) {
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
const abortController = new AbortController();
|
|
375
|
+
this.pendingMessagePreparations.add(abortController);
|
|
376
|
+
|
|
377
|
+
let fileParts: FileUIPart[];
|
|
378
|
+
try {
|
|
379
|
+
fileParts = Array.isArray(message.files)
|
|
380
|
+
? message.files
|
|
381
|
+
: await convertFileListToFileUIParts(message.files);
|
|
382
|
+
} finally {
|
|
383
|
+
this.pendingMessagePreparations.delete(abortController);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (abortController.signal.aborted) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
376
389
|
|
|
377
390
|
uiMessage = {
|
|
378
391
|
parts: [
|
|
@@ -589,6 +602,9 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
589
602
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
590
603
|
*/
|
|
591
604
|
stop = async () => {
|
|
605
|
+
for (const controller of this.pendingMessagePreparations) {
|
|
606
|
+
controller.abort();
|
|
607
|
+
}
|
|
592
608
|
this.activeResumeRequest?.abortController.abort();
|
|
593
609
|
this.activeResponse?.abortController.abort();
|
|
594
610
|
};
|
|
@@ -705,7 +721,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
705
721
|
const response = {
|
|
706
722
|
state: createStreamingUIMessageState({
|
|
707
723
|
lastMessage:
|
|
708
|
-
trigger === 'regenerate-message'
|
|
724
|
+
trigger === 'resume-stream' || trigger === 'regenerate-message'
|
|
709
725
|
? undefined
|
|
710
726
|
: this.state.snapshot(lastMessage),
|
|
711
727
|
messageId: this.generateId(),
|
package/src/ui/use-completion.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FetchFunction } from '@ai-sdk/provider-utils';
|
|
2
2
|
|
|
3
|
-
export type CompletionRequestOptions = {
|
|
3
|
+
export type CompletionRequestOptions<BODY extends object = object> = {
|
|
4
4
|
/**
|
|
5
5
|
* An optional object of headers to be passed to the API endpoint.
|
|
6
6
|
*/
|
|
@@ -9,10 +9,10 @@ export type CompletionRequestOptions = {
|
|
|
9
9
|
/**
|
|
10
10
|
* An optional object to be passed to the API endpoint.
|
|
11
11
|
*/
|
|
12
|
-
body?:
|
|
12
|
+
body?: BODY;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export type UseCompletionOptions = {
|
|
15
|
+
export type UseCompletionOptions<BODY extends object = object> = {
|
|
16
16
|
/**
|
|
17
17
|
* The API endpoint that accepts a `{ prompt: string }` object and returns
|
|
18
18
|
* a stream of tokens of the AI completion response. Defaults to `/api/completion`.
|
|
@@ -69,7 +69,7 @@ export type UseCompletionOptions = {
|
|
|
69
69
|
* })
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
|
-
body?:
|
|
72
|
+
body?: BODY;
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Streaming protocol that is used. Defaults to `data`.
|